2 Replies Latest reply on Mar 19, 2009 3:27 AM by krishnaroopa Senthilkumar

    Unable to create instance of Service object from a WSDL file

    Ajay Kumar Newbie

      Dear All,
      I am evaluating JAX-WS using JBOSS 4.2.3. I have exposed a simple statetless EJB3.0 as a web service which echo back the argument sent to it.
      The code of web service is as follows :

      package ccc;
      
      import javax.jws.*;
      import javax.ejb.*;
      @Stateless
      @javax.jws.WebService
      public class Greeting implements RemoteServiceInterface
      {
       @WebMethod
       public String echo(String input)
       {
       return input;
       }
      
      }
      


      I made the jar file and deployed it on the JBOSS4.2.3 server.It deployed succesfully and the following WSDL file is created by the application server:-

      - <definitions name="GreetingService" targetNamespace="http://ccc/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ccc/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      - <types>
      - <xs:schema targetNamespace="http://ccc/" version="1.0" xmlns:tns="http://ccc/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="echo" type="tns:echo" />
       <xs:element name="echoResponse" type="tns:echoResponse" />
      - <xs:complexType name="echo">
      - <xs:sequence>
       <xs:element minOccurs="0" name="arg0" type="xs:string" />
       </xs:sequence>
       </xs:complexType>
      - <xs:complexType name="echoResponse">
      - <xs:sequence>
       <xs:element minOccurs="0" name="return" type="xs:string" />
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       </types>
      - <message name="Greeting_echoResponse">
       <part element="tns:echoResponse" name="echoResponse" />
       </message>
      + <message name="Greeting_echo">
       <part element="tns:echo" name="echo" />
       </message>
      - <portType name="Greeting">
      - <operation name="echo" parameterOrder="echo">
       <input message="tns:Greeting_echo" />
       <output message="tns:Greeting_echoResponse" />
       </operation>
       </portType>
      - <binding name="GreetingBinding" type="tns:Greeting">
       <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
      - <operation name="echo">
       <soap:operation soapAction="" />
      - <input>
       <soap:body use="literal" />
       </input>
      - <output>
       <soap:body use="literal" />
       </output>
       </operation>
       </binding>
      - <service name="GreetingService">
      - <port binding="tns:GreetingBinding" name="GreetingPort">
       <soap:address location="http://dlhlx09.dlh.st.com:20120/mywebservice/Greeting" />
       </port>
       </service>
       </definitions>
      


      I tried to consume the web service deployed on the JBOSS server using java batch using following code :-
      package ccc.client;
      import javax.xml.ws.Service;
      import javax.xml.ws.WebServiceException;
      import javax.xml.namespace.QName;
      import java.net.MalformedURLException;
      import java.net.URL;
      import ccc.RemoteServiceInterface;
      import javax.xml.ws.Provider;
      public class EchoClient
      {
      
      
       URL wsdlLocation ;
       QName serviceName;
       Service service;
       public static void main(String[] args)
       {
       try {
       EchoClient client = new EchoClient();
       client.doTest("Ajay");
       } catch(Exception e) {
       e.printStackTrace();
       }
       }
      
       public void doTest(String x)
       {
       try {
       wsdlLocation = new URL("http://dlhlx09.dlh.st.com:20120/mywebservice/Greeting?wsdl");
       serviceName = new QName("http://ccc/", "GreetingService");
       Service service = Service.create(wsdlLocation, serviceName);
       RemoteServiceInterface port = service.getPort(RemoteServiceInterface.class);
       System.out.println("Invoking the sayHello operation on the port.");
      
       String response = port.echo(x);
       System.out.println(response);
       } catch(Exception e) {
       e.printStackTrace();
       }
       }
      
      }
      


      But I am not able to create instance of Service object and following exeption is being thrown at runtime :-

      java.lang.IllegalStateException: Failed to load javax.xml.ws.spi.Provider: org.jboss.ws.core.jaxws.spi.ProviderImpl
       at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:94)
       at javax.xml.ws.spi.Provider.provider(Provider.java:80)
       at javax.xml.ws.Service.<init>(Service.java:79)
       at javax.xml.ws.Service.create(Service.java:96)
       at ccc.client.EchoClient.doTest(EchoClient.java:33)
       at ccc.client.EchoClient.main(EchoClient.java:23)
      Caused by: java.lang.NoClassDefFoundError: org/jboss/util/NotImplementedException
       at java.lang.Class.getDeclaredConstructors0(Native Method)
       at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
       at java.lang.Class.getConstructor0(Class.java:2671)
       at java.lang.Class.newInstance0(Class.java:321)
       at java.lang.Class.newInstance(Class.java:303)
       at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:89)
      


      Can any one please help me out what is the cause of the prolem and
      why expetion is being thrown by the client application at the time of creating instance of Service object for consuming web service depoyed on JBOSS4.2.3

      best regards,
      Ajay Kumar