简体   繁体   中英

JAX-WS and wsimport, generated client stub causes exceptions

I'm generating a web service client stub using wsimport. After importing from a command line, I can see the generated code in Eclipse. I have no issues generating the code. The generated classes compiles fine, but when invoking any method from the generated stub it results in

java.lang.NullPointerException
at org.apache.xalan.transformer.TransformerIdentityImpl.setDocumentLocator(TransformerIdentityImpl.java:823)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader$State.<init>(DomLoader.java:78)
at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:113)
at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:55)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:449)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:427)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:275)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:209)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)`

By looking at the "unmarshaller" part of the error, I thought this probably had to do with version compatibility.

Clicking and inspecting the values of Service.GetPort() method shows me that the JAX-WS version used here is JAX-WS RI 2.1.3-b02- , while the command line (where I had initially run wsimport on) on wsimport -version returns version JAX-WS RI 2.1.6 in JDK 6.

Would a version difference cause this exception? Has anyone seen this exception before? How can I align the versions?

It turned out to be a mismatch between the java (JDK) version and xalan.jar (which was a jar referenced by the project). I was using JDK 6, and xalan jar was version 1.x. I downloaded the latest version of xalan.jar, and the issue disappeared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM