【发布时间】:2019-03-19 20:54:09
【问题描述】:
当我执行一个 jar 时,我收到了这个错误:
java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:218)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
at it.finanze.dogane.domest.otello.accesspoint.wsdl.Otello_Service.<init>(Otello_Service.java:44)
at it.sknt.truckonesender.App.main(App.java:70)
在生成的服务类中我有:
@WebServiceClient(name = "Otello",
wsdlLocation = "classpath:Otello.wsdl",
targetNamespace = "http://accessPoint.otello.domest.dogane.finanze.it/wsdl/")
公共类 Otello_Service 扩展服务 {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://accessPoint.otello.domest.dogane.finanze.it/wsdl/", "Otello");
public final static QName Otello = new QName("http://accessPoint.otello.domest.dogane.finanze.it/wsdl/", "Otello");
static {
URL url = Otello_Service.class.getClassLoader().getResource("Otello.wsdl");
if (url == null) {
java.util.logging.Logger.getLogger(Otello_Service.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "classpath:Otello.wsdl");
}
WSDL_LOCATION = url;
} .....
在我的 POM 文件中:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.6</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>classpath:Otello.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
这些是添加到项目中的 cxf 包
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.6</version>
</dependency>
如果我从 netbeans 执行程序,一切正常。
wdsl 文件位于 src/main/resources 下。 wsdl实现是自动生成的,放在target/generated-sources/cxf下
谁能帮帮我?
【问题讨论】: