在EAR中打包WAR文件,以便可以使用WAR依赖项

时间:2011-03-04 11:16:09

标签: eclipse weblogic packaging war ear

我将WAR模块[my-web-app]添加到当前仅包含EJB模块的现有EAR应用程序[my-ear-app]中。 WAR模块是一个用Spring MVC 3.0编写的RESTful应用程序 这些应用程序是maven 2.x应用程序。 当我在WebLogic 10.3.2上运行EAR应用程序时,它无法发布我添加的WAR模块。 我在Eclipse Helios的WebLogic 10.3.2中运行它 我已经在pom中尝试了应用程序保险丝warpath配置但是没有用。我还看了一下瘦弱的战争方法。我在帖子末尾添加了相关材料的链接。

我似乎无法通过丢失的oxm lib错误 - NoClassDefFoundError:org / springframework / oxm / Marshaller。

尝试将EAR应用程序发布到WL应用程序服务器时会发生错误。

已发布的EAR部署为:

  • META-INF \ application.xml中
  • META-INF \ MANIFEST.MF
  • META-INF \ weblogic-application.xml
  • 我的Web-app.war
  • .beabuild.txt

EAR发布的WAR模块提取为:

  • WEB-INF \ lib中\ JSTL-1.2.jar
  • WEB-INF \ lib中\弹簧webmvc-3.0.5.RELEASE.jar

为了进行比较,来自Web应用程序的maven打包WAR提取为:

  • META-INF \ MANIFEST.MF
  • WEB-INF \类
  • WEB-INF \ JSP
  • WEB-INF \ lib(具有所有WAR依赖性)
  • WEB-INF \弹簧
  • 的web.xml

这是部分错误跟踪:

java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail.
    at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper$DeploymentProgressListener.watch(WlsJ2EEDeploymentHelper.java:1559)
    at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deploy (WlsJ2EEDeploymentHelper.java:484)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules (WeblogicServerBehaviour.java:1419)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer    (WeblogicServerBehaviour.java:861)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce (WeblogicServerBehaviour.java:655)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish (WeblogicServerBehaviour.java:522)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish (ServerBehaviourDelegate.java:775)
    at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:2888)
    at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:337)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: weblogic.application.ModuleException: [HTTP:101216]Servlet: "mywebapp" failed to preload on startup in Web application: "mywebapp". java.lang.NoClassDefFoundError: org/springframework/oxm/Marshaller
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:389)
        at java.lang.Class.getDeclaredConstructors(Class.java:1836)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determinCCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:227)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInsance (AbstractAutowireCapableBeanFactory.java:903)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject (AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactor.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:580)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:425)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:442)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:458)
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext (FrameworkServlet.java:339)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean (FrameworkServlet.java:306)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
        at javax.servlet.GenericServlet.init(GenericServlet.java:241)
        at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run (StubSecurityHelper.java:283)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.StubSecurityHelper.createServlet (StubSecurityHelper.java:64)
        at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance (StubLifecycleHelper.java:58)
        at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:531)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlet (WebAppServletContext.java:1915)
        at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup (WebAppServletContext.java:1889)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources (WebAppServletContext.java:1807)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3045)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1397)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next (ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
        at weblogic.application.internal.flow.ModuleStateDriver.start (ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.ScopedModuleDriver.start (ScopedModuleDriver.java:200)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start (ModuleListenerInvoker.java:247)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next (ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
        at weblogic.application.internal.flow.ModuleStateDriver.start (ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.StartModulesFlow.activate (StartModulesFlow.java:27)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)
        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:54)
... 

下面是WAR模块的org.eclipse.wst.common.component文件,它有两个EJB依赖项:

<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="my-web-app">       
    <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/ejb-module-1/ejb-module1">
        <dependency-type>uses</dependency-type>
    </dependent-module>
    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/ejb-module-2/ejb-module2">
        <dependency-type>uses</dependency-type>
    </dependent-module>
<property name="java-output-path" value="/my-web-app/target/classes"/>
    <property name="context-root" value="my-web-app"/>
</wb-module>

以下是EAR模块的org.eclipse.wst.common.component文件。 EAR模块具有Web模块依赖性以及许多EJB依赖性。 EAR org.eclipse.wst.common.component文件仅显示两个EJB依赖项,以便于读取。第一个EJB依赖类型是项目根级别的EJB模块,第二个EJB依赖类型是写入lib /文件夹的EJB模块。

<?xml version="1.0" encoding="UTF-8"?>
    <project-modules id="moduleCoreId" project-version="1.5.0"> 
        <wb-module deploy-name="my-ejb-module"> 
            <wb-resource deploy-path="/" source-path="/EarContent"/> 
            <dependent-module archiveName="ejb-module-A.jar" deploy-path="/"   handle="module:/resource/ejbmoduleA/ejbmoduleA"> 
                <dependent-object/> 
                <dependency-type>uses</dependency-type> 
            </dependent-module> 
            <dependent-module archiveName="ejb-module-B-SNAPSHOT.jar" deploy-path="/lib" handle="module:/resource/ejb-module-B-SNAPSHOT/ejb-module-B-SNAPSHOT">
                <dependent-object/> 
                <dependency-type>uses</dependency-type> 
             </dependent-module> 
            <dependent-module archiveName="my-web-app.war" deploy-path="/" handle="module:/resource/my-web-app/my-web-app"> 
                <dependent-object/> 
                <dependency-type>uses</dependency-type>
             </dependent-module> 
     </wb-module>

以下是EAR应用程序的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">   

<modelVersion>4.0.0</modelVersion>
<groupId>com.ear.app</groupId>
<artifactId>my-ear-app</artifactId> 
<packaging>ear</packaging>
<version>1.0.0</version>

</properties>
    <spring.version>3.0.5.RELEASE</spring.version>
    <slf4j.version>1.6.1</slf4j.version>
</properties>

<dependencies>
    <dependency>        
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-W</artifactId>
        <version>1.0.0</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-X</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
    <dependency>        
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-Y</artifactId>
        <version>1.0.0</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-Z</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
    <dependency>
            <groupId>com.web.app</groupId>
            <artifactId>my-web-app</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>war</type>
    </dependency>
</dependencies> 
<build>
    <plugins>       
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.4</version>
            <configuration>
            <generateApplicationXml>false</generateApplicationXml>
                <earSourceDirectory>${basedir}/src/main/application</earSourceDirectory>
                <earSourceIncludes>META-INF/**</earSourceIncludes>
                <defaultJavaBundleDir>APP-INF/lib</defaultJavaBundleDir>
                <version>5</version>
                <modules>                                           <jarModule> 
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <includeInApplicationXml>false</includeInApplicationXml>                    
                    </jarModule>    
                    <jarModule>             
                        <groupId>com.ejb.module</groupId>
                        <artifactId>ejb-module-M</artifactId>                           
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>            
                    <jarModule>             
                        <groupId>com.ejb.module</groupId>
                        <artifactId>ejb-module-N</artifactId>                           
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>            
                    <jarModule>             
                        <groupId>com.ejb.module</groupId>
                        <artifactId>ejb-module-O</artifactId>                           
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>
                    <jarModule>             
                        <groupId>com.ejb.module</groupId>
                        <artifactId>ejb-module-P</artifactId>                               
                        <includeInApplicationXml>false</includeInApplicationXml>
                    </jarModule>
                    <jarModule>             
                        <groupId>org.codehaus.castor</groupId>
                        <artifactId>castor-core</artifactId>                
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>
                    <jarModule>             
                        <groupId>org.codehaus.castor</groupId>
                        <artifactId>castor-xml</artifactId>             
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>
                    <jarModule>             
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>        
                        <includeInApplicationXml>false</includeInApplicationXml>                        
                    </jarModule>            
                </modules>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>  
    <finalName>MY EAR APP</finalName>
</build>

这是web模块的pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.web.app</groupId>
<artifactId>my-web-app</artifactId>
<version>1.0.0-SNAPSHOT</version>   
<packaging>war</packaging>

</properties>
    <spring.version>3.0.5.RELEASE</spring.version>
    <slf4j.version>1.6.1</slf4j.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>${spring.version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-1</artifactId>
        <version>1.3.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.ejb.module</groupId>
        <artifactId>ejb-module-2</artifactId>
        <version>1.3.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
         <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

参考文献:

  1. http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem
  2. Maven WAR dependency 这一个类似于我的问题,我试图用它来解决我的问题但无济于事。它有一个使用来自appfuse的warpath的例子。

1 个答案:

答案 0 :(得分:0)

我认为org.springframework.oxm.Marshaller不是spring-webmvc-3.0.5.RELEASE.jar的一部分。我不熟悉webmvc或它的依赖项,但是spring-oxm-x.y.z.jar可能是它的一个deps,因此需要包含在WEB-INF / lib中?

的问候,
DAGR。