6 Replies Latest reply on Dec 1, 2010 6:03 PM by Andre Hopkins

    Seam 2.0.1 & JBossWS & WAR deployment

    Karel Jelinek Newbie

      The Seam reference explains how to configure and package a Seam EAR to support JBossWS web services. That worked great.


      However, I have not been able to get JBossWS to work with a Seam WAR deployment.


      I have Seam 2.0.1, JBoss AS 4.2.2 GA and JBossWS 2.0.3 GA


      I created this service interface:


      
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebResult;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      
      @WebService(name = "TestEndpoint", serviceName = "HcpService")
      @SOAPBinding(style = Style.RPC)
      public interface TestEndpoint
      {
         @WebMethod
         @WebResult(name = "result")
         public String echo(@WebParam(name = "message") String msg);
      }





      and service implementation:



      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebResult;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      
      import org.jboss.seam.Component;
      import org.jboss.seam.security.Identity;
      
      @WebService(name = "TestEndpoint", serviceName = "HcpService")
      @SOAPBinding(style = Style.RPC)
      public class TestEndpointBean
      {
      
         @WebMethod
         @WebResult(name = "result")
         public String echo(@WebParam(name = "message") String msg)
         {
             return "Echo " + msg;
         }
      }





      I don´t know if my procedure was fine, but to make the webservice working I had to add servlet to web.xml



        <servlet>
          <servlet-name>TestEndpoint</servlet-name>
          <servlet-class>hcp.TestEndpointBean</servlet-class>
        </servlet>
      
        <servlet-mapping>
          <servlet-name>TestEndpoint</servlet-name>
          <url-pattern>/test</url-pattern>
        </servlet-mapping>




      Only with this servlet is after deployment service endpoint registered and visible in browser (http://localhost:8080/jbossws/services)


      At first I had setProperty must be overridden by all subclasses of SOAPMessage exception, so I  switched to java 1.5 to get rid of it.


      After this, my webservice is active and I can successfully send requests and receive responses.


      But now I have another problem when I want to use some seam component. I have read, that I have to use Component.getInstance method. So i tried it:




      public class TestEndpointBean
      {
         @WebMethod
         @WebResult(name = "result")
         public String echo(@WebParam(name = "message") String msg)
         {
             Identity id = (Identity) Component.getInstance("org.jboss.seam.security.identity");
             id.setUsername(msg);
             id.setPassword(msg);
             id.login();
             if (id.isLoggedIn()) {
                 return "Logged in";
             } else {
                 return "Not logged in";
             }
         }
      }
      



      But after invoke the request I have this exception :-(



      23:42:04,890 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      java.lang.IllegalStateException: No application context active
           at org.jboss.seam.Component.forName(Component.java:1807)
           at org.jboss.seam.Component.getInstance(Component.java:1857)
           at org.jboss.seam.Component.getInstance(Component.java:1840)
           at org.jboss.seam.Component.getInstance(Component.java:1834)
           at hcp.TestEndpointBean.echo(TestEndpointBean.java:47)
           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:585)
           at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
           at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
           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.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           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)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      23:42:04,890 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      java.lang.IllegalStateException: No application context active
           at org.jboss.seam.Component.forName(Component.java:1807)
           at org.jboss.seam.Component.getInstance(Component.java:1857)
           at org.jboss.seam.Component.getInstance(Component.java:1840)
           at org.jboss.seam.Component.getInstance(Component.java:1834)
           at hcp.TestEndpointBean.echo(TestEndpointBean.java:47)
           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:585)
           at org.jboss.wsf.container.jboss42.DefaultInvocationHandler.invoke(DefaultInvocationHandler.java:102)
           at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:418)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:274)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:191)
           at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:124)
           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.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           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)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)





      Any suggestions?


      Thanks




        • 1. Re: Seam 2.0.1 & JBossWS & WAR deployment
          Karel Jelinek Newbie

          PROBLEM SOLVED


          I need to add context filter for my servlet. So i tried this:


          in web.xml


            <filter>
               <filter-name>Seam Context Filter</filter-name>
               <filter-class>org.jboss.seam.web.ContextFilter</filter-class>
            </filter>
          
            <filter-mapping>
               <filter-name>Seam Context Filter</filter-name>
               <url-pattern>/test</url-pattern>        
            </filter-mapping>



          or another solution is add context filter into components.xml


          .
          .
          xmlns:web="http://jboss.com/products/seam/web"
          .
          .
          <web:context-filter url-pattern="/test"/>



          I've tried both and both works right.
          Now I can use Component.getInstance and everything works

          • 2. Re: Seam 2.0.1 & JBossWS & WAR deployment
            Nicklas Karlsson Master

            A third option would have been to add the seam web service handler to your endpoint config.

            • 3. Re: Seam 2.0.1 & JBossWS & WAR deployment
              xsa lefter Newbie

              By the way, can you explain where to save standard-jaxws-endpoint-config.xml file? or why this warning appear when I tried to restart the server:


              WARN  [JAXWSDeployerHookPreJSE] Cannot load servlet class: com.waditra.bean.accounting.util.WSPublisher



              FYI, WSPublisher is just Hello World apps like:


              @Name("wsPublisher")
              @WebService(name="WSPublisher", serviceName="WSPublisher")
              @SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED)
              public class WSPublisher {
              
                private String message;
              
                @WebMethod
                public String getMessage() { return message; }
              
                @WebMethod
                public void setMessage(@WebParam(name="message")String message) {
                  this.message = message;
                }
              }
              



              And in web.xml i just add:


              <filter>
                <filter-name>Seam Context Filter</filter-name>
                <filter-class>org.jboss.seam.web.ContextFilter</filter-class>
              </filter>
              
              <filter-mapping>
                <filter-name>Seam Context Filter</filter-name>
                <url-pattern>/webservices/wspublisher</url-pattern>
              </filter-mapping>
              
              <servlet>
                <servlet-name>WSPublisher</servlet-name>
                <servlet-class>com.waditra.bean.accounting.util.WSPublisher</servlet-class>
              </servlet>
              
              <servlet-mapping>
                <servlet-name>WSPublisher</servlet-name>
                <url-pattern>/webservices/wspublisher</url-pattern>
              </servlet-mapping>
              



              I has been following some guide in forum and docs, but still no luck for me, and still, the WS is doesn't appear in:




              http://localhost:8080/jbossws/services



              Have some suggestion? Im using JBoss AS 4.2.3 and Seam 2.2.0.


              Any comment will be helpful. Thanks.

              • 4. Re: Seam 2.0.1 & JBossWS & WAR deployment
                Craig  Newbie

                Did you managed to get this to work?


                Thanks in advance


                Craig

                • 5. Re: Seam 2.0.1 & JBossWS & WAR deployment
                  Ravi Kumar Newbie

                  Hi


                  This is long day for me finally got some points as i am still stuck in same condition.

                  The reason is that web.xml file if mapped for file we have created
                  should must be available as if we can deploy the project in archived form it will work. but as it is exploded it will unable to get this mapped class
                  . you can refer this link for:
                  (and i am unable to put the link here but i have got same thing some one has also suffering)
                  My Link
                  My Link
                  and this para:
                  Packaging with Apache Ant


                  Packaging the war file can be done with Apache Ant. In the build.xml, you can find a number of targets. They are used to perform build actions. One of the targets has the name of packaging. This is the target used to create a war file for deployment, as shown following:
                  If get ahead of this kindly update Thanks

                  • 6. Re: Seam 2.0.1 & JBossWS & WAR deployment
                    Andre Hopkins Newbie
                    I am having problems invoking my Servlet from my XHTML form.  When I click on the Submit button, my Servlet is not getting invoked at all.  Below is how I access my GUI Tasking Page and from there I want to use the Servlet to process the request, once the user presses the "Submit" button on the XHTML page.  Am I using the right url pattern in my web.xml file?  Also, I am not quite sure I have my XHTML file setup correctly, please see below.  Once the form is submitted, it should invoke the Servlet, correct?  Any feedback would be much appreciated

                    http://localhost:8080/test-gui/tasking.seam

                    web.xml file...

                    <servlet>
                        <servlet-name>TaskingServlet</servlet-name>
                        <servlet-class>com.tasking.TaskingServlet</servlet-class>
                    </servlet>

                    <servlet-mapping>
                        <servlet-name>TaskingServlet</servlet-name>
                        <url-pattern>/tasking/TaskingServlet</url-pattern>
                    </servlet-mapping>



                    component.xml file....

                    <web:context-filter url-pattern="/tasking/*" />


                    tasking.xhtml file....

                    <form action="TaskingServlet" method="post">

                    <h:commandButton id="tasking" value="Submit"
                                     action="????????"/>



                    TaskingServlet file...

                    public class TaskingServlet extends HttpServlet {
                        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                                throws ServletException, IOException {
                                
                                    String action = request.getParameter("action");
                              System.out.println("User clicked the following action: " + action);

                                   if (action.equalsIgnoreCase("Submit")) {
                                                   // do some work
                                            }
                            ...
                        }
                    }