Mi objetivo es crear un cliente de servicios Web que se ejecuta en un frasco independiente con todas las dependencias utilizando el montaje mvn: solacargas cliente Apache CXF finas en Eclipse, pero frasco independiente NullPointerException en WSDLServiceFactory
me genera el cliente utilizando CXF wsdl2java CODEGEN, creando un @WebServiceClient llamada NetBanxAutostatementService
para las dependencias que tengo
<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>
desesperadamente incluso intentado añadir más "cosas"
<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>
El problema: cada vez que intento ejecutar "java-jar de destino/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)
Esto sucede en la línea que llama WebServiceClient autostatementService = new NetBanxAutostatementService (autostatement_wsdlLocation); sé por la línea de registro que no estoy pasando autostatement_wsdlLocation como nulo
código 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);
}
¿Podríamos el código de Java también? – thatidiotguy
NetBanxAutostatementService es una clase generada por CFX. Puedo agregarla también. Este código funciona bien en Eclipse, así que supongo que me falta algo de dependencia para agregarlo al archivo JAR. Ya intenté agregar la configuración cxf.xml Spring, pero obtuve el mismo error. –
Hmm, realmente no creo que sea un problema de carga de clases, porque eso le daría una excepción ClassNotFound, no un puntero nulo. Veo que WSDLServiceFactory tiene más de un argumento en sus constructores, pero no dice que lanzarían una excepción nullpointer basada en la documentación aquí: http://cxf.apache.org/apidocs/org/apache/cxf/wsdl11 /WSDLServiceFactory.html. Intente descargar el código fuente y mire 92 y vea qué lo causa. Im de sugerencias lo siento. – thatidiotguy