Il mio obiettivo è quello di creare un client Web Service che viene eseguito in un vaso autonomo con tutte le dipendenze con il montaggio mvn: singleApache CXF client carica sottili in Eclipse, ma vaso standalone getta NullPointerException in WSDLServiceFactory
ho generato il client utilizzando CXF Codegen WSDL2Java, creando un @WebServiceClient chiamato NetBanxAutostatementService
per le dipendenze ho
<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>
disperatamente ho anche cercato di aggiungere più "roba"
<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>
Il problema: ogni volta che tenta di eseguire "java -jar bersaglio/Netbanx-0.0.1-SNAPSHOT-jar-con-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)
Questo accade nella linea che invoca the WebServiceClient autostatementService = new NetBanxAutostatementService (autostatement_wsdlLocation); So dalla linea di registro che non sto passando autostatement_wsdlLocation nullo
codice 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);
}
Possiamo anche il codice Java? – thatidiotguy
NetBanxAutostatementService è una classe generata da CFX Posso anche aggiungerla. Questo codice funziona perfettamente con Eclipse, quindi credo che manchi qualche dipendenza da aggiungere al file JAR. Ho già provato ad aggiungere la configurazione di cxf.xml Spring ma ho ottenuto lo stesso errore. –
Hmm, davvero non penso che sia un problema di caricamento di classe, perché questo ti darebbe un'eccezione ClassNotFound, non un puntatore nullo. Vedo che WSDLServiceFactory ha più di un argomento nei suoi costruttori, ma non dice che genererebbe un'eccezione nullpointer basata sulla documentazione qui: http://cxf.apache.org/apidocs/org/apache/cxf/wsdl11 /WSDLServiceFactory.html. Prova a scaricare il codice sorgente e guarda come 92 e vedere cosa lo causa. Sono fuori dai suggerimenti scusa. – thatidiotguy