简体   繁体   English

JavaToWS 错误:java.lang.AbstractMethodError 从类生成 Web 服务

[英]JavaToWS Error: java.lang.AbstractMethodError generating a webservice from classes

I'm trying to generate a wsdl file from Java classes using Eclipse Oxigen (Right Click on class -> WebService -> Create Web Service) , Java 8u152 runtime and Tomcat 7.我正在尝试使用 Eclipse Oxigen (右键单击类 -> WebService -> 创建 Web 服务) 、Java 8u152 运行时和 Tomcat 7 从 Java 类生成一个 wsdl 文件。

With the following settings:使用以下设置:

  • Web Service type: Bottom up Java Bean Web Service Service Web 服务类型:自下而上的 Java Bean Web 服务服务
  • Implementation: my concrete class实现:我的具体类
  • Slider:Develop service滑块:开发服务
  • Runtime: CXF 2.x运行时:CXF 2.x
  • SEI: my interface class SEI:我的接口类

I have fed Eclipse with the CXF 3.2.2 jar (the same happens with 2.2.9 and 2.3.1).我已经为 Eclipse 提供了 CXF 3.2.2 jar(2.2.9 和 2.3.1 也是如此)。

I get the following error:我收到以下错误:

JavaToWS Error: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V

java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
    at org.apache.cxf.helpers.DOMUtils.getDocumentBuilder(DOMUtils.java:108)
    at org.apache.cxf.helpers.DOMUtils.createDocument(DOMUtils.java:148)
    at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1181)
    at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1178)
    at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1139)
    at org.apache.cxf.tools.common.dom.ExtendedDocumentBuilder.parse(ExtendedDocumentBuilder.java:100)
    at org.apache.cxf.tools.common.toolspec.ToolSpec.<init>(ToolSpec.java:73)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:87)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
    at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:78)
    at org.apache.cxf.tools.java2ws.JavaToWS.main(JavaToWS.java:46)

And it does not generate anything but an unwanted cxf-beans.xml.除了不需要的 cxf-beans.xml 之外,它不会生成任何东西。

Am I missing something?我错过了什么吗?

It's possible exists a problem with "xml-apis" or "xmlParserAPIs" on the classpath类路径上的“xml-apis”或“xmlParserAPIs”可能存在问题

you due to verify your version for it has the method javax.xml.parsers.DocumentBuilderFactory.setFeature(String ) .您应该验证您的版本,因为它具有方法javax.xml.parsers.DocumentBuilderFactory.setFeature(String )

For example, the first version with method in xml-apis is 1.4.01比如xml-apis中第一个有method的版本是1.4.01

In my case the problem was caused by xerces jar which was included in the classpath.在我的例子中,问题是由类路径中包含的 xerces jar 引起的。 I searched for it in Dependency Hierarchy of pom.xml and I have removed the artifact for xerces jar.我在 pom.xml 的依赖层次结构中搜索了它,并且删除了 xerces jar 的工件。

<exclusion>
       <groupId>batik</groupId>
       <artifactId>xerces</artifactId>
 </exclusion>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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