1 Reply Latest reply on Jan 29, 2010 9:03 PM by Sunil Subrahmanyam

    NoSuchEJBException

    Sunil Subrahmanyam Newbie

      Hello,


      I started getting
      ERROR


      [TxPolicy] javax.ejb.NoSuchEJBException: Could not find stateful bean: 5c4o12-6vcvdi-g4z1l1bg-1-g4z22jkp-ax



      after adding


      <transaction:ejb-transaction />



      in component.xml


      What does this exception mean? How does one fix this? I have searched the forum for this exception and I could not find an explanation.


      Thanks.

        • 1. Re: NoSuchEJBException
          Sunil Subrahmanyam Newbie

          Let me tell some more details about what I am doing,


          I am trying to integrate jasig CAS SSO application with Seam. I want to call identity.login() automatically when the CAS server has authenticated a user. I implemented a web filter (@Filter) to check for CAS user information and then call identity.login() as below.




          @Scope(APPLICATION)
          @Name("casIdentityFilter")
          @Install(precedence = Install.DEPLOYMENT)
          @BypassInterceptors
          @Filter (within = "org.jboss.seam.web.identityFilter")
          public class CasIdentityFilter extends AbstractFilter
          {
               @Logger Log log;
               @Override
               public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
                      log.info("-> in doFilter");
                     if (!(request instanceof HttpServletRequest)) 
                     {
                        throw new ServletException("This filter can only process HttpServletRequest requests");
                     }
          
                     HttpServletRequest httpRequest = (HttpServletRequest) request;
                     HttpServletResponse httpResponse = (HttpServletResponse) response;
          
                     // Force session creation
                     httpRequest.getSession();
                     
                     Context ctx = new SessionContext( new ServletRequestSessionMap(httpRequest) );
          
                     Identity identity = (Identity) ctx.get(Identity.class);
                     
                     if (identity == null)
                     {
                        throw new ServletException("Identity not found - please ensure that the Identity component is created on startup.");
                     }      
                     
                     Credentials credentials = (Credentials) ctx.get(Credentials.class);
                     boolean error = false;
          
                     if (!identity.isLoggedIn()) {
                           try
                           {
                               // Get user info from CAS server
                               Assertion assertion = (Assertion) ctx.get
                                    (AbstractCasFilter.CONST_CAS_ASSERTION);
                               String casUser = assertion.getPrincipal().getName();
                               log.info("CasUser: #0", casUser);
                               credentials.setUsername(casUser);
                                  //
                                log.info("Attempting to login");
                                credentials.setPassword(casUser);
                               authenticate(httpRequest);
                               ctx.set("ssoLoggedIn", true);
                               
                           }         
                           catch (Exception ex)
                           {
                              error = true;
                              log.warn("Error authenticating: " + ex.getMessage());
                              httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Not authorized");    
                           }  
                     }
                     if (!error) {
                          chain.doFilter(httpRequest, httpResponse);
                     }
                    
               }
               
                  private void authenticate(HttpServletRequest request)
                     throws ServletException, IOException
                  {
                     new ContextualHttpServletRequest(request)
                     {
                        @Override
                        public void process() throws ServletException, IOException, LoginException
                        {
                           Identity identity = Identity.instance();
                           identity.login();
                        }
                     }.run();  
                  }
               
          }






          1. This is working okay in terms of picking up the cas user and login on the seam side.

          2. I have an Observer on the login event which sets up addition session-scoped information for the user. This is working fine too.

          3. I am getting the NoSuchEJBException in the chain.doFilter(....) method after everything is done.

          4. There is no exception if I don't use transaction:ejb-transaction in component.xml

          5. There is no Exception if I don't call chain.doFilter(...). I think I can comment out chain.doFilter, if I somehow make this Filter that last one in the chain (But how to do that?)





          Here is the exception I get when I run my SeamTest (Same exception when I use the actual application also)


             [testng] ERROR [org.jboss.seam.exception.Exceptions] handled and logged exception
             [testng] java.lang.IllegalStateException: Could not start transaction
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:598)
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:583)
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:327)
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144)
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
             [testng]      at org.jboss.seam.mock.AbstractSeamTest$Request.restoreViewPhase(AbstractSeamTest.java:721)
             [testng]      at org.jboss.seam.mock.AbstractSeamTest$Request.emulateJsfLifecycle(AbstractSeamTest.java:583)
             [testng]      at org.jboss.seam.mock.AbstractSeamTest$Request.access$100(AbstractSeamTest.java:177)
             [testng]      at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:497)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
             [testng]      at com.logile.elm.eas.security.CasIdentityFilter.doFilter(CasIdentityFilter.java:94)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
             [testng]      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
             [testng]      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
             [testng]      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
             [testng]      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
             [testng]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             [testng]      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
             [testng]      at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
             [testng]      at com.foo.SecurityTest._testLogin(SecurityTest.java:21)
             [testng]      at com.foo.SecurityTest.testLogin(SecurityTest.java:16)
             [testng]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             [testng]      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             [testng]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             [testng]      at java.lang.reflect.Method.invoke(Unknown Source)
             [testng]      at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:607)
             [testng]      at org.testng.internal.Invoker.invokeMethod(Invoker.java:517)
             [testng]      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:669)
             [testng]      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:956)
             [testng]      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
             [testng]      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
             [testng]      at org.testng.TestRunner.runWorkers(TestRunner.java:759)
             [testng]      at org.testng.TestRunner.privateRun(TestRunner.java:592)
             [testng]      at org.testng.TestRunner.run(TestRunner.java:486)
             [testng]      at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
             [testng]      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
             [testng]      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
             [testng]      at org.testng.SuiteRunner.run(SuiteRunner.java:204)
             [testng]      at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877)
             [testng]      at org.testng.TestNG.runSuitesLocally(TestNG.java:842)
             [testng]      at org.testng.TestNG.run(TestNG.java:751)
             [testng]      at org.testng.TestNG.privateMain(TestNG.java:914)
             [testng]      at org.testng.TestNG.main(TestNG.java:887)
             [testng] Caused by: javax.ejb.NoSuchEJBException: Could not find stateful bean: 5c4oa3d-ccrymu-g51dxkuu-1-g51dxvy5-5
             [testng]      at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:394)
             [testng]      at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:379)
             [testng]      at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:63)
             [testng]      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             [testng]      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
             [testng]      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             [testng]      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:166)
             [testng]      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             [testng]      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
             [testng]      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             [testng]      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
             [testng]      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             [testng]      at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:261)
             [testng]      at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
             [testng]      at $Proxy119.afterTransactionBegin(Unknown Source)
             [testng]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             [testng]      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             [testng]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             [testng]      at java.lang.reflect.Method.invoke(Unknown Source)
             [testng]      at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
             [testng]      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
             [testng]      at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
             [testng]      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
             [testng]      at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
             [testng]      at org.javassist.tmp.java.lang.Object_$$_javassist_seam_4.afterTransactionBegin(Object_$$_javassist_seam_4.java)
             [testng]      at org.jboss.seam.transaction.UTTransaction.begin(UTTransaction.java:40)
             [testng]      at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:593)
             [testng]      ... 55 more