5 Replies Latest reply on Mar 29, 2008 2:17 PM by sajhak

    JBoss & JAX-WS. Beginners Guide

    jgf1

      Hi folks.
      I've recently been finished reading a book called Beginning Java EE 5 Platform from Novice to Professional.

      It contained an example using JAX-WS.

      When I tried to locate one of the jars, I couldn't find it:
      ie:jbossws.jar. According to book it's in jbossws.sar folder..

      Tried compiling code without this but came across two errors based on jars in my classpath:
      warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jsr173_1.0_api.jar": no such file or directory
      warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jaxb1-impl.jar": no such file or directory

      1) Wondered if someone could shed some light on this for me?

      (The authors do state the JAX-WS was incomplete at the time the book was being written. I have downloaded jboss-4.2.2ga,
      - Says no full implementations of JSR-181 WS meta-data for J EE 5/JAX-WS 2.0 formerly JAX-RPC. Book was published in 2006...)

      These are the jars in my classpath:
      c:\apps\jboss-4.2.2.ga\server\all\lib\servlet-api.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jsp-api.jar;
      c:\apps\jboss-4.2.2.ga\server\all\deploy\jbossws.sar\wsdl4j.jar;
      c:\apps\jboss-4.2.2.ga\client\jboss-jaxrpc.jar;

      c:\apps\jboss-4.2.2.ga\lib\concurrent.jar;
      c:\apps\jboss-4.2.2.ga\lib\jboss-common.jar;
      c:\apps\jboss-4.2.2.ga\client\jboss-j2ee.jar;
      c:\apps\jboss-4.2.2.ga\lib\commons-httpclient.jar;
      c:\apps\jboss-4.2.2.ga\client\jbossall-client.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jboss.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jboss-remoting.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jboss-transaction.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jnpserver.jar;
      c:\apps\jboss-4.2.2.ga\server\all\deploy\ejb3.deployer\jboss-ejb3.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jboss-ejb3x.jar;
      c:\apps\jboss-4.2.2.ga\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aop-jdk50.jar;
      c:\apps\jboss-4.2.2.ga\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aspect-library-jdk50.jar;
      c:\apps\jboss-4.2.2.ga\client\jboss-common-client.jar;c:\apps\jboss-4.2.2.ga\client\jbosssx-client.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\ejb3-persistence.jar;C:\apps\apache-tomcat-6.0.16\lib\jsf-api.jar;

      (The ones in bold I have just added. The ejb3 ones are the others they say are required as well as the missing jbossws.jar)


      This was the example

      package webservices;
      
      import java.rmi.Remote;
      
      public interface SimpleService extends Remote
      {
      String echo(String input);
      }
      


      package webservices;
      
      import org.jboss.annotation.ejb.RemoteBinding;
      import org.jboss.ws.annotation.PortComponent;
      
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      
      @WebService(name = "EndpointInterface", targetNamespace = "http://localhost",
       serviceName = "SimpleService")
      @PortComponent(contextRoot="/jbosswsest", urlPattern="/*")
      @Remote(SimpleService.class)
      @Stateless
      public class SimpleServiceImpl implements SimpleService
      {
       @WebMethod
       public String echo(String input)
       {
       return input;
       }
      }
      


      package client;
      
      import webservices.SimpleService;
      import javax.xml.rpc.ServiceFactory;
      import javax.xml.rpc.Service;
      import javax.xml.namespace.QName;
      import java.net.URL;
      
      public class SimpleServiceClient {
       private static final String _namespace = "http://localhost";
       private static final String _service = "SimpleService";
       private static final String _wsdl = "http://localhost:8080/jbosswstest?wsdl";
      
       public static void main(String[] args) {
       try {
       URL defUrl = new URL(_wsdl);
       // Create the Service Factory
       ServiceFactory serviceFactory = ServiceFactory.newInstance();
       // Load the service implementation class
       Service remoteService = serviceFactory.createService(defUrl,
       new QName(_namespace, _service));
       // Load a proxy for our class
       SimpleService invoker =
       (SimpleService) remoteService.getPort(SimpleService.class);
       // Invoke our interface for each argument
       for (int i = 0; i < args.length; i++) {
       String returnedString = invoker.echo(args);
       System.out.println("sent string: " + args
       + ", received string: " + returnedString);
       }
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
      }
      


      My compile fails with the following:
      warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jsr173_1.0_api.jar": no such file or directory
      warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jaxb1-impl.jar": no such file or directory
      webservices\SimpleServiceImpl.java:3: package org.jboss.annotation.ejb does not exist
      import org.jboss.annotation.ejb.RemoteBinding;
       ^
      webservices\SimpleServiceImpl.java:4: package org.jboss.ws.annotation does not exist
      import org.jboss.ws.annotation.PortComponent;
       ^
      webservices\SimpleServiceImpl.java:13: cannot find symbol
      symbol: class PortComponent
      @PortComponent(contextRoot="/jbosswsest", urlPattern="/*")
       ^
      3 errors
      2 warnings
      



      The book says you need the following to run client app:
      c:\apps\jboss-4.2.2.ga\client\jboss-jaxrpc.jar;
      c:\apps\jboss-4.2.2.ga\client\log4j.jar;
      c:\apps\jboss-4.2.2.ga\client\logkit.jar;
      c:\apps\jboss-4.2.2.ga\client\jbossws-client.jar;
      c:\apps\jboss-4.2.2.ga\client\activation.jar;
      c:\apps\jboss-4.2.2.ga\client\jboss-saaj.jar;
      c:\apps\jboss-4.2.2.ga\client\mail.jar;
      c:\apps\jboss-4.2.2.ga\client\wsdl4j.jar;
      c:\apps\jboss-4.2.2.ga\lib\endorsed\xercesImpl.jar;
      c:\apps\jboss-4.2.2.ga\client\jbossall-client.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\jboss-remoting.jar;
      c:\apps\jboss-4.2.2.ga\server\all\lib\javax.servlet.jar

        • 1. Re: JBoss & JAX-WS. Beginners Guide
          jgf1

          BTW: Should an 'i' enclosed in square brackets [ ] change output to italic when it's embedded in a code block. It's debatable I suppose. But not what I wanted :)

          • 2. Re: JBoss & JAX-WS. Beginners Guide
            jgf1

             

            "JGF1" wrote:
            warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jsr173_1.0_api.jar": no such file or directory
            warning: [path] bad path element "c:\apps\jboss-4.2.2.ga\client\jaxb1-impl.jar": no such file or directory

            1) Wondered if someone could shed some light on this for me?


            I think I may have tracked this one down.
            jaxb-impl.jar has a manifest with the two offenders
            jsr173_1.0_api.jar & jaxb1-impl.jar
            This was located in the jbossws.sar folder



            I think this got pulled in because of the introduction of jboss-jaxrpc.jar.
            It's manifest contains a reference to jaxb-impl.jar..

            Perhaps the folks doing the JBoss builds need to be made aware of this...

            • 3. Re: JBoss & JAX-WS. Beginners Guide
              jgf1

              I noticed in a PDF by Radim Marek over at BSG that @PortComponent is not supported in and @WebContext is now used instead.
              Also @WebContext has been moved to org.jboss.wsf.spi.annotation
              Is there an online guide for JBoss's implementation of Webservices using JAX-WS that someone can point me too that can give me an introduction and bring things up to date. (or perhaps an up to date book)
              I liked the idea of using annotations to code web services in Java in a fashion similar to the example they gave in the book.

              • 4. Re: JBoss & JAX-WS. Beginners Guide
                asoldano

                A common problem of computer science books is that they become out of date ;-)
                For sure we have documentation about JAX-WS web services, http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS and it is constantly maintained up to date.
                In particular, you might want to read this: http://jbws.dyndns.org/mediawiki/index.php?title=JAX-WS_User_Guide

                • 5. Re: JBoss & JAX-WS. Beginners Guide
                  sajhak

                  Hey JGF1 ,

                  i m having the exact same problem as i refer the same book u have read.
                  did you sort it out the problem ? could you please tell me the modifications needed to run that example correctly ?

                  im using JBOSS 4.2.2 GA too.

                  thanks
                  saji