EJB的Classloader问题 [英] Classloader problem with EJB

查看:162
本文介绍了EJB的Classloader问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含持久性库(JPA 1.2),EJB 3和Web表示层(JSF)的项目。我使用Eclipse开发应用程序,应用程序通过eclipse插件在Websphere Application Server社区版(Geronimo 2.1.4)上发布(但是如果我手动发布也会发生同样的情况)。当发布到服务器时,我会收到以下错误:

  java.lang.NoClassDefFoundError:无法完全加载类:manager.administration。 vehicle.VehicleTypeAdminBean 
由于:manager / vehicles / VehicleType
在classLoader中:
org.apache.geronimo.kernel.classloader.TemporaryClassLoader@18878c7
在org.apache.xbean。 finder.ClassFinder(ClassFinder.java:177)
在org.apache.xbean.finder.ClassFinder(ClassFinder.java:146)...

在web.xml中,我参考了EJB:

 < ejb-local -ref> 
< ejb-ref-name> ejb / VehicleTypeAdmin< / ejb-ref-name>
< ejb-ref-type>会话< / ejb-ref-type>
< local> manager.administration.vehicles.VehicleTypeAdmin< / local>
< ejb-link> VehicleTypeAdminBean< / ejb-link>
< / ejb-local-ref>

EJB项目具有对持久性项目的引用,Web项目对这两个项目都有引用。我没有得到任何编译错误,所以我想类和引用是正确的。



我不知道是否是应用服务器问题,但是我运行了以前的应用程序在同一个服务器上使用相同的配置参数。



有人有一个线索可能是什么问题?

解决方案

看起来几乎像在尝试创建/加载类manager.administration.vehicles.VehicleTypeAdminBean时找不到类manager.vehicles.VehicleType。



我以前遇到过类似的问题。当类加载器尝试加载类时,它会查看import语句(和其他类使用声明),然后尝试加载这些类等等,直到它到达链的底部(即java .lang.Object)。如果它不能在链中找到一个类(在你的情况下,它看起来不能加载VehicleType),那么它将声明它不能加载链在顶部的类(在你的情况下是VehicleTypeAdminBean)。



VehicleType类是否在不同的jar中?如果您有一个Web模块和EJB模块,那么您将jar包含在相应位置的VehicleType类。有时使用Web项目,您必须将jar放在WebContent / WEB-INF / lib文件夹中,否则它们将无法找到它们。



这两个项目是否单独部署(即两只耳朵还是一只耳朵和一只战争?)或者它们在一起(即一只耳朵和一个内部的战争?)。我假设第二个给你宣布你的EJB本地?



你依赖的jar也必须在项目中的MANIFEST.MF文件中声明使用它。



由于我不知道您的项目结构,我有一种猜测。显示会有所帮助。但是我仍然检查一下VehicleType所在的EJB类。你可能会发现它不是你认为是包装或运行时的地方。


I'm working on a project which includes persistence library (JPA 1.2), EJB 3 and Web presentation layer (JSF). I develop application using Eclipse and application is published on Websphere Application Server Community Edition (Geronimo 2.1.4) through eclipse plugin (but the same thing happens if I publish manually). When publishing to server I get the following error:

java.lang.NoClassDefFoundError: Could not fully load class: manager.administration.vehicles.VehicleTypeAdminBean
 due to:manager/vehicles/VehicleType
 in classLoader: 
org.apache.geronimo.kernel.classloader.TemporaryClassLoader@18878c7
    at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:177)
    at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:146)...

In web.xml I have reference to EJB:

<ejb-local-ref>
    <ejb-ref-name>ejb/VehicleTypeAdmin</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>manager.administration.vehicles.VehicleTypeAdmin</local>
    <ejb-link>VehicleTypeAdminBean</ejb-link>
</ejb-local-ref>

EJB project has a reference to persistence project, and Web project has references to both projects. I don't get any compilation errors, so I suppose classes and references are correct.

I don't know if it is app server problem, but I ran previously application on the same server using same configuration parameters.

Does anybody have a clue what might be the problem?

解决方案

Looks almost like it couldn't find the class manager.vehicles.VehicleType when it was attempting to create/load the class manager.administration.vehicles.VehicleTypeAdminBean.

I've encountered similar problems before. When the class loader attempts to load the class it looks at the import statements (and other class usage declarations) and then attempts to load those classes and so on until it reaches the bottom of the chain (ie java.lang.Object). If it cannot find one class along the chain (in your case it looks like it cannot load VehicleType) then it will state that it cannot load the class at the top of the chain (in your case VehicleTypeAdminBean).

Is the VehicleType class in a different jar? If you have a web module and and EJB module do you have the jar containing the VehicleType class in the appropriate place(s). Sometimes with web projects you have to put the jars in the WebContent/WEB-INF/lib folder or it won't find them.

Are both of these projects deployed separately (ie. two ears? or one ear and one war?) or are they together (ie, one ear with jars and a war inside?). I'm assuming the second given you declared your EJB local?

The jars that you are dependent on also have to be declared in your MANIFEST.MF files in the projects that use it.

I'm kind of running on guesses since I do not know your project structure. Showing that would help quite a bit. But I'd still check on where VehicleType is located with regards to your EJB class. You might find it isn't where you think it is come packaging or runtime.

这篇关于EJB的Classloader问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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