将耳朵部署到Glassfish时出错 [英] Error deploying ear to Glassfish

查看:142
本文介绍了将耳朵部署到Glassfish时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含3个EJB模块的EAR。我试图部署到glassfish,但我遇到了一个错误,我无法解释或找出最佳方法。

  [ #| 2010-08-03T14:39:15.570 + 0100 | INFO | glassfish3.0.1 | javax.enterprise.system.tools.deployment.org.glassfish.deployment.common | _ThreadID = 28; _ThreadName =线程1; | [ AutoDeploy]为自动部署选择文件/export/home/myapp/apps/domains/myapp/autodeploy/App-ear.ear。|#] 

[#| 2010-08-03T14:39:18.654 +0100 |警告| glassfish3.0.1 | javax.enterprise.system.tools.deployment.org.glassfish.deployment.common | _ThreadID = 28; _ThreadName = Thread-1; |注释处理错误: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; ] 未找到。加载时出错[class com.company.app.eventprocessor.provider.EventProvider] |#]

I已经检查了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

任何指针非常感谢。



James

解决方案

其实,没有得到一个 ClassNotFoundException ,你得到了一个 NoClassDefFoundError ,我暂停如下所示:

  Class [Lcom / company / app / jms / IJmsSessionFactory; ] 未找到。加载时出错[class com.company.app.eventprocessor.provider.EventProvider 

Where is that com.company.app.jms.IJmsSessionFactory







现在我已经将耳朵切割成单个ejb模块,并且获得了用于Lorg / apache / log4j / Logger的NoClassDef,但是log4j jar也在耳中。感觉就像我一定在这里错过了一些基本的东西?

log4j.jar 究竟在哪里?在 / lib 中?你真的可以展示你的EAR的结构吗?并且还请显示您的EJB-JAR的 MANIFEST.MF

为防万一,以下是来自
$ b


打包EJB -JAR



...



EJB-JAR文件必须包含
接口和bean类。它可能
也包括任何助手类。
可选地,助手类可以是在
EAR文件中的单独JAR文件中打包的
。您有两种选择:


  • 包含帮助程序类的JAR可以打包在EAR文件的lib目录
    中。使用这种方法,打包类将是
    ,EAR模块中所有模块
    自动可见。

  • 如果要将可见性限制为只有特定的EJB-JAR或WAR
    模块,您可以在模块的
    Manifest.mf文件中创建一个条目,
    包含一个到
    JAR的Class-Path属性file。



现在您已经知道
EJB-JAR的结构以及如何打包它,让我们来
看看 ejb-jar.xml 的元素。








根据您的意见,我认为我正在考虑我的问题。它会出现我没有正确包装耳朵,我不认为maven依赖关系被正确引用。如果我简单地构建我的ejb jar,它不包含任何依赖jar。我应该在pom中指定一些东西来包含jar ejb-jar吗?我有构建插件< artifactId> maven-ejb-plugin< / artifactId> 和打包< packaging> ejb< / packaging> code> set。


不支持将依赖关系捆绑到EJB-JAR中(请参阅 JAR规范(并且可能不被所有EJB容器支持)并且不符合 Sun关于J2EE打包的建议一般。



因此,尽管您可能会忽略此规则(请参阅这个招数 this one ),the标准的方法是将EJB-JAR和它依赖的所有JAR包装在EAR中。这是我的建议,我认为这篇文章可能有帮助:因为我总是忘记如何使用maven-ear-plugin


We have a EAR with 3 EJB modules. I am trying to deploy to glassfish but am hitting an error I can't explain or work out how best to identify.

[#|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.

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:

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?


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. It feels like I must be missing something fundamental here?

Where is the log4j.jar exactly? In /lib? Can you actually show the structure of your EAR? And please also show the MANIFEST.MF of your EJB-JAR.

Just in case, here is a relevant quote from Packaging EJB 3 Applications:

Packaging EJB-JAR

...

The EJB-JAR file must include the interfaces and bean classes. It may also include any helper classes. Optionally the helper classes may be packaged in a separate JAR file in the EAR file. You have two options:

  • The JAR containing helper classes may be packaged in the lib directory of the EAR file. Using this approach, the packaged classes will be automatically visible to all modules in the EAR module.
  • 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.

Now that you know the structure of EJB-JAR and how to package it, let's look at the elements of 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. If I simply build my ejb jar it does not include any of the dependant jars. Should I be specifying something in the pom to include the jars ejb-jar? I have the build plugin <artifactId>maven-ejb-plugin</artifactId> and packaging <packaging>ejb</packaging> set.

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.

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. This is my recommendation and I think that this post might help: Because I always forget how to use maven-ear-plugin.

这篇关于将耳朵部署到Glassfish时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆