2014-11-25 126 views
1

我寫一個EJB代碼,有狀態bean。遠程EJB調用失敗的第二次狀態bean

HelloStatefulBean打包在.EAR文件中,EjbClient打包在.WAR文件中,兩個壓縮文件都部署在JBOSS-EAP-6.2服務器中。 EjbClient.java文件通過REST API調用(/ test/execute)

我從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燒製的REST API:http://{JBOSS-SERVER-IP}:8080/api/test/execute,在REST的API被調用和EJB的查找也成功。 此外,「的sayHello()」方法也被成功調用,但調用「的sayHi()」從EjbClient方法,應用程序失敗,出現異常:

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] 
+0

沒有的sayHello()拋出任何異常? – 2014-11-25 12:37:01

+0

@ GabrielAramburu:不,sayHello()不會拋出任何異常。在進一步的挖掘中,我發現只有sayHi()發生異常,而不是其他任何方法。無法理解這種奇怪的行爲,即調用只會失敗一個特定的方法。 – user1944878 2014-11-26 07:09:36

+1

嘗試刪除@StatefulTimeout註釋 – 2014-11-26 11:12:29

回答

1

如果卸下@StatefulTimeout解決NoSuchEJBException例外,並且假定你正在調用第一個和第二個方法在bean保持活着的時間段(1分鐘),可能是Container對這個註解有一些問題。我在谷歌做了一些研究,但是我沒有發現任何關於這個問題的可能的錯誤。

關於你的評論,答案是否定的,做一個新的查找調用之前的第二種方法是不是一個解決方案,因爲你會得到一個不同的EJB引用,以不同的狀態。它的作用是因爲在你的例子中你不是在管理狀態,但是在真正的需求下你需要保持相同的ejb參考。 (這是有狀態的原因)