简体   繁体   English

找不到SOAPConnectionFactory的类定义

[英]No class def found for SOAPConnectionFactory

I am re-building an application from Java 8 in Java 9 (jdk 9.0.4), using modules. 我正在使用模块在Java 9(jdk 9.0.4)中从Java 8重建应用程序。 One of these modules requires making SOAP calls to our server to check if various services are running, and then reports back the status of those services via email. 这些模块之一需要对我们的服务器进行SOAP调用,以检查各种服务是否正在运行,然后通过电子邮件报告这些服务的状态。

I understand that the SOAP libraries have been deprecated in Java 9 but not removed yet. 我了解SOAP库在Java 9中已被弃用,但尚未删除。 I have the java.xml.ws module declared as a requirement in the appropriate module-info: 我在适当的module-info中将java.xml.ws模块声明为要求:

module services {
    exports com.nams.hyperion.services;

    requires configurations;
    requires java.xml.ws;
}

It compiles, but I get an error when I try running the project: java.lang.NoClassDefFoundError: javax/xml/soap/SOAPConnectionFactory 它可以编译,但是尝试运行该项目时出现错误: java.lang.NoClassDefFoundError: javax/xml/soap/SOAPConnectionFactory

scf = SOAPConnectionFactory.newInstance(); <-- error here
conn = scf.createConnection();
mf = MessageFactory.newInstance();
msg = mf.createMessage();

I tried using the --add-modules java.xml.ws compiler option, but that doesn't resolve the problem; 我尝试使用--add-modules java.xml.ws编译器选项,但这不能解决问题。 does my Java installation not have this module? 我的Java安装没有此模块吗? What are my options? 我有什么选择? I've mucked around maven a bit looking for a separate distribution but haven't found anything yet. 我已经在Maven周围摸索了一下,寻找单独的发行版,但还没有找到任何东西。

I found a Maven distribution that I could use: https://search.maven.org/artifact/com.sun.xml.ws/rt-jdk9/2.3.0/jar 我找到了可以使用的Maven发行版: https : //search.maven.org/artifact/com.sun.xml.ws/rt-jdk9/2.3.0/jar

However, the module-info file gives me a warning that my module reads java.xml.ws from 2 identically named sources; 但是,module-info文件向我发出警告,提示我的模块从2个名称相同的源中读取java.xml.ws but the project runs, which is all that matters to me at the moment. 但是项目运行了,这对我来说现在很重要。 I'll work out how to deal with the ambiguity later and update this answer if I manage to do it. 稍后,我将解决如何处理歧义,如果可以,请更新此答案。

Update: I solved the ambiguity by removing the jar file from the module's dependencies, but retaining it in Maven's dependencies list. 更新:通过从模块的依赖项中删除jar文件,但将其保留在Maven的依赖项列表中,我解决了歧义。

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

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