4 Replies Latest reply on Oct 2, 2012 10:39 AM by camilo casadiego

    jboss 7 webservice cofiguration

    camilo casadiego Newbie

      HI there, I've been working an getting together a example project to start a migration from a jboss 5 to jboss as 7 (jboss-as-7.1.1.Final) until now I got:

       

      Seam 2.2.2 and full web components working

      Envers for hibernate 3

      Simple jax web services

       

      On the original jboss 5 project, the webservices were also seam componets like this:

       

      @WebService(name = "calculoService", serviceName = "calculoService", endpointInterface = "co.com.adv.Salarix2.ws.CalculoServiceFacade")

      @Stateless

      @Name("calculoService")

      @Scope(ScopeType.SESSION)

      public class CalculoService implements CalculoServiceFacade{

       

      And the onlye thing that I needed to to do achieve this was to add an standard-jaxws-endpoint-config.xml to the META-INF folder of my ear project.

       

      Now on jboss7, this file ins't even read, I know t beacuase I just made this change

       

                          <javaee:handler-class>org.jboss.seam.webservice.SOAPRequestHandler2</javaee:handler-class>

       

      and got no error at all, note that the handler class name is wrong..

       

      I already tried no place it on everi META-INF folder on the project but by this time I'm really stuck...

       

      By the way, this is my webservice class:

       

      @WebService(name = "Test", serviceName = "Test", endpointInterface = "org.jboss.samples.webservices.ITest")

      @Stateless

      @Name("Test")

      @Scope(ScopeType.SESSION)

       

       

      public class Test implements ITest {

       

                @In(required=true) protected EntityManager entityManager;

       

                private long instance;

       

                public Test(){

                          instance = System.currentTimeMillis();

                          System.out.println("Intance created: " + instance);

                }

       

                @PostConstruct

                public void something(){

                          System.out.println("element: " + entityManager);

                }

       

       

                /* (non-Javadoc)

                 * @see org.jboss.samples.webservices.ITest#sayHello(java.lang.String)

                 */

                @Override

                @WebMethod()

                public String sayHello(String name) {

                          System.out.println("Intance called: " + instance);

                          System.out.println(entityManager);

       

       

       

                          System.out.println(entityManager);

       

                    System.out.println("Hello: " + name);

                    return "Hello " + name + "!";

                }

      }

       

      and when I call it this is what i get:

       

      15:52:33,588 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Intance created: 1348951953588

      15:52:33,606 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Intance created: 1348951953606

      15:52:33,608 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Intance called: 1348951953606

      15:52:33,609 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) null

      15:52:33,611 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) null

      15:52:33,612 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Hello: null

      15:52:33,685 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Intance called: 1348951953606

      15:52:33,687 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) null

      15:52:33,688 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) null

      15:52:33,689 INFO  [stdout] (http-localhost-127.0.0.1-9090-1) Hello: null

       

      as you can se somewhy the system creates two differente instances, I guess one of which is the seam mananged instance, but the one it calls to attend the webservices isn't even in a seam context.

       

      Pdta: The web.xml doesn't have any selvlet anotations as long as they aren't needed any more.

       

      Any help'll be reaally Apreciated

       

      In case some one whants to take a look, or thinks tha my project culd help him, Im atacheing the full maven projects (by this point I already sorted a LOT of obstacles to get seam 2.2.2 envers and jboss 7 together, here you can already see seam and envers working like a charm! )

        • 1. Re: jboss 7 webservice cofiguration
          Tomaz Cerar Master

          Hi,

           

          @Stateless & statefull (@Scope(SESSION)

           

          dont mix well.

           

           

          --

          tomaz

          • 2. Re: jboss 7 webservice cofiguration
            camilo casadiego Newbie

            Hi there. I give it a try (as long as I ready found that the problem was tha boss wasn't reading the config file),and got just the same results acording to my problem :s

             

            Im not sure if its a jboss specific issue, or something im missing, but the actual problem is that the file standard-jaxws-endpoint-config.xml that I used to tell the container which class to use for handling webservices, isn't been readed on jboss 7..I can be sure of that because I give it a try and changed the hanlders class name to SOAPRequestHandler2, and the server and application just started withouto problems, but when I tried the same on jboss 5....voiiiiiiiiiila the container throw an class not found...so my conclusion, jboss7 isn't reading this config file....so My question is....HOW you do this on jboss7??? Already read most of te docunetation and haven't found munch info ;(

            • 3. Re: jboss 7 webservice cofiguration
              Richard Opalka Master

              standard-jaxws-endpoint-config.xml is not supported any more - it was JBoss proprietary approach.

              Users have to use JAXWS standard approach, i.e. annotate your endpoint with

               

              @javax.jws.HandlerChain(file="jaxws-handlers-server.xml")

               

              where jaxws-handlers-server.xml file is located in the same directory like endpoint class.

              1 of 1 people found this helpful
              • 4. Re: jboss 7 webservice cofiguration
                camilo casadiego Newbie

                Hi there I gave it a try with your last solution, and now jboss is reading my config file as expected, but my final problem persists:

                 

                so my class is like this:

                 

                @HandlerChain(file="/seam-jaxws-handlerchain.xml")

                @WebService(name = "Test", serviceName = "Test", endpointInterface = "org.jboss.samples.webservices.ITest")

                @Name("Test")

                @Scope(ScopeType.SESSION)

                 

                 

                public class Test implements ITest {

                 

                          @In(required=true) protected EntityManager entityManager;

                 

                But when the webservice call came in it is not a component :s I dig it a little bit further and checked and debugged class SOAPRequestHandler and there there is jut this piece of code

                 

                public boolean handleInbound(MessageContext messageContext)

                   {

                      try

                      {

                         HttpServletRequest request = (HttpServletRequest) messageContext.get(MessageContext.SERVLET_REQUEST);     

                         ServletLifecycle.beginRequest(request, ServletLifecycle.getServletContext());

                 

                 

                         ServletContexts.instance().setRequest(request);

                                

                         String conversationId = extractConversationId(messageContext);

                         ConversationPropagation.instance().setConversationId( conversationId );

                         Manager.instance().restoreConversation();

                        

                         ServletLifecycle.resumeConversation(request);            

                  

                         return true;

                      }

                      catch (SOAPException ex)

                      {

                         log.error("Error handling inbound SOAP request", ex);

                         return false;

                      }

                   }

                 

                So now I'm totally lost....what I need (is what I did have on jboss-5.1.0.GA) is that when I call this endpoint, it is a component so i t has the injections managed by seam, but neither the instance called is a component, nor has the dependencies injected :s