有状态 bean 的远程 EJB 调用第二次失败
Posted
技术标签:
【中文标题】有状态 bean 的远程 EJB 调用第二次失败【英文标题】:Remote EJB invocation fails for second time for stateful bean 【发布时间】:2015-01-23 10:28:45 【问题描述】:我正在编写带有状态 bean 的 EJB 代码。
HelloStatefulBean 打包在 .EAR 文件中,EjbClient 打包在 .WAR 文件中,两个档案都部署在 JBOSS-EAP-6.2 服务器中。 通过 REST-API(/test/execute) 调用 EjbClient.java 文件
我从 EjbClient.java 类调用 EJB。从客户端到 EJB 对第二种方法 (sayHi()) 的调用失败,出现“NoSuchEJBException”,这种行为似乎有点奇怪,因为在相同的上下文中我能够成功调用第一种方法(sayHello())。
请告诉我,我错过了什么?
这是我的代码:
Stateful bean:
@Stateful(name = "helloejb")
@StatefulTimeout(unit = TimeUnit.MINUTES, value = 1)
@TransactionManagement((TransactionManagementType.BEAN))
public class HelloStatefulBean extends CloudProvider implements IHelloBean
public String sayHello(String name)
String str = "Hello " + name;
System.out.println(str);
....
...
..
.
return str;
public void sayHi(String str)
System.out.println("Hi " + str);
....
...
..
.
Remote Interface:
@Remote
public abstract interface IHelloBean
public abstract String sayHello(String paramString1);
public abstract void sayHi(String paramString1);
EJB Client:
@Path("/test")
public class EjbClient
@POST
@Path("/execute")
public Response execute()
String lookupName = "java:global/hello/hello/helloejb!com.test.beans.ifc.IHelloBean";
Context initialContext = new InitialContext();
LOGGER.info("Looking-up the EJB with name: " + lookupName);
IHelloBean objRef = (IHelloBean)initialContext.lookup(lookupName);
LOGGER.info("Lookup successful.");
String msg = objRef.sayHello("XYZ");
objRef.sayHi(msg); // Fails on this method call with NoSuchEJBException
在使用 URL: http://JBOSS-SERVER-IP:8080/api/test/execute
触发 REST-API 时,将调用 REST-API 并且对 EJB 的查找也成功。
此外,“sayHello()”方法也被成功调用,但在从 EjbClient 调用“sayHi()”方法时,应用程序失败并出现异常:
2014-11-22 20:02:26,724 +0530 ERROR [org.jboss.as.ejb3.invocation] (http-localhost/127.0.0.1:8080-1) JBAS014134: EJB Invocation failed on component helloejb for method com.test.beans.ifc.IHelloBean.sayHi(java.lang.String): javax.ejb.NoSuchEJBException: JBAS014300: Could not find EJB with id [12, -41, -13,..., -121]
at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:63) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:249) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBObjectInterceptor.handleInvocation(EJBObjectInterceptor.java:58) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBHomeInterceptor.handleInvocation(EJBHomeInterceptor.java:83) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at com.sun.proxy.$Proxy179.sayHi(Unknown Source)
at com.test.rest.server.EjbClient.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_71]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_71]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339) [jersey-server-1.17.1.jar:1.17.1]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) [jersey-servlet-1.17.1.jar:1.17.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) [jersey-servlet-1.17.1.jar:1.17.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) [jersey-servlet-1.17.1.jar:1.17.1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:389)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
2014-11-22 20:02:26,744 +0530 ERROR [com.test.rest.server.EjbClient.execute] (http-localhost/127.0.0.1:8080-1) JBAS014300: Could not find EJB with id [12, -41, -13,..., -121]: javax.ejb.NoSuchEJBException: JBAS014300: Could not find EJB with id [12, -41, -13,..., -121]
at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:63) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:249) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBObjectInterceptor.handleInvocation(EJBObjectInterceptor.java:58) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBHomeInterceptor.handleInvocation(EJBHomeInterceptor.java:83) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
at com.sun.proxy.$Proxy179.sayHi(Unknown Source)
at com.test.rest.server.EjbClient.execute(Unknown Source) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_71]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_71]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339) [jersey-server-1.11.jar:1.11]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) [jersey-servlet-1.11.jar:1.11]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) [jersey-servlet-1.11.jar:1.11]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708) [jersey-servlet-1.11.jar:1.11]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:389) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.3.1.Final-redhat-1.jar:7.3.1.Final-redhat-1]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
【问题讨论】:
sayHello() 是否抛出异常? @GabrielAramburu :不,sayHello() 不会抛出任何异常。在进一步挖掘中,我发现异常只发生在 sayHi() 上,而不是任何其他方法。无法理解这种奇怪的行为,即调用只失败了一个特定的方法。 尝试去掉@StatefulTimeout注解 @GabrielAramburu:完美!!!这导致了问题,但我没有删除 StatefulTimeout 注释(因为它是我的任务的要求:)),而是在从 bean 调用每个方法之前执行 EJB 查找,因此会话超时不会发生并在每个实例上找到 EJB。以下哪种方案更好: 1. 去掉 StatefulTimeout 注解。 2. 或者,在每个 EJB 方法调用之前进行 EJB 查找。请让我知道。谢谢。 【参考方案1】:如果删除@StatefulTimeout
解决了NoSuchEJBException
异常,并假设您在bean 保持活动的时间段(1 分钟)内调用第一种和第二种方法,则容器可能存在一些问题这个注释。我在谷歌上做了一些研究,但没有发现任何关于这个问题的可能的错误。
关于您的评论,答案是否定的,在调用第二种方法之前进行新的查找不是解决方案,因为您将获得具有不同状态的不同 ejb 引用。它之所以有效,是因为在您的示例中,您没有管理状态,但在实际要求下,您需要保持相同的 ejb 引用。 (这就是有状态的原因)
【讨论】:
以上是关于有状态 bean 的远程 EJB 调用第二次失败的主要内容,如果未能解决你的问题,请参考以下文章
sessionscoped 托管 bean 与有状态 ejb