【问题标题】:Apache CXF - Null Pointer Exception in WSDLServiceFactoryApache CXF - WSDLServiceFactory 中的空指针异常
【发布时间】: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下

谁能帮帮我?

【问题讨论】:

    标签: java apache cxf


    【解决方案1】:

    &lt;wsdlOption&gt;标签之间添加这两个标签:

     <wsdl>src/main/resources/Otello.wsdl</wsdl> 
     <wsdlLocation>classpath:Otello.wsdl</wsdlLocation>
    

    &lt;wsdl&gt; 标签中,您需要提供相对于项目目录的路径。

    【讨论】:

    • 我试过了,但我总是有同样的错误......如果帮助我使用版本 3.2.6 的 cxf
    • 进行更新并添加您的目录结构(带有 WSDL 位置),可能会有所帮助。
    • wdsl 文件位于 src/main/resources 下。 wsdl 实现是自动生成的,放在 target/generated-sources/cxf
    • 服务内部用来访问wsdl的url如下jar:file:/var/www/html/Clienti/TruckOne/TruckOneSender/target/TruckOneSender-1.0-jar-with- dependencies.jar!/Otello.wsdl
    猜你喜欢
    • 1970-01-01
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    • 2015-07-12
    相关资源
    最近更新 更多