javac 找不到符号构造函数服务 [英] javac cannot find symbol constructor Service

查看:36
本文介绍了javac 找不到符号构造函数服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在借助这个Apache CXF Web 服务开发 一书,但是,唉,这本书的示例项目之一甚至无法编译!

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

有问题的代码是第 3 章的 contractfirst,这不是拼写错误,因为我使用的是从 本书的支持网站.

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 个编译错误实际上指向一个问题:

The 3 compilation errors point actually to a single 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);
^

在 OrderProcessService.java 文件中.

In the file OrderProcessService.java.

初始重新搜索表明这可能是一个JAX-WS 2.2 vs. 2.1 问题,但我不知道如何让这个基于 ANT 的编译环境支持"JAX-WS 2.2.

Initial research suggests that this may be a JAX-WS 2.2 vs. 2.1 issue but I have no idea how to make this ANT-based compilation environment "endorse" JAX-WS 2.2.

我尝试在 %JAVA_HOME%\lib\endorsed 中放置一个 jaxws-api.jar 并尝试将该 jar 添加到项目的库列表中,但似乎没有任何帮助.

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.

我没有使用 Maven,所以我什至不能将它列为依赖项,并希望这将是神奇地解决了.

I am not using Maven, so I can't even list it as a dependency and hope that this will be magically resolved.

知道如何解决这个问题吗?这样我就可以构建这个非常简单的项目?

Any idea how to solve this problem? So that I can make this very simple project build?

推荐答案

根据您的描述,这听起来与所描述的问题相似 在这篇文章中.

From your description this sounds similar to the problem described in this post.

要解决这个问题,您可以简单地将 jaxb-api.jarjaxws-api.jar 复制到 JDK 的 JRE 中/lib/endorsed

To get around this issue, You can simply copy jaxb-api.jar, jaxws-api.jar to JDK's JRE's /lib/endorsed

注意,endorsing"是指将相关的 JAR 文件(在本例中为 jaxb-api.jar,jaxws-api.jar)放在 %JAVA_HOME%\jre\lib\endorsed(注意路径中的 jre).不要直接在JDK的lib目录下创建endorsed目录.

Note that "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 not create the endorsed directory directly under the JDK's lib directory.

或者...如果您不想接触 JDK 安装,请使用这些 env vars 正在使用 wsimport 和 wsgen(其中 JAXWS_HOME 指向 JAX-WS 2.1 安装):

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):

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

或者...如果你使用 ant 任务,你可以在调用 wsimport 和 wsgen ant 任务时将 -Djava.endorsed.dirs=%JAXWS_HOME%/lib 作为 jvmarg 传递(为了这个工作,您需要设置 wsimport 和 wsgen 蚂蚁任务的 fork="true" 属性).

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).

归功于 Rama Pulavarthi.

这篇关于javac 找不到符号构造函数服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆