简体   繁体   English

在Weblogic上使用EJB 3无状态会话bean中的Jersey Client

[英]Using Jersey Client inside EJB 3 stateless session bean on Weblogic

I am using Jersey client inside a EJB 3 stateless session bean. 我在EJB 3无状态会话bean中使用Jersey客户端。 I can deploy the EJB project on Weblogic 11g. 我可以在Weblogic 11g上部署EJB项目。 But when I try to look up the bean from a JSP, I get the following error 但是当我尝试从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

I am new to EJB 3, Jersey and Weblogic. 我是EJB 3,Jersey和Weblogic的新手。 What I understand is that, the stateless session bean is unable to find the Jersey Client class. 我的理解是,无状态会话bean无法找到Jersey Client类。 Can anyone help me with this ? 谁能帮我这个 ?

I have two projects in OEPE (Oracle Enterprise Pack for Eclipse). 我在OEPE(Eclipse Enterprise Pack for Eclipse)中有两个项目。 One is a EJB 3.0 project which contains the stateless session bean. 一个是包含无状态会话bean的EJB 3.0项目。 The other is a dynamic web project which contains the JSP from which I do a JNDI look up to get the stateless session bean. 另一个是动态Web项目,它包含JSP,我从中查找JNDI以获取无状态会话bean。 I am using Jersey Client class inside one of the methods in the stateless session bean. 我在无状态会话bean中的一个方法中使用Jersey Client类。 This method is invoked from the JSP. 从JSP调用此方法。

When I check the deployments on the server using Administrator console, there are two deployments. 当我使用管理员控制台检查服务器上的部署时,有两个部署。 One is an EAR auto generated by OEPE. 一个是OEPE自动生成的EAR。 This EAR corresponds to the dynamic web project. 此EAR对应于动态Web项目。 The other deployment is of type EJB. 另一个部署是EJB类型。

I also tried adding the jersey jar files to the lib folder under the server and restarted the server. 我还尝试将jersey jar文件添加到服务器下的lib文件夹中,然后重新启动服务器。 But still, I get the same error. 但是,我仍然得到同样的错误。

Indeed, the NoClassDefFoundError means that the definition of the Jersey Client class can't be found and loaded at runtime (it was there at compile time though). 实际上, NoClassDefFoundError意味着无法在运行时找到并加载Jersey Client类的定义(虽然它在编译时存在)。 So this is very likely a classpath or packaging issue. 所以这很可能是类路径或打包问题。

Put your Jersey jar in the APP-INF/lib directory of the EAR and try again (if it doesn't work, please update your question with the structure of your EAR). 将您的Jersey jar放入EAR的APP-INF/lib目录中并再试一次(如果它不起作用,请使用您的EAR结构更新您的问题)。

See http://download.oracle.com/docs/cd/E12839_01/web.1111/e13706/libraries.htm#sthref135 and http://download.oracle.com/docs/cd/E12839_01/web.1111/e13706/classloading.htm for more details. 请参阅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了解更多详情。

Update: JARs should go in EarContent/APP-INF/lib that should have been automatically created but I'm not using OEPE so I can't confirm. 更新: JAR应该进入应该自动创建的 EarContent/APP-INF/lib ,但我没有使用OEPE,所以我无法确认。 Note that according to this very recent thread , there might be a bug in the OEPE publisher that is under investigation (at least under Linux). 请注意,根据这个最近的帖子 ,OEPE发布者中可能存在一个正在调查中的错误(至少在Linux下)。

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

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