gpt4 book ai didi

eclipse - 将 WAR 文件打包到 EAR 中,以便 WAR 依赖项可用

转载 作者:行者123 更新时间:2023-12-01 23:14:52 24 4
gpt4 key购买 nike

我正在将 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 中的应用程序 fuse war 路径配置,但这不起作用。我还研究了瘦 war 方法。我在帖子末尾添加了相关 Material 的链接。

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

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

发布的 EAR 部署为:

  • META-INF\application.xml
  • META-INF\MANIFEST.MF
  • META-INF\weblogic-application.xml
  • my-web-app.war
  • .beabuild.txt

从 EAR 中发布的 WAR 模块提取如下:

  • WEB-INF\lib\jSTL-1.2.jar
  • WEB-INF\lib\spring-webmvc-3.0.5.RELEASE.jar

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

  • META-INF\MANIFEST.MF
  • WEB-INF\类
  • WEB-INF\jsp
  • WEB-INF\lib(具有所有 WAR 依赖项)
  • WEB-INF\spring
  • 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 的示例。

最佳答案

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

问候,
达格R。

关于eclipse - 将 WAR 文件打包到 EAR 中,以便 WAR 依赖项可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5193009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com