Maven 3 upgrade - maven ear plugin bundles different version of libs - ClassNotFoundException weblogic

StackOverflow https://stackoverflow.com/questions/22603771

  •  20-06-2023
  •  | 
  •  

Question

I have a maven multi module project. In which there are few web projects and ejb projects. There are no change in the source code of the entire project. Just I upgraded to Maven 3 and built my project. The resulting ear file has libraries of different versions than the ear file built using maven 2. Some older version of particular libs and some newer version of particular libs.

for eg: commons-logging-1.1.1 was with maven2 but wiht maven 3 it resolved to commons-logging-1.0.3

The real problem is, when I try to deploy the ear created with maven 3 into weblogic server, I get ClassNotFoundException for spring classes. But the spring classes are there in the ear file. I double checked it. The ear file of the same source code built with maven 2 deploys successfully.

<Mar 24, 2014 11:42:17 AM IST> <Error> <HTTP> <BEA-101371> <There was a failure when processing annotations for application C:\weblogic\appsrv\domains\mydomain\servers\admin\tmp\_WL_user\myApp-ear\1697udy\app-control.war. Please make sure that the annotations are valid. The error is org.springframework.web.context.support.HttpRequestHandlerServlet>
<Mar 24, 2014 11:42:17 AM IST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'mayApp-ear' due to error weblogic.application.ModuleException: Failed to load webapp: '/app-control-war'.
weblogic.application.ModuleException: Failed to load webapp: '/app-control-war'
        at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:387)
        at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:180)
        at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
        at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:388)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
        Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.springframework.web.context.support.HttpRequestHandlerServlet
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        Truncated. see log file for complete stacktrace

If I upgrade maven, is there something I need to tell to application server?

Update: I see there is no classpath entry in one of my ejb module's manifest file. That may be the cause of the issue. But why is it missing when everything fine with maven2 build? There is no change in any pom file at all.

Was it helpful?

Solution

It turned out to be a bug with Maven 3.0.3

As a workaround, added maven-jar-plugin to generate manifest file with class path entries and added manifestFile property to maven-ejb-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
        </archive>
    </configuration>
</plugin>
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-ejb-plugin</artifactId>
   <configuration>
       <ejbVersion>3.0</ejbVersion>
       <archive>
        <manifestFile>target/generated-resources/META-INF/MANIFEST.MF</manifestFile>
       </archive>
  </configuration>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top