4 Replies Latest reply on Oct 13, 2011 6:17 PM by stevecoh4

    Newbie Question about wsconsume and javax.xml.ws.Service

    stevecoh4

      My project is somehow set up wrong.  What is getting me is that there are apparently two versions of the class javax.xml.ws.Service.

       

      One version has a single two-parameter constructor:

      http://download.oracle.com/javase/6/docs/api/javax/xml/ws/Service.html

       

      This version ships with the javase 1.6 JDK I am using.

       

      has two constructors, adding an additioanal three-parameter constructor

       

      http://java.sun.com/javaee/6/docs/api/index.html?javax/xml/ws/Service.html

       

      I am trying to develop a web service that will run on jboss-as 5.1.

       

      I am finding that wsconsume is generating code with the three-parameter constructor, which the compiler will then not compile because it is using the class with the two-parameter constructor.

       

      Why are there two incompatible versions of the same class and how do I resolve this mess?

       

      Here is my pom.xml

      {code:xml}

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

          <modelVersion>4.0.0</modelVersion>

       

          <groupId>whatever</groupId>

          <artifactId>however</artifactId>

          <packaging>war</packaging>

          <version>0.0.1-SNAPSHOT</version>

       

          <name>relayws</name>

          <url>http://maven.apache.org</url>

       

          <dependencies>

       

              <dependency>

                  <groupId>javax.servlet</groupId>

                  <artifactId>servlet-api</artifactId>

                  <version>2.5</version>

                  <scope>provided</scope>

              </dependency>

       

              <dependency>

                  <groupId>javax.servlet.jsp</groupId>

                  <artifactId>jsp-api</artifactId>

                  <version>2.1</version>

                  <scope>provided</scope>

              </dependency>

       

              <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <version>3.8.1</version>

                  <scope>test</scope>

              </dependency>

       

              <dependency>

                   <groupId>org.jboss.jbossas</groupId>

                   <artifactId>jboss-as-client</artifactId>

                   <version>5.1.0.GA</version>

                   <type>pom</type>

                   <scope>provided</scope>

               </dependency>

           </dependencies>

       

          <build>

              <plugins>

             

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>2.0.2</version>

                      <configuration>

                          <source>1.6</source>

                          <target>1.6</target>

                      </configuration>

                  </plugin>

                  <plugin>

                      <groupId>org.jboss.ws.plugins</groupId>

                      <artifactId>maven-jaxws-tools-plugin</artifactId>

                      <version>1.0.0.GA</version>

                      <configuration>

                      <targetPackage>com.att.relay.ws</targetPackage>

                          <wsdls>

                              <wsdl>http://localhost:8080//wsdl/LoginService.wsdl</wsdl>

                          </wsdls>

                      </configuration>

                      <executions>

                          <execution>

                              <goals>

                                  <goal>wsconsume</goal>

                              </goals>

                          </execution>

                      </executions>

                      <dependencies>

           <dependency>

            <groupId>org.jboss.ws</groupId>

            <artifactId>jbossws-spi</artifactId>

            <version>1.4.1.GA</version>

            <type>jar</type>

            <scope>compile</scope>

           </dependency>

              <dependency>

                   <groupId>com.sun.istack</groupId>

                   <artifactId>istack-commons-runtime</artifactId>

                   <version>1.0</version>

               </dependency>

       

                          <dependency>

                              <groupId>org.jboss.ws.native</groupId>

                              <artifactId>jbossws-native-client</artifactId>

                              <version>3.4.0.GA</version>

                              <type>jar</type>

                              <scope>compile</scope>

                          </dependency>

       

                      </dependencies>

                  </plugin>

                </plugins>

          </build>

      </project>

      {code}

        • 1. Re: Newbie Question about wsconsume and javax.xml.ws.Service
          stevecoh4

          OK, answered my own question.

           

          The answer is the undocumented <target> option for the plugin

           




          <plugin>



          <groupId>org.jboss.ws.plugins</groupId>




          <artifactId>maven-jaxws-tools-plugin</artifactId>




          <version>1.0.0.GA</version>




          <configuration>




          <target>2.1</target>

           

           

          This plugin option is NOT documented here:

          http://community.jboss.org/wiki/JBossWS-Wsconsume#Maven_Plugin

          but earlier on the same page, i.e. http://community.jboss.org/wiki/JBossWS-Wsconsume#Command_Line_Tool

          the target option is given as a command-line option and I figured to try it with the maven plugin and lo and behold it worked.

           

          Now if someone could please tell me how to make ordinary pastings not be pasted in as an HTML table, I'd be even happier. 

          1 of 1 people found this helpful
          • 2. Re: Newbie Question about wsconsume and javax.xml.ws.Service
            stevecoh4

            I took the correct answer tag off the previous post because my understanding wasn't complete.

             

            It was a perfectly adequate answer for my situation but it has occurred to me, what if I wanted to target JaxWS 2.2 (the default for wsconsume) and JDK 6 instead of 2.1?  How would the incompatibility between the two versions of the Service class be resolved?  I want to understand the classloader trickery needed to mask the J2SE 1-constructor version of Service with the JEE 2-constructor version of Service - and why these two incompatible versions of the same class have the same package and classname, something I don't see too often if at all. 

             

            Can anyone explain the history and the mechanism used to overcome this?

            • 3. Re: Newbie Question about wsconsume and javax.xml.ws.Service
              hmburgett

              FWIW - when I tried executing wsconsume from the command line (JDK 1.6 & JBoss AS 5.1) using the -t or --target parameter the generated service always has the extra contructors (not JDK 1.6 version of JAX-WS) regardless of target (2.0, 2.1, or 2.2).  The command line tool seems to ignore the parameter completely.

               

              If this works from the maven plugin version, then it must be implemented differently than the command line tool.

              • 4. Re: Newbie Question about wsconsume and javax.xml.ws.Service
                stevecoh4

                that's scary.

                 

                I suppose Maven loads itself with a different preset classpath than the command line tool.  I assume that wsconsume command line is a shell script?  Can you change its classpath to be what Maven's is?