Moim celem jest stworzenie klienta, serwis internetowy, który działa w osobnym słoiku z wszystkie zależności przy użyciu mvn montaż: pojedynczyapache cxf obciążenia klienta grzywny w Eclipse, ale samodzielny słoiku rzuca NullPointerException w WSDLServiceFactory
I generowane klienta za pomocą CXF Codegen wsdl2java, tworząc @WebServiceClient nazwie NetBanxAutostatementService
w zależności mam
<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>
rozpaczliwie próbowałem nawet dodać więcej "rzeczy"
<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>
Problem: za każdym razem próbuję uruchomić "java -jar target/Netbanx-0.0.1-SNAPSHOT-jar-z-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)
Dzieje się w linii, która wywołuje WebServiceClient autostatementService = new NetBanxAutostatementService (autostatement_wsdlLocation); wiem linią dziennika, że nie jestem przechodzącej autostatement_wsdlLocation za nieważną
kod 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);
}
Czy możemy też kod java? – thatidiotguy
NetBanxAutostatementService to klasa generowana przez CFX, którą mogę dodać również. Ten kod działa dobrze w środowisku Eclipse, więc myślę, że brakuje mi zależności do dodania do pliku JAR. Próbowałem już dodać konfigurację Spring cxf.xml, ale mam ten sam błąd. –
Hmm, naprawdę nie sądzę, że jest to problem z ładowaniem klasowym, ponieważ dałoby to wyjątek ClassNotFound, a nie wskaźnik zerowy. Widzę, że WSDLServiceFactory ma więcej niż jeden argument w swoich konstruktorach, ale nie mówi, że wygenerowałby wyjątek nullpointer na podstawie dokumentacji tutaj: http://cxf.apache.org/apidocs/org/apache/cxf/wsdl11 /WSDLServiceFactory.html. Spróbuj pobrać kod źródłowy i spojrzeć na 92 i zobaczyć, co go powoduje. Im z sugestii przepraszam. – thatidiotguy