0

I am using Maven to build a java ear file. When we deploy the ear to Weblogic, we get the following exception, which makes me think the dependencies need to be added to the ear file (packaged into the ear by maven):

<Feb 2, 2015 3:20:30 PM EST> <Error> <HTTP> <BEA-101371> <There was a failure when processing annotations for application /6v09bd/Develapp-0.1.war. Please make sure that the annotations are valid. The error is javax.faces.webapp.FacesServlet>
<Feb 2, 2015 3:20:30 PM EST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1422908423000' for task '18'. Error is: 'weblogic.application.ModuleException: Failed to load webapp: '/Develapp''
weblogic.application.ModuleException: Failed to load webapp: '/Develapp'
        at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:395)
        at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
        at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
        at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        Truncated. see log file for complete stacktrace

I attempted to add the maven plugin "jar-with-dependencies", according to this SO solution. But I get download errors for the plugin and maven won't compile the pom.xml. And I'm not sure if this plugin actually works for ear files.

Basically, I need to know how to get all the dependencies for the war into it so Weblogic is happy with the ear, if that makes sense.

Community
  • 1
  • 1
udog
  • 1,409
  • 1
  • 15
  • 25

2 Answers2

2

I'm guessing you are not using maven-war-plugin for building your war.. Because this plugin does what you are asking.. it copies your war dependencies to the lib folder.

Remember that provided scope dependencies don't get copied.

Plugin documentation: http://maven.apache.org/plugins/maven-war-plugin/

mendieta
  • 3,202
  • 2
  • 16
  • 22
0

you will need to have something like this in your war/pom.xml

<build>
  <finalName>${project.artifactId}</finalName>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
      </configuration>
    </plugin>
  </plugins>
</build>

and don't forget the ear/pom.xml

 <build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-ear-plugin</artifactId>
         <configuration>
            <modules>
               <webModule>
                  <moduleId>YOURService</moduleId>
                  <groupId>YOURGroupId</groupId>
                  <artifactId>YOURArtifactId</artifactId>
                  <contextRoot>/DevelApp</contextRoot>
               </webModule>
            </modules>
            <defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
            <skinnyWars>true</skinnyWars>
         </configuration>
      </plugin>            
   </plugins>
</build>

And if you have some special classes, that want to enforce into the web-app, you can always use this plugin:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-dependency-plugin</artifactId>
   <executions>
      <execution>
         <id>unpack-my-dependencies</id>
         <phase>process-resources</phase>
         <goals>
            <goal>unpack</goal>
         </goals>
         <configuration>
            <artifactItems>
               <artifactItem>
                  <groupId>another.groupId</groupId>
                  <artifactId>another.artifactId</artifactId>
                  <version>another.version</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
               </artifactItem>
            </artifactItems>
            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/APP-INF/classes
            </outputDirectory>
            <overWriteReleases>true</overWriteReleases>
            <includes>**/*.class</includes>
         </configuration>
      </execution>
   </executions>
</plugin>

You can always pass a dependency to your war just marking it with <scope>runtime</scope> (see: maven dependency scope)

Tulio C
  • 96
  • 1
  • 3