java javac 找不到符号构造函数服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14131503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javac cannot find symbol constructor Service
提问by Eternal Learner
I am in the process of learning CXF with the help of this Apache CXF Web Service Developmentbook but, alas, one of the book's sample projects won't even compile!
我正在这本Apache CXF Web 服务开发书的帮助下学习 CXF,但是,唉,书中的一个示例项目甚至无法编译!
The code in question is Chapter 3's contractfirst
and it's not a typo problem because I am using the source code verbatim as downloaded from the book's support site.
有问题的代码是第 3 章的contractfirst
,这不是拼写错误,因为我使用的是从本书支持站点下载的源代码。
The 3 compilation errors point actually to a single problem:
这 3 个编译错误实际上指向一个问题:
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.
在文件 OrderProcessService.java 中。
Initial researchsuggests that this may be a JAX-WS 2.2 vs. 2.1issue but I have no idea how to make this ANT-based compilation environment "endorse" JAX-WS 2.2.
初步研究表明,这可能是JAX-WS 2.2 与 2.1 的问题,但我不知道如何使这个基于 ANT 的编译环境“支持”JAX-WS 2.2。
I tried placing a jaxws-api.jar
in %JAVA_HOME%\lib\endorsed
and I tried adding that jar to the project's libraries list but none seemed to help.
我试着放置jaxws-api.jar
在%JAVA_HOME%\lib\endorsed
和我尝试添加该JAR到项目的库列表中,但似乎没有提供帮助。
I am not using Maven, so I can't even list it as a dependency and hope that this will be magically resolved.
我没有使用Maven,所以我什至不能将它列为依赖项,并希望这能神奇地解决。
Any idea how to solve this problem? So that I can make this very simple project build?
知道如何解决这个问题吗?这样我就可以构建这个非常简单的项目?
回答by Withheld
From your description this sounds similar to the problem described in this post.
从你的描述,这听起来类似描述的问题在这个岗位。
To get around this issue, You can simply copy jaxb-api.jar
, jaxws-api.jar
to JDK's JRE's
/lib/endorsed
要解决此问题,您可以简单地将jaxb-api.jar
,复制jaxws-api.jar
到 JDK 的 JRE 中
/lib/endorsed
Notethat "endorsing" means placing the relevant JAR files (jaxb-api.jar, jaxws-api.jar in this case) in %JAVA_HOME%\jre\lib\endorsed
(note the jre
in the path). Do notcreate the endorseddirectory directly under the JDK's libdirectory.
请注意,“背书”意味着将相关的 JAR 文件(在本例中为 jaxb-api.jar、jaxws-api.jar)放入%JAVA_HOME%\jre\lib\endorsed
(注意jre
路径中的 )。千万不能创建赞同直接JDK的目录下的lib目录。
or... if you prefer not to touch your JDK install, use these env vars is using wsimport and wsgen (where JAXWS_HOME points to JAX-WS 2.1 installation):
或者...如果您不想接触 JDK 安装,请使用这些 env vars 正在使用 wsimport 和 wsgen(其中 JAXWS_HOME 指向 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 while calling wsimport and wsgen ant tasks (for this to work, you need to set fork="true" attribute of wsimport and wsgen ant tasks).
或者...如果您使用 ant 任务,则可以-Djava.endorsed.dirs=%JAXWS_HOME%/lib
在调用 wsimport 和 wsgen ant 任务时作为 jvmarg传递(为此,您需要设置 wsimport 和 wsgen ant 任务的 fork="true" 属性)。
Credit goes to Rama Pulavarthi.
幸得拉玛Pulavarthi。
回答by Daniel Kulp
Endorsing the 2.2 version of the jaxws-api jar should work. You could also pass the "-fe jaxws21" flag to the CXF wsdl2java command to make it generate 2.1 compatible code instead.
支持 jaxws-api jar 的 2.2 版本应该可以工作。您还可以将“-fe jaxws21”标志传递给 CXF wsdl2java 命令,以使其生成 2.1 兼容代码。
回答by Manjunath D R
Adding webservices-api-2.2.jaralone in %JAVA_HOME%\jre\lib\endorsedhas resolved issue for me.
在%JAVA_HOME%\jre\lib\endorsed 中单独添加webservices-api-2.2.jar为我解决了问题。