6 Replies Latest reply on Jun 12, 2008 12:13 AM by brettsc

    please help - web services still dont work for me - jboss as

    wiggy

      thought i'd have one last go

      downloaded jboss As5b4. configured eclipse 3.3 with default 5.0 server (basic one)

      deployed ejb3 webservice as ejb file to server and checked wsdl generated. used wsconsume to gen client artifacts and imported into standalone application client project. All compiles.

      client looks like this - cant get much easier

      
      package test;
      
      import java.util.Hashtable;
      
      import javax.naming.InitialContext;
      
      import org.wstest.webservices.*;
      
      public class Test {
      
       /**
       * @param args
       */
       public static void main(String[] args) throws Exception
       {
      
       InitialContext ctx;
       // TODO Auto-generated method stub
      
      
       HelloService s = new HelloService();
       HelloServiceWS ws = s.getHelloServiceWSPort();
      
      
      
       String res = ws.sayHello();
       System.out.println ("test: returned " + res + " \n");
      
       }
      



      generated wsdl at server looks like

      
      - <definitions name="HelloService" targetNamespace="http://webservices.wstest.org/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservices.wstest.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      - <types>
      - <xs:schema targetNamespace="http://webservices.wstest.org/" version="1.0" xmlns:tns="http://webservices.wstest.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="sayHello" type="tns:sayHello" />
       <xs:element name="sayHelloResponse" type="tns:sayHelloResponse" />
      - <xs:complexType name="sayHello">
       <xs:sequence />
       </xs:complexType>
      - <xs:complexType name="sayHelloResponse">
      - <xs:sequence>
       <xs:element minOccurs="0" name="helloResult" type="xs:string" />
       </xs:sequence>
       </xs:complexType>
       </xs:schema>
       </types>
      - <message name="HelloServiceWS_sayHello">
       <part element="tns:sayHello" name="sayHello" />
       </message>
      - <message name="HelloServiceWS_sayHelloResponse">
       <part element="tns:sayHelloResponse" name="sayHelloResponse" />
       </message>
      - <portType name="HelloServiceWS">
      - <operation name="sayHello" parameterOrder="sayHello">
       <input message="tns:HelloServiceWS_sayHello" />
       <output message="tns:HelloServiceWS_sayHelloResponse" />
       </operation>
       </portType>
      - <binding name="HelloServiceWSBinding" type="tns:HelloServiceWS">
       <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
      - <operation name="sayHello">
       <soap:operation soapAction="" />
      - <input>
       <soap:body use="literal" />
       </input>
      - <output>
       <soap:body use="literal" />
       </output>
       </operation>
       </binding>
      - <service name="HelloService">
      - <port binding="tns:HelloServiceWSBinding" name="HelloServiceWSPort">
       <soap:address location="http://127.0.0.1:8080/wstest-ejb/HelloService" />
       </port>
       </service>
       </definitions>
      




      run the test and get


      Exception in thread "main" javax.xml.ws.WebServiceException: Unable to load Provider: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl
       at javax.xml.ws.spi.Provider.provider(Provider.java:90)
       at javax.xml.ws.Service.<init>(Service.java:82)
       at org.wstest.webservices.HelloService.<init>(HelloService.java:40)
       at test.Test.main(Test.java:21)
      Caused by: java.lang.IllegalStateException: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl
       at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:96)
       at javax.xml.ws.spi.Provider.provider(Provider.java:82)
       ... 3 more
      Caused by: java.lang.ExceptionInInitializerError
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
       at java.lang.Class.newInstance0(Class.java:350)
       at java.lang.Class.newInstance(Class.java:303)
       at javax.xml.ws.spi.ProviderLoader.loadProvider(ProviderLoader.java:91)
       ... 4 more
      Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference.
       at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:188)
       at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:65)
       ... 11 more
      Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
      Two classes have the same XML type name "address". Use @XmlType.name and @XmlType.namespace to assign different names to them.
       this problem is related to the following location:
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address
       at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address com.sun.xml.ws.developer.MemberSubmissionEndpointReference.addr
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
       this problem is related to the following location:
       at javax.xml.ws.wsaddressing.W3CEndpointReference$Address
       at private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
       at javax.xml.ws.wsaddressing.W3CEndpointReference
      Two classes have the same XML type name "elements". Use @XmlType.name and @XmlType.namespace to assign different names to them.
       this problem is related to the following location:
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
       at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
       at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
       this problem is related to the following location:
       at javax.xml.ws.wsaddressing.W3CEndpointReference$Elements
       at private javax.xml.ws.wsaddressing.W3CEndpointReference$Elements javax.xml.ws.wsaddressing.W3CEndpointReference.referenceParameters
       at javax.xml.ws.wsaddressing.W3CEndpointReference
      
       at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
       at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438)
       at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:286)
       at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
       at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)
       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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:211)
       at javax.xml.bind.ContextFinder.find(ContextFinder.java:372)
       at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
       at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
       at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:186)
       ... 12 more
      


      please help i really want this to work so i can get back to my business problem - and not spend time trashing in frameworks.

      doesnt work on 4.2.2 either

        • 1. Re: please help - web services still dont work for me - jbos
          peterj

          Based on the client code you posted, I assume that your web service looks very similar to that given at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=132729, except yours is an EJB.

          I compiled your client, and ran it:

          >F:\opt\jboss-5.0.0.Beta4\bin\wsrunclient -classpath "F:\opt\ws2\target\dist\client.jar;F:\opt\jboss-5.0.0.Beta4\client\jbossall-client.jar" test.Test
          log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.builder
          .jaxws.JAXWSWebServiceMetaDataBuilder).
          log4j:WARN Please initialize the log4j system properly.
          test: returned Hello

          Works for me. JBossAS 5.0.0.Beta4 (which contains JBossWS 2.0.3.GA), JDK 1.5.0_14. It also works in JBossAS 4.2.2.

          So now the question is, how is your setup different from mine?

          • 2. Re: please help - web services still dont work for me - jbos
            pramod_bs

            Try to remove following jar files from your clients class path - jaxws-rt.jar
            jaxws-tools.jar. This happended to me. Please try this. It might work.

            • 3. Re: please help - web services still dont work for me - jbos
              heiko.braun

              Yes, it's a classpath problem. The JAX-WS provider is accessed by a Jar service loader. Depending on which jar is in the classpath it either loads the Jbossws one or the Sun RI one: com.sun.xml.ws.spi.ProviderImpl.

              It's the two jars pramod_bs described. They only needed for the wsconsume and wsprovide tools, but shouldn't be on the client classpath.

              • 4. Re: please help - web services still dont work for me - jbos
                heiko.braun

                Maybe someone can put some docs into the Wiki how to setup eclipse?

                • 5. update Re: please help - web services still dont work for me
                  wiggy

                  Yes thank you the two libraries if removed from the build work.

                  spent a day on the train and created a user library (rather than the jboss4.2.2 runtime library).

                  I dont know whos problem this is - is it JBOSS tools problem? This has cost me alot of pain/time to resolve and I think it should go into jira somewhere and change in the library builds to remove this problem.

                  Where should this go?

                  anyhow i fiddled around with the standalone client and managed to get down the following minimal set or jars (for this example)

                  //from /client
                  jbossws-spi.jar
                  jaxb-api.jar
                  jboss-jaxws.jar
                  jbossws-client.jar
                  jbossclient-all.jar


                  also from the /lib/endorsed directory you need
                  xercesImpl.jar


                  when i now run the client i get the result with no errors -

                  for any one esle with this problem you have to used wsconsume (and parse the wsdl on the server) in the /bin directory to generate the client stubs that you include in your client build

                  I had problems with eclipse web services explorer - in the end i'm not sure what fixed this it was either a) i created my workspace with no spaces in the path and or b) i updated the jboss ws libaries from the jbossWS downloads (i installed the jbossws-3.0.1-native-2.0.4.GA.zip) and my explorer now seems to work

                  is there any where where you can post a this is how you set up a project ?


                  package test;
                  
                  import java.util.Hashtable;
                  
                  import javax.naming.InitialContext;
                  
                  import org.wstest.webservices.*;
                  
                  public class Test {
                  
                   /**
                   * @param args
                   */
                   public static void main(String[] args) throws Exception
                   {
                  
                   InitialContext ctx;
                   // TODO Auto-generated method stub
                  
                  
                   HelloService s = new HelloService();
                   HelloServiceWS ws = s.getHelloServiceWSPort();
                  
                  
                  
                   String res = ws.sayHello();
                   System.out.println ("test: returned " + res + " \n");
                  
                   }
                  


                  Thanks for the help - eventually i can get back to my project!



                  • 6. Re: please help - web services still dont work for me - jbos
                    brettsc

                    Just a minor change to the libraries...

                    jbossclient-all.jar should be jbossall-client.jar.