将多模块POM项目(EAR)部署到WTP时出现ClassNotFoundException

时间:2013-01-03 14:41:44

标签: eclipse maven ear pom.xml eclipse-wtp

Eclipse版本: Indigo

目标应用程序服务器: Weblogic 10.3.5(11gR1)

我无法在Eclipse中构建和部署多模块POM项目(打包为EAR)到我的WebLogic服务器。

尽管父POM在IDE之外成功构建了EAR文件,但在尝试将UI WAR部署到Application Server时,我收到以下错误:

java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail.
    at oracle.eclipse.tools.weblogic.server.internal.DeploymentProgressListener.watch(DeploymentProgressListener.java:190)
    at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deploy(WlsJ2EEDeploymentHelper.java:486)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1466)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:898)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:686)
    at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:539)
    at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
    at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3027)
    at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:341)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: weblogic.application.ModuleException: Failed to load webapp: 'lerp-ui'
    at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:393)
    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)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
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:305)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
    at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
    at weblogic.servlet.internal.WebAnnotationProcessorImpl.processServlets(WebAnnotationProcessorImpl.java:225)
    at weblogic.servlet.internal.WebAnnotationProcessorImpl.processJ2eeAnnotations(WebAnnotationProcessorImpl.java:209)
    at weblogic.servlet.internal.WebAnnotationProcessorImpl.processAnnotations(WebAnnotationProcessorImpl.java:105)
    at weblogic.servlet.internal.WebAppServletContext.processAnnotations(WebAppServletContext.java:1368)
    at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:449)
    at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:493)
    at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:418)
    at weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:972)
    at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:382)

尽管在Maven POM中有jsf-api依赖关系并且在UI WAR项目的.classpath文件中引用了它:

用于UI WAR项目的POM片段:

<dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.0.3</version>
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.0.3</version>
        </dependency>
用于UI WAR项目的

.classpath:

<classpathentry kind="var" path="M2_REPO/javax/faces/jsf-api/2.0.3/jsf-api-2.0.3.jar"/>
  <classpathentry kind="var" path="M2_REPO/com/sun/faces/jsf-impl/2.0.3/jsf-impl-2.0.3.jar"/>

下面是多模块项目的整个父POM:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>uk.co.7specialgems</groupId>
    <artifactId>multiModulePOMProject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>7specialgems troublesome project</name>


    <modules>
        <module>../../Business/common</module>
        <module>../../Business/svccom</module>
        <module>../../Business/busctl</module>
        <module>../../Client/ui</module>
        <module>../../Business/ear</module>
        <module>../../Business/talend/java/businessrules</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.0</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <properties>

        <project.ui.version>1.0-SNAPSHOT</project.ui.version>
        <project.common.version>1.0-SNAPSHOT</project.common.version>
        <project.svccom.version>1.0-SNAPSHOT</project.svccom.version>
        <project.busctl.version>1.0-SNAPSHOT</project.busctl.version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <webapp.filter>development</webapp.filter>
        <spring.version>3.0.5.RELEASE</spring.version>      
        <eclipselink.version>2.1.3</eclipselink.version>
        <persistence.version>2.0.0</persistence.version>
        <spring.cdi.version>1.0.0</spring.cdi.version>

        <weblogic.adminurl>t3://localhost:7050</weblogic.adminurl>
        <weblogic.user>weblogic</weblogic.user>
        <weblogic.password>welcome1</weblogic.password>
        <weblogic.target>7specialGemsLocalDomain</weblogic.target>
        <weblogic.source>../../Business/ear/target/${parent.artifactId}.${packaging}</weblogic.source>              

    </properties>

    <profiles>
        <profile>
            <id>production</id>
            <properties>
                <webapp.filter>production</webapp.filter>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.2</version>
            </plugin>
        </plugins>
    </build>
</project>

很明显,这是一个类路径问题,但我已经在两天的时间里盯着它看了卷轴,并且已经决定现在是浪费白旗并呼吁求助的时候了!

最终目标是采用我的EAR项目(目前因为每次稍微更改而在命令行上取消部署/重新部署的烦人需求而受阻)并获取它以便我可以在运行的部署中执行热修复在IDE内部。

由于

更新

通过将违规依赖项添加到应用程序服务器的domains\<domain>\lib文件夹,并重新启动应用程序服务器,我现在开始获取ClassNotFoundExceptions其他WAR依赖项。现在很清楚,Eclipse不尊重WAR项目的classpath - 我仍然不明白为什么或如何: - (

2 个答案:

答案 0 :(得分:2)

要将依赖关系打包到lib目录中,请将其添加到EAR打包pom

<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-ear-plugin</artifactId>
         <version>2.5</version>
         <configuration>
            <version>6</version>
            <defaultLibBundleDir>lib</defaultLibBundleDir>
            <modules>
               [Your EJB and Web modules here]
            </modules>
          </configuration>
       </plugin>
   </plugins>
</build>

请注意defaultLibBundleDir标记。

答案 1 :(得分:0)

在Eclipse中使用File > Export构建EAR后,我能够将EAR与我的Maven POM生成的EAR进行比较。

我发现Eclipse没有在部署程序集中包含对Maven Dependencies构建路径项的引用(我发现仅仅将Projects作为依赖项添加是不够的。)

阅读主题,我发现有必要将子WAR和JAR的Maven依赖项添加到各自的WAR和JAR项目中,但目的地为

  

../ LIB

在每个WAR上声明,JAR 指的是父EAR的lib文件夹。

使用此菜单的组合(或者通过依次编辑每个受影响的WAR和JAR的每个相应的.settings / org.eclipse.wst.common.component文件)我能够构建一个版本的EAR与通过我的Maven脚本生成的EAR相匹配。

我希望这有助于某人。