问题
I have a wsdl file for the Web service. I want to test the interaction between the client and the server. To do this, I run the mock server with embedded grizzly.
The question about of implementing mock server. I generated an interface from wsdl (and xsd) using the wsimport and wrote implementation. When run on the grizzly, I get the following error:
com.sun.xml.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(META-INF/wsdl/test.wsdl)
I run a web service with this code:
HttpHandler httpHandler = new JaxwsHandler(new TestImpl());
server.getServerConfiguration().addHttpHandler(httpHandler, "/test");
The problem is that Grizzly can not find wsdl and xsd files. In embedded glassfish its work.
EDIT1
I change wsdlLocation to "test.wsdl" and its work. But now grizzly say:
java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
EDIT2
If use JDK1.7 it works. But I need a JDK 1.6
回答1:
I'm not sure why you're seeing that error. I can run the Grizzly jaxws example and obtain the wsdl using either 1.6 or 1.7.
I would recommend reviewing the source1 of the example and compare to what you have.
回答2:
I'm change the jdk6 to jdk7 and works fine! Don't forget to change the JAVA_HOME and the default JDK of Netbeans as related here: How to set the JDK Netbeans runs on?
回答3:
Your version of Grizzly expects a JAX-WS 2.2 API while JDK 1.6 ships with JAX-WS 2.1. As others mentioned, some of these files need to be installed into an endorsed directory. You can download the required files here or take them from your Grizzly installation. The download includes an Ant build file that provides a build target to install the files into the JDK endorsed directory. You can run it with ant install-api
. If you cannot run Ant, you may install them manually:
cp lib/jaxb-api.jar $JAVA_HOME/lib/endorsed
cp lib/jaxws-api.jar $JAVA_HOME/lib/endorsed
Do not install other files from the JAX-WS distribution into the endorsed directory unless you want to create some really difficult to debug bugs for yourself.
I am suggesting to use the endorsed directory in $JAVA_HOME/lib/endorsed because that will work with most tools and applications without any additional changes. Others already suggested more targeted changes, such as setting an endorsed directory during a Maven build or copying the files into a Tomcat endorsed directory. All these approaches are fine as long as you can make sure that your code is picking up the right endorsed directory.
回答4:
As a result, we had to use endorsed mechanism. Documentation
回答5:
create a folder called endorsed and put these jar files in it 1.jaxb-api-2.2.jar 2.jaxws-api.jar put the folder in tomcat server as C:\tomcat-7.50\< created folder> and run it will works
回答6:
Changing JDK from 1.6 to 1.7 worked for me.
来源:https://stackoverflow.com/questions/13356479/grizzly-java-lang-nosuchmethoderror-javax-xml-ws-webfault-messagename