简体   繁体   English

将耳朵部署到Glassfish时出错

[英]Error deploying ear to Glassfish

We have a EAR with 3 EJB modules. 我们有一个包含3个EJB模块的EAR。 I am trying to deploy to glassfish but am hitting an error I can't explain or work out how best to identify. 我正在尝试部署到glassfish,但我遇到了一个错误,我无法解释或找出最好的识别方法。

[#|2010-08-03T14:39:15.570+0100|INFO|glassfish3.0.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=28;_ThreadName=Thread-1;|[AutoDeploy] Selecting file /export/home/myapp/apps/domains/myapp/autodeploy/App-ear.ear for autodeployment.|#]

[#|2010-08-03T14:39:18.654+0100|WARNING|glassfish3.0.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=28;_ThreadName=Thread-1;|Error in annotation processing: java.lang.NoClassDefFoundError: com/company/app/controller/IMessagingProcessor|#]

[#|2010-08-03T14:39:20.470+0100|SEVERE|glassfish3.0.1|global|_ThreadID=28;_ThreadName=Thread-1;|Class [ Lcom/company/app/jms/IJmsSessionFactory; ] not found. Error while loading [ class com.company.app.eventprocessor.provider.EventProvider ]|#]

I have checked the classes mentioned in the ClassNotFoundException and they are definetly in a Jar in the ear and I have no compilation issues in eclipse/maven. 我已经检查了ClassNotFoundException中提到的类,它们肯定是在耳中的Jar中,我在eclipse / maven中没有编译问题。

D:\Repository\App\AppEA\App-ear\target\App-ear.ear\CoreJms-1.0-SNAPSHOT.jar\com\company\app\controller\IMessagingProcessor.class

D:\Repository\App\AppEA\App-ear\target\App-ear.ear\EventProcessor-ejb-1.0-SNAPSHOT.jar\com\company\app\eventprocessor\provider\EventProvider.class

Any pointers are much appreciated. 任何指针都非常感谢。

James 詹姆士

Actually, you're not getting a ClassNotFoundException , you're getting a NoClassDefFoundError and I suspect some dependencies to be missing, as suggested by: 实际上,你没有得到ClassNotFoundException ,你得到一个NoClassDefFoundError ,我怀疑一些依赖项缺失,如下所示:

Class [ Lcom/company/app/jms/IJmsSessionFactory; ] not found. Error while loading [ class com.company.app.eventprocessor.provider.EventProvider 

Where is that com.company.app.jms.IJmsSessionFactory ? com.company.app.jms.IJmsSessionFactory在哪里?


I have now cut the ear down to a single ejb module and am getting the NoClassDef for Lorg/apache/log4j/Logger however the log4j jar is also in the ear. 我现在已将耳朵切换到单个ejb模块,并获得Lorg / apache / log4j / Logger的NoClassDef但是log4j jar也在耳中。 It feels like I must be missing something fundamental here? 感觉我必须遗漏一些基本的东西吗?

Where is the log4j.jar exactly? log4j.jar到底在哪里? In /lib ? /lib Can you actually show the structure of your EAR? 你能真正展示你的EAR的结构吗? And please also show the MANIFEST.MF of your EJB-JAR. 并且还请显示EJB-JAR的MANIFEST.MF

Just in case, here is a relevant quote from Packaging EJB 3 Applications : 以防万一,这是封装EJB 3应用程序的相关引用:

Packaging EJB-JAR 打包EJB-JAR

... ...

The EJB-JAR file must include the interfaces and bean classes. EJB-JAR文件必须包含接口和bean类。 It may also include any helper classes. 它还可能包括任何帮助程序类。 Optionally the helper classes may be packaged in a separate JAR file in the EAR file. 可选地,辅助类可以打包在EAR文件中的单独JAR文件中。 You have two options: 您有两种选择:

  • The JAR containing helper classes may be packaged in the lib directory of the EAR file. 包含帮助程序类的JAR可以打包在EAR文件的lib目录中。 Using this approach, the packaged classes will be automatically visible to all modules in the EAR module. 使用此方法,EAR模块中的所有模块将自动显示打包的类。
  • If you want to limit the visibility to only a specific EJB-JAR or WAR module, you can create an entry in the Manifest.mf file of the module that contains a Class-Path attribute to the JAR file. 如果要将可见性限制为仅限特定的EJB-JAR或WAR模块,则可以在模块的Manifest.mf文件中创建一个条目,该文件包含JAR文件的Class-Path属性。

Now that you know the structure of EJB-JAR and how to package it, let's look at the elements of ejb-jar.xml . 既然您已经了解了EJB-JAR的结构以及如何打包它,那么让我们看一下ejb-jar.xml的元素。


Based on your comments I think I am understadning my issue. 根据您的意见,我认为我正在解决我的问题。 It would appear I am not packaging the ear correctly, I don't think the maven dependencies are referenced correctly. 看来我没有正确包装耳朵,我认为maven依赖关系没有被正确引用。 If I simply build my ejb jar it does not include any of the dependant jars. 如果我只是构建我的ejb jar,它不包括任何依赖的jar。 Should I be specifying something in the pom to include the jars ejb-jar? 我应该在pom中指定包含罐子ejb-jar的东西吗? I have the build plugin <artifactId>maven-ejb-plugin</artifactId> and packaging <packaging>ejb</packaging> set. 我有构建插件<artifactId>maven-ejb-plugin</artifactId>和打包<packaging>ejb</packaging>集。

Bundling dependencies into an EJB-JAR is not supported (see MEJB-3 ) mostly because jar-within-jar is not part of the JAR specification (and might not be supported by all EJB container) and does not comply with Sun's advice regarding J2EE packaging in general. 不支持将依赖项捆绑到EJB-JAR中(参见MEJB-3 ),主要是因为jar-within-jar不是JAR规范的一部分(并且可能不受所有EJB容器支持),并且不符合Sun关于J2EE的建议包装一般。

So while you may ignore this rule (see this trick or this one ), the standard way would be to package the EJB-JAR and all the JARs it depends on in an EAR. 因此,尽管你可以忽略此规则(见这一招还是这一个 ),该标准的方式是打包EJB-JAR和所有JAR它在EAR依赖。 This is my recommendation and I think that this post might help: Because I always forget how to use maven-ear-plugin . 这是我的建议,我认为这篇文章可能有所帮助: 因为我总是忘记如何使用maven-ear-plugin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM