cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Renuka Pathak <reshu...@gmail.com>
Subject NullPointerException when running java webservice client to consume secure webservice using CXF2.2.6\2.2.7
Date Fri, 02 Apr 2010 18:55:50 GMT
Hi CXF Team,

I am using CXF framework to consume a secure webservice. I created a java
client & facing problem in achieving this as there is an error when running
client code. Please find the issue detail as below. Please help me resolve
this issue.

*Issue*:

    I have written a java webservice client to consume a secure webservice
using CXF.  I instantiated the service class by passing wsdlURL &
serviceName to the constructor. Here wsdlURL is a "https" webservice url. I
also added code to provide security credentials to access this secure
webservice which comes after we instantiate the service class.  But my code
is failing with NullPointerException at the time of creation like
DsmlQueryService ss = new DsmlQueryService(wsdlURL,
SERVICE_NAME), before I provide authentication itself.

*Questions*:

1. Could you please let me know if anything is wrong in my client code which
is causing this error.  I have also found this JIRA issue CXF-2702 over the
internet (http://issues.apache.org/jira/browse/CXF-2702 ) which seems to
resolve similar kind of error. Is  CXF-2702  issue same as mine? Please let
me know If I should open a JIRA issue to track this. Any help in this regard
is much appreciated.

2. I generated java classes using wsdl file located in my machine & then
updated the url with actual remote webservice url location in client code.
Please let me know if it makes any difference in doing this way or providing
remote webservice url in the wsdl2Java command itself?

*Scenario\Steps: *

Here is the client code & error stacktrace in detail:

1. Generated classes using CXF (2.2.6\2.2.7)  wsdl2Java command  mentioned
below:

wsdl2java -p osc.enrollment.webserviceSFS.generated -exsh true -client -d
C:/development/WorkSpace/WebServiceSFS/src/main/java dsmlSoapQuery/wsdl

2. Generated java client is as follows.

public final class DsmlSoap_DsmlSoapQuery_Client {

    private static final QName SERVICE_NAME = new
QName("urn:oasis:names:tc:DSML:2:0:core", "dsmlQueryService");

    private DsmlSoap_DsmlSoapQuery_Client() {
    }

    public static void main(String args[]) throws Exception {
        URL wsdlURL = DsmlQueryService.WSDL_LOCATION;


        if (args.length > 0) {
            File wsdlFile = new File(args[0]);
            try {
                if (wsdlFile.exists()) {
                    wsdlURL = wsdlFile.toURI().toURL();
                } else {
                    wsdlURL = new URL(args[0]);
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        }

       * DsmlQueryService ss = new DsmlQueryService(wsdlURL,SERVICE_NAME);*

        DsmlSoap port = ss.getDsmlSoapQuery();

        setAuthParameter(port);

        DsmlSoap_DsmlSoapQuery_Client  dsmlClient = new
DsmlSoap_DsmlSoapQuery_Client();

        BatchRequest _directoryRequest_batchRequest=
dsmlClient.callSearchRequest();


main.java.gov.osc.enrollment.webserviceSFS.util.names.tc.dsml._2._0.core.BatchResponse
_directoryRequest__return =
port.directoryRequest(_directoryRequest_batchRequest);

        System.out.println("directoryRequest.result=" +
_directoryRequest__return);

        System.exit(0);
    }

3. Executed this client ( in eclipse IDE) as java application.
java.lang.NullPointerException error occurred. Its failing at the line "
DsmlQueryService ss = new DsmlQueryService(wsdlURL,SERVICE_NAME);".
 Following is the complete stack trace.

Invoking directoryRequest1..

Apr 2, 2010 10:00:21 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@47393f:
display name [org.apache.cxf.bus.spring.BusApplicationContext@47393f];
startup date [Fri Apr 02 10:00:21 EDT 2010]; root of context hierarchy
Apr 2, 2010 10:00:21 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
Apr 2, 2010 10:00:21 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
Apr 2, 2010 10:00:21 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider':
replacing [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
Apr 2, 2010 10:00:21 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory': replacing
[Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
with [Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in URL
[jar:file:/C:/development/apache-cxf-2.2.6/lib/cxf-2.2.6.jar!/META-INF/cxf/cxf-extension-http.fixml]]
Apr 2, 2010 10:00:21 AM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext@47393f]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@618d26
Apr 2, 2010 10:00:21 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@618d26:
defining beans
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.corba.CorbaBindingFactory,org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister#0,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.javascript.JavascriptQueryHandlerRegistry,org.apache.cxf.transport.local.LocalTransportFactory,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.management.InstrumentationManager,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.transport.jms.JMSTransportFactory,org.apache.cxf.binding.object.ObjectBindingFactory,org.apache.cxf.binding.http.HttpBindingFactory,org.apache.cxf.jaxrs.JAXRSBindingFactory,org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader,org.apache.cxf.ws.policy.AssertionBuilderRegistry,org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry,org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry,org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder,org.apache.cxf.ws.policy.PolicyBuilder,org.apache.cxf.ws.policy.PolicyEngine,org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider,org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider,org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder,org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMManager,org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMAssertionBuilder];
root of factory hierarchy
Apr 2, 2010 10:00:22 AM org.apache.cxf.transport.https.SSLUtils
getCiphersuites
INFO: The cipher suites have not been configured, falling back to cipher
suite filters.
Apr 2, 2010 10:00:22 AM org.apache.cxf.transport.https.SSLUtils
getCiphersuites
INFO: The cipher suite filters have not been configured, falling back to
default filters.
Apr 2, 2010 10:00:22 AM org.apache.cxf.transport.https.SSLUtils
getCiphersFromList
INFO: The cipher suites have been set to SSL_RSA_WITH_RC4_128_MD5,
SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA,
SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA,
SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_KRB5_WITH_RC4_128_SHA,
TLS_KRB5_WITH_RC4_128_MD5, TLS_KRB5_WITH_3DES_EDE_CBC_SHA,
TLS_KRB5_WITH_3DES_EDE_CBC_MD5, TLS_KRB5_WITH_DES_CBC_SHA,
TLS_KRB5_WITH_DES_CBC_MD5, TLS_KRB5_EXPORT_WITH_RC4_40_SHA,
TLS_KRB5_EXPORT_WITH_RC4_40_MD5, TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA,
TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5.
Apr 2, 2010 10:00:23 AM org.apache.cxf.transport.https.SSLUtils
getCiphersuites
INFO: The cipher suites have not been configured, falling back to cipher
suite filters.
Apr 2, 2010 10:00:23 AM org.apache.cxf.transport.https.SSLUtils
getCiphersuites
INFO: The cipher suite filters have not been configured, falling back to
default filters.
Apr 2, 2010 10:00:23 AM org.apache.cxf.transport.https.SSLUtils
getCiphersFromList
INFO: The cipher suites have been set to SSL_RSA_WITH_RC4_128_MD5,
SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA,
SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA,
SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA,
SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_KRB5_WITH_RC4_128_SHA,
TLS_KRB5_WITH_RC4_128_MD5, TLS_KRB5_WITH_3DES_EDE_CBC_SHA,
TLS_KRB5_WITH_3DES_EDE_CBC_MD5, TLS_KRB5_WITH_DES_CBC_SHA,
TLS_KRB5_WITH_DES_CBC_MD5, TLS_KRB5_EXPORT_WITH_RC4_40_SHA,
TLS_KRB5_EXPORT_WITH_RC4_40_MD5, TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA,
TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5.
Exception in thread "main" java.lang.NullPointerException
    at
org.apache.cxf.transport.http.CXFAuthenticator.getPasswordAuthentication(CXFAuthenticator.java:84)
    at
java.net.Authenticator.requestPasswordAuthentication(Authenticator.java:300)
    at
sun.net.www.protocol.http.HttpURLConnection$1.run(HttpURLConnection.java:280)
    at java.security.AccessController.doPrivileged(Native Method)
    at
sun.net.www.protocol.http.HttpURLConnection.privilegedRequestPasswordAuthentication(HttpURLConnection.java:276)
    at
sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(HttpURLConnection.java:1666)
    at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1091)
    at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
    at
org.apache.cxf.resource.URIResolver.tryFileSystem(URIResolver.java:163)
    at org.apache.cxf.resource.URIResolver.resolve(URIResolver.java:119)
    at
org.apache.cxf.resource.ExtendedURIResolver.resolve(ExtendedURIResolver.java:41)
    at
org.apache.cxf.transport.TransportURIResolver.resolve(TransportURIResolver.java:127)
    at
org.apache.cxf.catalog.CatalogWSDLLocator.getBaseInputSource(CatalogWSDLLocator.java:72)
    at
org.apache.cxf.wsdl11.AbstractWrapperWSDLLocator.getBaseInputSource(AbstractWrapperWSDLLocator.java:57)
    at
org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:214)
    at
org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:179)
    at
org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:91)
    at
org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:205)
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
    at
org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:65)
    at javax.xml.ws.Service.<init>(Service.java:57)
    at
main.java.gov.osc.enrollment.webserviceSFS.util.names.tc.dsml._2._0.core.DsmlQueryService.<init>(DsmlQueryService.java:48)
    at
main.java.gov.osc.enrollment.webserviceSFS.util.names.tc.dsml._2._0.core.DsmlSoap_DsmlSoapQuery_Client.main(DsmlSoap_DsmlSoapQuery_Client.java:82)


Thanks & Regards
Renuka

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message