5 Replies Latest reply on Apr 10, 2010 5:58 PM by Carey Foushee

    Attempted to invoke a Seam component outside an initialized application

    Tony Sourpuss Newbie

      Hi all,


      I'm getting following error after invoking webservice method from external application (SoapUI).



      09:08:57,228 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside an initialized application
              at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:113)
              at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:619)
              at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:131)
              at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
              at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
              at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)
              at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
              at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)




      My webservice class:



      @Stateless
      @WebService(name = "StatelessService1", serviceName="StatelessService1", targetNamespace = "http://abc.at/demo/xapi/jaxws/ws")
      @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
      @Name("statelessService1Impl")
      public class StatelessService1Impl implements StatelessService1{
             
           public User doSomething(String username) {
               ...
           }
      }



      component.xml:



      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core"
          xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:drools="http://jboss.com/products/seam/drools"
          xmlns:bpm="http://jboss.com/products/seam/bpm" xmlns:security="http://jboss.com/products/seam/security"
          xmlns:mail="http://jboss.com/products/seam/mail" xmlns:transaction="http://jboss.com/products/seam/transaction"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
                       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd">
         
          <core:init jndi-pattern="webservice-persistence/#{ejbName}/local" debug="true" />
          
          <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"/>
          
      
      </components>



      I also placed a seam.properties in root of application.


      That .jar file is placed into an .ear file. The application.xml in the .ear-file includes the .jar file as ejb-module as well as the jboss-seam-2.1.0.SP1.jar file.


      The application is deployed into JBoss 4.2.2. The jboss-app.xml contains:



      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
           "-//JBoss//DTD J2EE Application 1.4//EN"
           "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
        <loader-repository>seam.jboss.org:loader=webservice-persistence</loader-repository>
      </jboss-app>




      The error message says, that i tried to invoke the seam component from outside an initialized application. That's right. I call my webservice from soapUI, but that should be ok. Maybe seam is not initialized in the right way.


      Thanks in advance, i will really appreciate your help!


      regards, tony





        • 1. Re: Attempted to invoke a Seam component outside an initialized application
          Tony Sourpuss Newbie

          After a short debugging session, I know the purpose of this exception.


          I have to say, that i came over from springframework. So i expected an initialized seam application before invoking the webservice. But Seam does not initialize non-webapps (webservices just packaged in ear file). You need to create your ServletContext by yourself - to initialize seam correctly.


          Something like:



          MockServletContext servletContext = new MockServletContext();
                                
                     ServletLifecycle.beginApplication(servletContext);
                     
                     FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
                     new Initialization(servletContext).create().init();
                     ((Init) servletContext.getAttribute(Seam.getComponentName(Init.class))).setDebug(false);
                     



          (copied from AbstractSeamTest.java)
                    
          thanks tony to solve this issue so fast ;-)


          best regards


          tony


          • 2. Re: Attempted to invoke a Seam component outside an initialized application
            Tony Sourpuss Newbie

            After a short debugging session, I know the purpose of this exception.


            I have to say, that i came over from springframework. So i expected an initialized seam application before invoking the webservice. But Seam does not initialize non-webapps (webservices just packaged in ear file). You need to create your ServletContext by yourself - to initialize seam correctly.


            Something like:



            MockServletContext servletContext = new MockServletContext();
                                  
                       ServletLifecycle.beginApplication(servletContext);
                       
                       FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
                       new Initialization(servletContext).create().init();
                       ((Init) servletContext.getAttribute(Seam.getComponentName(Init.class))).setDebug(false);
                       



            (copied from AbstractSeamTest.java)
                      
            thanks tony for solving this issue so fast ;-)


            best regards


            tony

            • 3. Re: Attempted to invoke a Seam component outside an initialized application
              Tony Sourpuss Newbie

              RTFM - use standard-jaxws-endpoint-config.xml to initialize seam application for webservices :-)

              • 4. Re: Attempted to invoke a Seam component outside an initialized application
                philip andrew Newbie

                Hi,


                I am getting this problem even though I added standard-jaxws-endpoint-config.xml


                Why? Please help.


                19:42:27,731 ERROR [HandlerChainExecutor] Exception during handler processing
                java.lang.IllegalStateException: Attempted to invoke a Seam component outside an
                 initialized application
                        at org.jboss.seam.contexts.Lifecycle.getApplication(Lifecycle.java:36)
                        at org.jboss.seam.contexts.ServletLifecycle.beginRequest(ServletLifecycl
                e.java:52)
                        at org.jboss.seam.webservice.SOAPRequestHandler.handleInbound(SOAPReques
                tHandler.java:71)
                        at org.jboss.seam.webservice.SOAPRequestHandler.handleMessage(SOAPReques
                tHandler.java:56)
                        at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(Ha
                ndlerChainExecutor.java:305)
                        at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(Ha
                ndlerChainExecutor.java:142)
                        at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callRequestHandl
                erChain(HandlerDelegateJAXWS.java:97)
                        at org.jboss.ws.core.server.ServiceEndpointInvoker.callRequestHandlerCha
                in(ServiceEndpointInvoker.java:125)
                        at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
                tInvoker.java:201)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
                dlerImpl.java:474)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
                lerImpl.java:295)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
                .java:205)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
                HandlerImpl.java:131)
                        at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(Abstract
                EndpointServlet.java:85)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                icationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                ilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
                lter.java:96)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                icationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                ilterChain.java:206)
                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
                alve.java:235)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
                alve.java:191)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
                yAssociationValve.java:190)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
                e.java:92)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.proce
                ss(SecurityContextEstablishmentValve.java:126)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invok
                e(SecurityContextEstablishmentValve.java:70)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
                ava:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
                ava:102)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
                onnectionValve.java:158)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
                ve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
                a:330)
                        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso
                r.java:905)
                        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr
                ocess(Http11AprProtocol.java:592)
                        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:20
                36)
                        at java.lang.Thread.run(Thread.java:619)
                19:42:27,848 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
                java.lang.IllegalStateException: Attempted to invoke a Seam component outside an
                 initialized application
                        at org.jboss.seam.contexts.Lifecycle.getApplication(Lifecycle.java:36)
                        at org.jboss.seam.contexts.ServletLifecycle.beginRequest(ServletLifecycl
                e.java:52)
                        at org.jboss.seam.webservice.SOAPRequestHandler.handleInbound(SOAPReques
                tHandler.java:71)
                        at org.jboss.seam.webservice.SOAPRequestHandler.handleMessage(SOAPReques
                tHandler.java:56)
                        at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(Ha
                ndlerChainExecutor.java:305)
                        at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(Ha
                ndlerChainExecutor.java:142)
                        at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callRequestHandl
                erChain(HandlerDelegateJAXWS.java:97)
                        at org.jboss.ws.core.server.ServiceEndpointInvoker.callRequestHandlerCha
                in(ServiceEndpointInvoker.java:125)
                        at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
                tInvoker.java:201)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
                dlerImpl.java:474)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
                lerImpl.java:295)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
                .java:205)
                        at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
                HandlerImpl.java:131)
                        at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(Abstract
                EndpointServlet.java:85)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                icationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                ilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
                lter.java:96)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
                icationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
                ilterChain.java:206)
                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
                alve.java:235)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
                alve.java:191)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
                yAssociationValve.java:190)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
                e.java:92)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.proce
                ss(SecurityContextEstablishmentValve.java:126)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invok
                e(SecurityContextEstablishmentValve.java:70)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
                ava:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
                ava:102)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
                onnectionValve.java:158)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
                ve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
                a:330)
                        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso
                r.java:905)
                        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr
                ocess(Http11AprProtocol.java:592)
                        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:20
                36)
                        at java.lang.Thread.run(Thread.java:619)
                

                • 5. Re: Attempted to invoke a Seam component outside an initialized application
                  Carey Foushee Newbie

                  I got the same problem and fixed it by removing the @WebContext annotation, which sucks because I haven't found another way of modifying the deploy path.