14

I am told that Java 7 is supposed to include JAX-WS such that I don't need libraries like those in Apache CXF. However, the official docs say:

This release contains Java API for XML Processing (JAXP) 1.4.5, supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports Java API for XML Web Services (JAX-WS) 2.2.4.

Further, the Eclipse page on JAX-WS speaks of using implementations such as Apache CXF, Sun Metro, or Apache Axis. And every example/tutorial I can find on JAX-WS uses a library set like CXF or Metro.

I have a project in Eclipse that calls "Endpoint.publish(...)" on a class with a javax.jws.WebService annotation. The WSDL file referenced below resides outside Eclipse. This project runs (as a "Java Application") fine with the Apache CXF libraries includes. As soon as I remove them (and Eclipse references to Apache CXF), it crashes with the following exception:

com.sun.xml.internal.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(http://localhost:8081/wsdl/csw.wsdl)
    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:313)

So either I'm doing something wrong or Apache is supplying implementations of things to which the JDK itself only has APIs. Please point out which is the case, along with the usual link to something relevant.

kuloch
  • 319
  • 1
  • 3
  • 10

1 Answers1

12

Jdk 7 (like 6) includes a metro based implementation.

As you can see from your exception, the internal implementation is running "com.sun.xml.internal.ws.transport.http.server.EndpointImpl". The problem seems to be that it doesn't like your WsdlLocation (i believe jaxws is expecting a local resource, but you have given it a http resource).

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • Thanks for the details. You're right that I do get past that exception if I put the WSDL file in my classpath. Unfortunately, I'm now back to an exception that I only dealt with before because CXF was using its own JAXB library. The current version of JAXB is 2.2.4, which throws a NullPointerException. When I replaced CXF's jaxb-impl*.jar with the 2.2.3 version, that fixed it. But I can't find the system jaxb-impl, and putting 2.2.3 on the classpath doesn't fix it. – kuloch Feb 02 '12 at 18:13
  • 1
    @kuloch - you need to use the endorsed override mechanism to use a newer jaxb or jaxws implementation, see http://docs.oracle.com/javase/6/docs/technotes/guides/standards/ . related advice here http://weblogs.java.net/blog/ramapulavarthi/archive/2007/01/problems_using.html – jtahlborn Feb 02 '12 at 18:35
  • Thanks. We came across that before I saw your post, and the service is running again - this time on (presumably) Metro. – kuloch Feb 02 '12 at 20:13
  • 1
    @jtahlborn AFAIK, "Jdk 7 (like 6) includes the metro implementation." is not entirely correct. JDK 6+ does include JAX-WS RI (reference implementation), but Metro is a superset of JAX-WS RI, i.e. Metro = JAX-WS RI + WSIT. – Miljen Mikic Apr 27 '13 at 14:24
  • 1
    @MiljenMikic Is it possible to setup JAX-WS on tomcat just using RI? I tired but failed so used Metro. – John Eipe Aug 07 '14 at 07:50
  • 1
    @John Have you tried mkyong's tutorial? (http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat). It gives nice, step-by-step cookbook how to setup JAX-WS on Tomcat. – Miljen Mikic Aug 08 '14 at 13:37
  • mkyongs tutorial explains using metro. My question is - is it possible to set up jax-ws on tomcat just using RI? Now this question is based on my understanding that RI is part of JDK, metro is not. – John Eipe Aug 08 '14 at 13:48
  • @John If you haven't already, you should probably ask your question as a separate thread. I'm pretty confident that you can create a WAR that uses JAX-WS and runs in Tomcat. You will need to at least link in the javax.servlet-api-.jar at compile time, as the container (e.g. Tomcat) will provide the API and an implementation at runtime. You'll also need to have a [web.xml](http://en.wikipedia.org/wiki/WAR_(file_format)) that instructs the container to use JAX-WS and probably your classes. – kuloch Nov 11 '14 at 16:39