1 2 Previous Next 15 Replies Latest reply on Dec 8, 2011 4:55 AM by Andrew Dinn

    Xts class does not have javax.jws.WebService annotation

    Pavlos Polianidis Newbie

      Hi everybody,

       

      i am trying to implement a transaction for web services using xts api. I have followed the examples provided with the jbossts 4.6.1 distribution. Acrually i have managed to do most of the part(started the transaction and got the coordination context). However, when i try to enroll my service in the following way:

       

      TransactionManagerFactory.transactionManager().enlistForDurableTwoPhase( participant,                                                                             "uk.ac.soton.ecs.comp6017:flightAT:" + new Uid().toString());

       

      To my surprise i get this strange exception:

       

      com.arjuna.wst.SystemException: javax.xml.ws.WebServiceException: Service endpoint interface class org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType does not have a javax.jws.WebService annotation.

       

      I checked the RegistrationPortType interface, and everything is fine, there is this annotation:

       

      @WebService(name = "RegistrationPortType", targetNamespace = "http://docs.oasis-open.org/ws-tx/wscoor/2006/06

       

      Has anyone tacled before with such a problem?

        • 1. Re: Xts class does not have javax.jws.WebService annotation
          Paul Robinson Master

          Pavlos,

           

          Can you provide the code for your participant and service classes?

           

          Thanks,

           

          Paul.

          • 2. Re: Xts class does not have javax.jws.WebService annotation
            Pavlos Polianidis Newbie

            Paul,

             

            Here is my service code:

             

            package uk.ac.soton.ecs.comp6017;
            
            import com.arjuna.ats.arjuna.common.Uid;
            import com.arjuna.mw.wst11.TransactionManagerFactory;
            import com.arjuna.mw.wst11.UserTransactionFactory;
            
            import javax.jws.HandlerChain;
            import javax.jws.WebParam;
            import javax.jws.WebService;
            import javax.jws.WebMethod;
            import javax.jws.soap.SOAPBinding;
            
            
            import uk.ac.soton.ecs.comp6017.tdata.*;
            
            
            
            public class TradeFlightImpl implements TradeFlightService {
                 
                 public FlightStatus checkFlightAvailability(FlightRequestInfo flightInfo) {
                      System.out.println("Flight destination is:");
                      System.out.println(flightInfo.getDestination());
                      String transactionId = null;
                      
                      try {
                            //get the transaction context of this thread:
                           transactionId = UserTransactionFactory.userTransaction().toString();
                           System.out.println("ServiceAT transaction id ="
                                     + transactionId);
                           System.out.println("ServiceAT - enrolling...");
                           // enlist the Participant for this service:
                           FlightServiceATParticipant participant = new FlightServiceATParticipant( transactionId );               
                           TransactionManagerFactory.transactionManager().enlistForDurableTwoPhase( participant, 
                                                                                       "uk.ac.soton.ecs.comp6017:flightAT:" + new Uid().toString());
                           
                      } catch (Exception e) {
                           System.err.println("checkFlightAvailability: Participant enrolment failed");
                           e.printStackTrace(System.err);
                           
                      }
                      FlightStatus status = new FlightStatus();
            
                      status.setSource("London");
                      status.setDestination("Athens");
            
                      return status;
                 }
            }
            
            

             

            and here is the participant of the service:

             

            package uk.ac.soton.ecs.comp6017;
            
            import java.io.Serializable;
            
            import com.arjuna.wst.*;
            
            
            /**Participant of the flight service*/
            public class FlightServiceATParticipant implements Durable2PCParticipant, Serializable{
            
                 private static final long serialVersionUID = 1L;
                 private String txID; 
                 
                 /**Constructor*/
                 public FlightServiceATParticipant( String txID ){
                      // we need to save the txID for later use when calling
                    // business logic methods in the restaurantManger.
                      this.txID = txID;
                 }
            
                 public void commit() throws WrongStateException, SystemException {
                       System.out.println("RestaurantParticipantAT.commit");
                      
                 }
            
                 public void error() throws SystemException {
                      // TODO Auto-generated method stub
                      
                 }
            
                 public Vote prepare() throws WrongStateException, SystemException {
                      System.out.println("RestaurantParticipantAT.prepare");
                      
                      return new Prepared();
                 }
            
                 public void rollback() throws WrongStateException, SystemException {
                      System.out.println("RestaurantParticipantAT.rollback");
                      
                 }
            
                 public void unknown() throws SystemException {
                      // TODO Auto-generated method stub
                      
                 }
                 
                 
            }
            
            
            • 3. Re: Xts class does not have javax.jws.WebService annotation
              Andrew Dinn Master

              Pavlos Polianidis wrote:

               

              To my surprise i get this strange exception:

               

              com.arjuna.wst.SystemException: javax.xml.ws.WebServiceException: Service endpoint interface class org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType does not have a javax.jws.WebService annotation.

               

              I checked the RegistrationPortType interface, and everything is fine, there is this annotation:

               

              @WebService(name = "RegistrationPortType", targetNamespace = "http://docs.oasis-open.org/ws-tx/wscoor/2006/06

               

              Has anyone tacled before with such a problem?

               

              Hmm, so we have a class clearly annotated with javax.jws.WebService yet the JBossWS code is saying that it is not annotated with javax.jws.WebService. How can that happen? Well, this suggests to me that there are two versions of this class, one version used to resolve the annotation and another used by JBossWS. How can that happen?

               

              Well, it can only really occur in very unusual circumstances, For example, if you have bundled a jar with your app which contains javax/jws/WebService.class and if your app's classloader loads from the bundled jars in preference to the jars used by JBossWS (the latter are -- or at least ought to be -- in the system classpath).

               

              So, what is the structure of your deployment? Have you bundled any WS library jars in with your code?

              • 4. Re: Xts class does not have javax.jws.WebService annotation
                Pavlos Polianidis Newbie

                Andrew you are tottaly right. I had a jar which was invluded by some maven dependency, and i had the javax/jws/WebService.class insside. So i removed it and the specific error disappeared.

                 

                However, i am still strugling to make the service register. More particularly, i now get a NPE. After debugging i dound the source of the exception.

                The exception is thrown from the com.arjuna.webservices11.wscoor.client.WSCOORClient; class. More specifacally, from line 132 :

                 

                AddressingHelper.installActionMessageID(addressingProperties, action, messageID);as

                 

                and this is due to the previous line:

                AddressingProperties addressingProperties = (AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);

                 

                 

                where the addressingProperties is NULL.

                 

                To be honest i have to idea of what is going wrong, in this case.

                • 6. Re: Xts class does not have javax.jws.WebService annotation
                  Pavlos Polianidis Newbie

                  Paul,

                   

                  You mean i have to write the @Addressing(required=true) above my service implementation class?

                   

                  I did so, and it does not seem to work, The error which appears is:

                   

                  javax.xml.ws.soap.SOAPFaultException: A required header representing a Message Addressing Property is not present
                       org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.getSOAPFaultException(SOAPFaultHelperJAXWS.java:84)
                       org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.throwFaultException(SOAP11BindingJAXWS.java:107)
                       org.jboss.ws.core.CommonSOAPBinding.unbindResponseMessage(CommonSOAPBinding.java:579)
                       org.jboss.ws.core.CommonClient.invoke(CommonClient.java:381)
                       org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:290)
                       org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170)
                       org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
                       $Proxy373.checkFlightAvailability(Unknown Source)
                       org.comp6017.JaxWsClient.Client.testTransaction(Client.java:252)
                       org.comp6017.JaxWsClient.Client.doGet(Client.java:190)
                       javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
                       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  
                  • 7. Re: Xts class does not have javax.jws.WebService annotation
                    Pavlos Polianidis Newbie

                    As far as i'm concerned, the service stub gets a SOAP message without a message addressing property in the header. But, i think that the JaxWSHeaderContextProcessor handler does this job for us. It inserts the coordination context, as well as the message addressing property.

                    • 8. Re: Xts class does not have javax.jws.WebService annotation
                      Paul Robinson Master

                      Pavlos,

                       

                      It sounds like the client side JaxWSHeaderContextProcessor handler is not being invoked. You could attach a debugger to verify this.

                       

                      Are you using @HandlerChain on the Client side interface? This is not allowed for generated SEI. We hit this problem with the TXBridge bistro example:

                       

                      https://issues.jboss.org/browse/JBTM-937

                       

                      You can look at the Bistro example for how to use the BindingProvider instead of @HandlerChain to specify the handler chain on the client side.

                       

                      Paul.

                      • 9. Re: Xts class does not have javax.jws.WebService annotation
                        Pavlos Polianidis Newbie

                        Paul,

                         

                        On the client side i am not using the  @HandlerChain. i am doing the following:

                         

                        System.out.println("configureClientHandler....");
                                  Handler handler = new JaxWSHeaderContextProcessor();
                                  List handlers = Collections.singletonList(handler);
                                  bindingProvider.getBinding().setHandlerChain(handlers);
                        

                         

                        And i think the client side JaxWSHeaderContextProcessor  is invoked because in my service, when i run:

                         

                         

                        transactionId = UserTransactionFactory.userTransaction().toString();
                                       System.out.println("ServiceAT transaction id =" + transactionId);
                        

                        i can see the transactionid, which is the same that is returned on the client side when i am starting the transaction (ut.begin()).

                         

                        I think this states, that the client side JaxWSHeaderContextProcessor  handelr is indeed invoked.

                        • 10. Re: Xts class does not have javax.jws.WebService annotation
                          Pavlos Polianidis Newbie

                          I checked the getregistrationPort method's code, which is:

                           

                           // don't think we ever need this as we get a registration port from the endpoint ref returned by
                              // the activation port request
                              public static RegistrationPortType getRegistrationPort(W3CEndpointReference endpointReference, String action, String messageID)
                              {
                                  // TODO - we need the 2.1 verison of Service so we can specify that we want to use the WS Addressing feature
                                  RegistrationService service = getRegistrationService();
                                  // RegistrationPortType port = service.getPort(endpointReference, RegistrationPortType.class, new AddressingFeature(true, true));
                                  RegistrationPortType port = service.getPort(endpointReference, RegistrationPortType.class);
                                  BindingProvider bindingProvider = (BindingProvider)port;
                                  /*
                                   * we have to add the JaxWS WSAddressingClientHandler because we cannoy specify the WSAddressing feature
                                   */
                                  List customHandlerChain = new ArrayList();
                                    customHandlerChain.add(new WSAddressingClientHandler());
                                    bindingProvider.getBinding().setHandlerChain(customHandlerChain);
                          
                                  // ok, JBossWS native has hacked this by pulling the address and reference parameters out of the endpoint
                                  // and storing them in an AddressingProperties instance hung off the context under CLIENT_ADDRESSING_PROPERTIES_OUTBOUND.
                                  // but we still need to set the action and message id -- this is all distinctly non-portable :-/
                                  // n.b. Metro installs the address in requestContext under ENDPOINT_ADDRESS_PROPERTY. it also seems to ensure
                                  // that the reference parameters get installed -- but how?
                          
                                  Map requestContext = bindingProvider.getRequestContext();
                                  // String address = (String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
                                  // AddressingProperties addressingProperties = AddressingHelper.createRequestContext(address, action, messageID);
                                  // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addressingProperties);
                                   // jbossws should do this for us . . .
                                   // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addressingProperties);
                                  AddressingProperties addressingProperties = (AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
                                  AddressingHelper.installActionMessageID(addressingProperties, action, messageID);
                                  // we should not need to do this but JBossWS does not pick up the value in the addressing properties
                                  requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, addressingProperties.getTo().getURI().toString());
                                  return port;
                              }
                          }
                          

                           

                          At some point it says:

                           

                          // String address = (String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
                                  // AddressingProperties addressingProperties = AddressingHelper.createRequestContext(address, action, messageID);
                                  // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addressingProperties);
                                   // jbossws should do this for us . . .
                                   // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addressingProperties);
                          

                          Apparently, i looks like jboss does not execute this commented out code, that's why the:

                           

                          AddressingProperties addressingProperties = (AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);

                           

                          returns null!

                          • 11. Re: Xts class does not have javax.jws.WebService annotation
                            Andrew Dinn Master

                            Pavlos Polianidis wrote:

                             

                            At some point it says:

                             

                            // String address = (String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
                                    // AddressingProperties addressingProperties = AddressingHelper.createRequestContext(address, action, messageID);
                                    // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addressingProperties);
                                     // jbossws should do this for us . . .
                                     // requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addressingProperties);
                            

                            Apparently, i looks like jboss does not execute this commented out code, that's why the:

                             

                            AddressingProperties addressingProperties = (AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);

                             

                            returns null!

                             

                            No, that is not what is wrong here. If you use XTS with JBossWS Native then the addreessing properties are installed in the request context when the port is created from the RegistrationCoordinator endpoint. That comment explains how WS Native differs form Glassfish which was the only working WS stack when the XTS code based on JaxWS was prototyped in 2007.

                             

                            I finally realised what you are trying to do here. It lookjs like you are trying to run XTS on top of JBossWS using the CXF stack. yes? Well, that is never going to work for a whole load of reasons. AS 5.0.1 and AS 5.1.0 only support XTS using the JBossWS Native stack. XTS was eventually ported to run on the CXF stack for JBoss AS 6 although doing so required many fixes to deal with problems in the behaviour of CXF. It also runs on top of AS7. So, if you really want/need to use CXF then you will have to use AS 6.0 or AS 7.0 Final releases.

                            1 of 1 people found this helpful
                            • 12. Re: Xts class does not have javax.jws.WebService annotation
                              Pavlos Polianidis Newbie

                              Andrew,

                               

                              Does that mean that i have to remove any CXF jar file that i have on my deployed war, in order to avoid class loading problems?

                               

                              Moreover do i have to change my appContext.xml file?

                               

                              <?xml version="1.0" encoding="UTF-8"?>

                              <beans xmlns="http://www.springframework.org/schema/beans"

                                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

                                        xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws"

                                        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

                              http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd

                              http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd

                              http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"

                                        default-dependency-check="none" default-lazy-init="false">

                               

                               

                                        <!-- Load the needed resources that are present in the cxf* jars -->

                                        <import resource="classpath:META-INF/cxf/cxf.xml" />

                                        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

                                        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

                               

                               

                                        <!-- Hook up the web service -->

                                        <jaxws:endpoint id="FlightService"

                                                  implementor="uk.ac.soton.ecs.comp6017.TradeFlightImpl" address="/FlightService">

                                                  <jaxws:handlers>

                                                            <bean class="com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor" name="ContextHandler"/>

                                                  </jaxws:handlers>

                                        </jaxws:endpoint>

                               

                               

                              Thank you in advance!

                               

                              </beans>

                              • 13. Re: Xts class does not have javax.jws.WebService annotation
                                Pavlos Polianidis Newbie

                                Andrew,

                                 

                                I tried to deploy my service on jboss 6, However it seems that there is an issue with spring:

                                 

                                It throws an:

                                Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationListener

                                 

                                Despite the fact that spring is included in my war.

                                • 14. Re: Xts class does not have javax.jws.WebService annotation
                                  Pavlos Polianidis Newbie

                                  Solved. I moved manually the spring jars into the common/lib directory and i runs now!

                                   

                                  Andrew thank you so much for you're valuable help. Esspecially, for CXF and jboss 5 issue. I was struggling two weeks without knowing that detail. I am impressed, how did you understand that i am using the CXF stack? Thanks again.

                                  1 2 Previous Next