2012-01-05 183 views
1

我试图将EAR文件部署到应用程序服务器。该项目使用NetBeans 7中的Maven 3构建。部署ear文件时出现问题

当我尝试部署Glassfish和Websphere CE时,告诉我某些类即使它们打包在EAR文件中也无法找到。应用程序服务器可以查看包中的其他类,但不是全部。

问题是什么?我一直在努力解决这一整天。我查看了Maven POM文件,并且一直在阅读有关部署描述符的内容,但我似乎并未在进行中。

我得到的错误是 SEVERE:Class [className] not found。加载时出错[类名]

下面是该项目的主要POM文件:

<modelVersion>4.0.0</modelVersion> 
<parent> 
    <artifactId>SeaMarNetting</artifactId> 
    <groupId>com.manageinc.seamar</groupId> 
    <version>1.0RC1</version> 
</parent> 
<groupId>${project.parent.groupId}</groupId> 
<artifactId>SeaMarNetting-ear</artifactId> 
<packaging>ear</packaging> 
<version>${project.parent.version}</version> 
<name>SeaMarNetting-ear JEE5 Assembly</name> 
<url>http://maven.apache.org</url> 
<dependencies> 
    <dependency> 
     <groupId>${project.parent.groupId}</groupId> 
     <artifactId>SeaMarNetting-project-deps</artifactId> 
     <version>${project.parent.version}</version> 
     <type>pom</type> 
    </dependency> 
    <dependency> 
     <groupId>${project.parent.groupId}</groupId> 
     <artifactId>SeaMarNetting-ejb</artifactId> 
     <version>${project.parent.version}</version> 
     <type>ejb</type> 
    </dependency> 
    <dependency> 
     <groupId>${project.parent.groupId}</groupId> 
     <artifactId>SeaMarNetting-jpa</artifactId> 
     <version>${project.parent.version}</version>    
    </dependency> 
    <dependency> 
     <groupId>${project.parent.groupId}</groupId> 
     <artifactId>SeaMarNetting-web</artifactId> 
     <version>${project.parent.version}</version> 
     <type>war</type> 
    </dependency> 
    <dependency> 
     <groupId>com.manageinc.seamar</groupId> 
     <artifactId>SeaMarNetting-web</artifactId> 
     <version>1.0RC1</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.0.2</version> 
      <configuration> 
       <source>${source.version}</source> 
       <target>${compile.version}</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ear-plugin</artifactId> 
      <version>2.4.2</version> 
      <configuration> 
       <version>5</version> 
       <displayName>SeaMarNetting</displayName> 
       <modules>       
        <jarModule> 
         <groupId>${project.parent.groupId}</groupId> 
         <artifactId>SeaMarNetting-jpa</artifactId> 
        </jarModule> 
        <ejbModule> 
         <groupId>${project.parent.groupId}</groupId> 
         <artifactId>SeaMarNetting-ejb</artifactId> 
        </ejbModule> 
        <webModule> 
         <groupId>${project.parent.groupId}</groupId> 
         <artifactId>SeaMarNetting-web</artifactId> 
         <contextRoot>/nets</contextRoot> 
        </webModule> 
       </modules> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

我试图改变范围的建议,但我得到了同样的错误消息。我刚开始使用Maven,我确信这是简单的,我不知道。

谢谢。

回答

0

不能看到你的POM文件,我最好的猜测是你没有正确定义你的依赖关系。 http://maven.apache.org/pom.html#The_Basics显示:在Apache的POM参考

<dependencies> 
<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.0</version> 
    <type>jar</type> 
    <scope>test</scope> 
    <optional>true</optional> 
</dependency> 
... 

我认为你需要把重点放在“范围”属性,在这里你可以将其列为无论是“提供”或“系统”。这样,maven不会在其存储库中查找您的罐子。以下是可能的瓦特/描述:

范围: 该元素指的是在手头的任务的类路径(编译和运行时,测试,>等),以及如何限制依赖性的传递。有五个范围可用:编译,提供,运行时,测试,系统。

编译 - 这是默认范围,如果没有指定,则使用。编译依赖关系在所有类路径中都可用。此外,这些依赖关系会传播到依赖项目。

提供 - 这非常类似于编译,但表示您希望JDK或容器在运行时提供它。它仅在编译和测试类路径中可用,并且不可传递。

运行时 - 此范围指示编译时不需要依赖项,但是要执行该依赖项。它在运行时和测试类路径中,但不在编译类路径中。

测试 - 此范围指示正常使用>应用程序时不需要依赖关系,并且仅适用于测试编译和执行阶段。

系统 - 该范围与提供的范围相似,只是必须明确提供包含它的JAR。该工件始终可用,并且不会在>存储库中查找。

记住为每个与存储库的groupId对应的依赖项包含groupId也很重要。我发现即使我的文件保存在本地,他们仍然需要一个groupId - 即使范围是'提供'。

+0

感谢您回复TedPrz。问题是持久层的瓶子没有被glassfish看到。耳朵由ejb,web和jpa中的每个jar组成。我可以在Websphere Express上部署和运行应用程序,但不能在glassfish和Websphere CE上运行。有问题的罐子在EAR里面。 – user1054606 2012-01-09 22:53:46

+0

你确定耳朵包装正确吗?有什么办法可以发布部分.xml文件吗? – Ted 2012-01-10 12:13:48

+0

不,我不确定EAR是否正确打包。我开始使用Maven构建的现有项目。这是我第一次使用Maven。该项目在NetBeans中正常生成并在生产服务器上运行。我试图建立一个开发服务器。 – user1054606 2012-01-10 16:39:09