Клиент Apache CXF нормально загружается в Eclipse, но отдельный jar бросает NullpointerException в WSDLServiceFactory

Моя цель - создать клиент веб-сервиса, который запускается в отдельном jar со всеми зависимостями с помощью mvn assembly:single

Я сгенерировал клиент с помощью CXF codegen wsdl2java, создав @WebServiceClient под названием NetBanxAutostatementService

Для зависимостей, которые у меня есть

<cxf.version>2.5.2</cxf.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
        <scope>runtime</scope>
    </dependency>

Отчаянно я даже пытался добавить больше "вещей"

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
        <version>2.5.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf</artifactId>
        <version>2.5.2</version>
        <type>pom</type>
        <scope>runtime</scope>
    </dependency>

Проблема: каждый раз, когда я пытаюсь запустить "java -jar target/Netbanx-0. 0.1-SNAPSHOT-jar-with-dependencies.jar"

INFO [main] (Netbanx.java:97) - autostatement_wsdlLocation:https://www.test.netbanx.com/cgi-bin/autostatement_wsdl
Exception in thread "main" java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:91)
at javax.xml.ws.Service.<init>(Service.java:56)
at com.netbanx.autostatement.NetBanxAutostatementService.<init>  (NetBanxAutostatementService.java:39)
at my.project.netbanx.Netbanx.<init>(Netbanx.java:98)
at my.project.netbanx.Netbanx.main(Netbanx.java:130)

Это происходит в строке, которая вызывает WebServiceClient autostatementService = new NetBanxAutostatementService(autostatement_wsdlLocation); Я знаю по логу, что я не передаю autostatement_wsdlLocation как null

Java код:

URL autostatement_wsdlLocation = null;
URL payment_wsdlLocation = null;
try {
    autostatement_wsdlLocation = new URL(properties.getProperty("autostatement_wsdlLocation"));
    payment_wsdlLocation = new URL(properties.getProperty("payment_wsdlLocation"));
} catch (MalformedURLException e) {
    logger.error("MalformedURLException",e);
}

    /**
     * Load the Netbanx's webservices AutostatementService and PaymentService
     */
try {           
    logger.info("autostatement_wsdlLocation:"+autostatement_wsdlLocation.toString());
    autostatementService = new NetBanxAutostatementService(autostatement_wsdlLocation); //it is here I get the NullPointerException error
    logger.info("payment_wsdlLocation:"+payment_wsdlLocation.toString());
    paymentService = new NetBanxPaymentService(payment_wsdlLocation);
webServiceStarted = true;
    } catch(javax.xml.ws.WebServiceException wsException ){
        String error = "Cannot create NetBanx web service please make sure this host can reach:" + autostatement_wsdlLocation +" and " + payment_wsdlLocation;
        logger.error(error);
        logger.error("WebServiceException",wsException);

}

16
задан André Ricardo 30 January 2012 в 19:08
поделиться