我的 .ear 文件有一些问题。文件结构为:
app.ear
|-xxx.jar
-yyy.jar
-zzz.jar
-ektorp.jar
-app-ejb.jar
-app-web.war
|-WEB-INF
|-lib
|-xxx.jar
|-yyy.jar
|-zzz.jar
|-ektorp.jar
当我尝试部署我的应用程序时,我得到 ClassNotFoundException,其中的类位于 ektorp.jar 中。该文件由 ejb 模块使用。
我也不知道为什么这些 jar 要加倍? in ear 和 in war 模块是相同的 .jar 文件。
Ear 由 maven2 构建。
最佳答案
When I try to deploy my application, I get ClassNotFoundException, with class which is in ektorp.jar. This file is used by ejb module.
EJB-JAR 是否在 list 的 Class-Path:
条目中引用了 ektorp.jar
(有关这方面的更多背景信息,请参阅 Packaging EJB 3 Applications)?常见问题解答说明 how you can configure the plugin to generate a Class-Path:
entry in the manifest :
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.2.1</version>
...
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
...
</plugin>
</plugins>
</build>
...
</project>
以防万一,您是否知道可以使用 Java EE 6 将 EJB 打包到 .war 中(区别在于使用 .war 打包时所有类都使用相同的类加载器加载)?如果没有很强的模块化需求,.war打包更简单。
关于java - 服务器在 .ear 中找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3173152/