FROMDEV

Trying to run JAX-WS Sample Application in the Metro Environment

I recently downloaded the Metro 2.0 from .

I wanted to install it on my Tomcat 6 (apache-tomcat-6.0.18) with JDK (1.6.0_10)

I followed Java example in the “Getting started with Metro” guide from https://metro.java.net/getting-started/basic.html

Below are the issues I ran into during this process so thought of posting this for others benefit.


Issue #1 : Tomcat endorsed directory location in Ant build.xml

When you run the “server” target in build.xml it throws following error message.

C:wsit-jaxws-fromjava>ant -Duse.tomcat=true server
Buildfile: build.xml

BUILD FAILED
C:wsit-jaxws-fromjavabuild.xml:129: C:Toolsapache-tomcat-6.0.18commonendorsed not found.

Total time: 0 seconds

This issue is due the wrong directory path for lib.endorsed in build.xml to fix this issue open the wsit-jaxws-fromjavabuild.xml file and search for following



Change the directory value ${catalina.home}/common/endorsed to ${catalina.home}/endorsed as shown below and save the build.xml file.



Now run the “ant -Duse.tomcat=true server” command again, build should be successful.

Issue #2 : The xendorsed option is required for JDK6

Once the you are done generating the server side for this web service you need to generate the client sources for the same sample service.
When I run the “ant -Duse.tomcat=true client” command I get following error message and build is failed again.

C:wsit-jaxws-fromjava>ant -Duse.tomcat=true client
Buildfile: build.xml
Trying to override old definition of task apt

setup:

generate-client:

BUILD FAILED
C:wsit-jaxws-fromjavabuild.xml:192: You are running on JDK6 which comes with JAX-WS 2.1 API, but this tool requires JAX-WS 2.2 API. Use the endorsed standards override mechanism (http://java.sun.com/javase/6/docs/technotes/guides/standards/), or set xendorsed="true" on .

Total time: 0 seconds

As the message says it clearly, this problem is due to the JDK6 being shipped with older version of JAX-WS API. To make the tag use a override on this you need to add one more attribute xendorsed=”true” in the tag in Ant build.xml file.

Open the build.xml file and look for below tag





Now change this to add a new attribute as shown below.





Now run the “ant -Duse.tomcat=true client” command again, and this time it should generate all your client sources properly.

Issue #3 : Using the endorsed directory in JDK6

When I run the client using command “ant -Duse.tomcat=true run”, it gives me below error.

C:wsit-jaxws-fromjava>ant run
Buildfile: build.xml
Trying to override old definition of task apt

run:
[java] Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
[java]     at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
[java]     at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:898)
[java]     at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:666)
[java]     at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:420)
[java]     at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:254)
[java]     at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:661)
[java]     at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:649)
[java]     at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:343)
[java]     at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326)
[java]     at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:308)
[java]     at javax.xml.ws.Service.getPort(Service.java:92)
[java]     at fromjava.client.AddNumbersImplService.getAddNumbersImplPort(AddNumbersImplService.java:72)
[java]     at fromjava.client.AddNumbersClient.main(Unknown Source)
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 2 seconds

———–

The error message is due to client using older version of jaxws-ri which already bundled with the JDK6.
The annotation javax.xml.ws.WebFault in the rt.jar that ships with JDK1.6.0_X does not contain a messageName property
where as the javax.xml.ws.WebFault annotation that comes in the webservices-api.jar does contain this property.

To avoid this error you need to copy the endorsedwebservices-api.jar file to /jre/lib/endorsed directory

if /jre/lib/endorsed directory does not exist in your system create it and copy the webservices-api.jar file here.

For more details on endorsed directory read details at http://java.sun.com/javase/6/docs/technotes/guides/standards/

Now run the command “ant run” you should see the successful output.

C:Downloadswsit-jaxws-fromjavawsit-jaxws-fromjava>ant run
Buildfile: build.xml
Trying to override old definition of task apt

run:
[java] Invoking addNumbers(10, 20)
[java] The result of adding 10 and 20 is 30.
[java]
[java] Invoking addNumbers(-10, 20)
[java] Caught AddNumbersException_Exception: Numbers: -10, 20

BUILD SUCCESSFUL
Total time: 1 second

Let me know if you face any other issue while following steps.

Exit mobile version