首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

成功lookup:java.lang.ClassCastException: org.jboss.remoting.InvokerLocator

2014-01-26 
jboss 4.0.4上运行ejb3+jsf的工程。 ejb部分分层为:实体bean,dao和manager,jsf分层为backing bean和展示层。

jboss 4.0.4上运行ejb3+jsf的工程。

ejb部分分层为:实体bean,dao和manager,jsf分层为backing bean和展示层。

在manager层有interface EntityManager,并EntityManagerBean实现他,在EntityManagerBean中通过

@EJB注入dao,manager层则通过storeObject(Object)--> dao.storeObject(Object)完成中间的过度操作

,dao中用函数storeObject(Object){em.persist()}持久化对象。

具体有定义一个stateless的bean,
@Stateless
@Remote({EmployeeManager.class})
@Local({EmployeeManager.class})
public class EmployeeManagerBean implements EmployeeManager {

在jsf的backing bean层,通过lookup查找jndi。
EmployeeManager em = (EmployeeManager)ctx.lookup( "log/EmployeeManagerBean/remote ");可以确定

的是,这个查找已经成功返回了。

但问题出现了,
当我用通过查找并cast的EmployeeManager em来em.storeObject()会出现异常:
Caused by: java.lang.ClassCastException: org.jboss.remoting.InvokerLocator
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke

(InvokeRemoteInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke

(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke

(SecurityClientInterceptor.java:55)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke

(StatelessRemoteProxy.java:102)
at $Proxy311.storeObject(Unknown Source)

花了很多时间去google,大都讲到和class loader相关。但,试的结果都还不行。
在http://www.jboss.org/index.html?

module=bb&op=viewtopic&t=101108&postdays=0&postorder=asc&start=0上,有这样的回答:
You probably have a classloader issue. Looks like the code that does the casting is in a

servlet. You do not, by any chance, have the APLEntityFacade class in both the EJB jar file

and in a jar file (or in the classes directory) in your war file?
还有:
Peter-

Nice catch... that was indeed the problem. I forgot about that whole "class identity = class

+ classloader " thing, and was lazy about how I had configured ant. There are also some

useful wiki pages on this and other potential classloader issues:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingOverview

因为对jboss刚接触不久,对于上面的e文理解不透彻?我要怎样解决呢?

------解决方法--------------------------------------------------------


Object objref = initial.lookup(CodedNames.TX_EJBHOME);

EmployeeManager em =(EmployeeManager) PortableRemoteObject.narrow(objref,
LocalTxHome.class);
------解决方法--------------------------------------------------------
我的经验是,EJB重新部署后,WEB应用也重新部署一下就行了
------解决方法--------------------------------------------------------
我的经验是java.lang.ClassCastException一般是因为装载的classloader不一致,你可以跟踪一下,WEB应用的classloader和业务层的classlaoder通常是不一样的,让一个WEB的对业务层的是可见的。
------解决方法--------------------------------------------------------
试试这个吧,把
deploy\jbossweb-tomcat55.sar\META-INF\jboss-service.xml
的 UseJBossWebLoader 改为true,再重启服务器看看

        

热点排行