Javac cannot find Service character constructor

I am learning CXF with this Apache CXF Web Service Development , but alas, one of the book sample projects won't even compile!

This code refers to chapter 3 of contractfirst , and this is not a typo problem, because I use the source code verbatim from the book support site .

3 compilation errors point to one problem:

 Chapter3\contractfirst\src\demo\order\OrderProcessService.java:52: cannot find symbol symbol: constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[]) location: class javax.xml.ws.Service super(WSDL_LOCATION, SERVICE, features); ^ 

In the file OrderProcessService.java.

The initial re search suggests that it might be JAX-WS 2.2 vs. 2.1 , but I don’t know how to make this compilation environment based on ANT “approve” JAX-WS 2.2.

I tried to put jaxws-api.jar in %JAVA_HOME%\lib\endorsed , and I tried to add this jar to the list of project libraries, but none of them helped.

I do not use Maven , so I can’t even list it as a dependency, and I hope that it will be magically resolved.

Any ideas how to solve this problem? So what can I do this very simple project build?

+8
java jax-ws ant cxf
source share
3 answers

From your description, this seems like the problem described in this post .

To get around this problem, you can simply copy jaxb-api.jar , jaxws-api.jar into the JDK JRE /lib/endorsed

Note that “approving” means placing the corresponding JAR files (jaxb-api.jar, jaxws-api.jar in this case) in %JAVA_HOME%\jre\lib\endorsed (note the jre on the way). Do not create a support directory in the JDK lib directory.

or ... if you prefer not to touch the JDK installation, use these env vars using wsimport and wsgen (where JAXWS_HOME indicates the installation of JAX-WS 2.1):

 WSIMPORT_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib WSGEN_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib 

or ... If you use ant tasks, you can pass -Djava.endorsed.dirs=%JAXWS_HOME%/lib as jvmarg when invoking wsimport and wsgen ant tasks (for this you need to set the fork = "true" wsimport and wsgen ant attribute )

The loan goes to Rama Pulawarty .

+14
source share

Approval version 2.2 of jaxws-api jar should work. You can also pass the "-fe jaxws21" flag to the CXF wsdl2java command to generate 2.1 compatible code instead.

0
source share

Adding webservices-api-2.2.jar only in % JAVA_HOME% \ jre \ lib \ endorsed solved the problem for me.

0
source share

All Articles