3

我在 EJB 3 无状态会话 bean 中使用 Jersey 客户端。我可以在 Weblogic 11g 上部署 EJB 项目。但是当我尝试从 JSP 中查找 bean 时,出现以下错误

 javax.ejb.EJBException: EJB Exception: ; nested exception is: 
 java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client; nested exception is: java.rmi.RemoteException: EJB Exception: ; nested exception is: 
 java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client
 at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:112)
 at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:91)
 at $Proxy66.sayHelloFromServiceBean(Unknown Source)
 at jsp_servlet.__yelpin._jspService(__yelpin.java:92)
 at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
 at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
 at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
 at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
 at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
 at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
 at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
 at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.rmi.RemoteException: EJB Exception: ; nested exception is: 
 java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client
 at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:205)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
 at com.yelpin.ABCD_xruy6c_ABCDRemoteImpl_1032_WLStub.sayHelloFromServiceBean(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:73)
 ... 15 more
Caused by: java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client
 at com.yelpin.ABCD.sayHelloFromServiceBean(ABCD.java:26)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
 at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
 at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:55)
 at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
 at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
 at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy67.sayHelloFromServiceBean(Unknown Source)
 at com.yelpin.ABCD_xruy6c_ABCDRemoteImpl.sayHelloFromServiceBean(ABCD_xruy6c_ABCDRemoteImpl.java:61)
 at com.yelpin.ABCD_xruy6c_ABCDRemoteImpl_WLSkel.invoke(Unknown Source)
 at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
 ... 23 more

我是 EJB 3、Jersey 和 Weblogic 的新手。我的理解是,无状态会话 bean 无法找到 Jersey Client 类。谁能帮我这个 ?

我在 OEPE(Oracle Enterprise Pack for Eclipse)中有两个项目。一个是包含无状态会话 bean 的 EJB 3.0 项目。另一个是包含 JSP 的动态 Web 项目,我从中进行 JNDI 查找以获取无状态会话 bean。我在无状态会话 bean 的一种方法中使用 Jersey Client 类。该方法是从 JSP 调用的。

当我使用管理员控制台检查服务器上的部署时,有两个部署。一种是由 OEPE 生成的 EAR 自动。此 EAR 对应于动态 Web 项目。另一个部署是 EJB 类型。

我还尝试将 jersey jar 文件添加到服务器下的 lib 文件夹中并重新启动服务器。但是,我仍然遇到同样的错误。

4

1 回答 1

1

实际上,这NoClassDefFoundError意味着Client无法在运行时找到和加载 Jersey 类的定义(尽管它在编译时就在那里)。所以这很可能是一个类路径或包装问题。

将您的 Jersey jar 放在APP-INF/libEAR 目录中,然后重试(如果不起作用,请使用您的 EAR 结构更新您的问题)。

请参阅http://download.oracle.com/docs/cd/E12839_01/web.1111/e13706/libraries.htm#sthref135http://download.oracle.com/docs/cd/E12839_01/web.1111/e13706 /classloading.htm了解更多详情。

更新:EarContent/APP-INF/lib应该自动创建的 JAR 应该进入,但我没有使用 OEPE,所以我无法确认。请注意,根据这个最近的线程,正在调查的 OEPE 发布者中可能存在一个错误(至少在 Linux 下)。

于 2010-02-27T16:35:44.970 回答