通过CXF配置基于SSL的JAX-WS

时间:2010-09-08 07:31:54

标签: java ssl jax-ws cxf

嘿,我只有一些相关的问题。最近,生成客户端的外部SOAP接口已更改为https 1。我有一个旧的代码库,它通过cxf生成java文件,并且不安全,http://基于wsdl。我在uri和maven方面进行了测试,即使是测试通过也一切正常。但是当我在我的主要项目中使用这个罐子时,我得到了这个:

Caused by: java.lang.NoSuchMethodError: javax.net.ssl.HttpsURLConnection.getSSLSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
        at sun.net.www.protocol.https.DelegateHttpsURLConnection.getSSLSocketFactory(DelegateHttpsURLConnection.java:50)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
        at java.net.URL.openStream(URL.java:1010)
        at org.apache.cxf.resource.URIResolver.tryFileSystem(URIResolver.java:169)
        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:134)
        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.(WSDLServiceFactory.java:91)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:207)
        at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java:150)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
        at javax.xml.ws.Service.(Service.java:56)
        at generated.webservices.com.gbm.sso.ssoclient.AuthenticationServiceInternal.(AuthenticationServiceInternal.java:49)
        at com.gbm.caprice.sso.client.CachingSSOClient.init(CachingSSOClient.java:42)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1536)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
        ... 45 more

你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

由于您收到 NoSuchMethodError (由编译器捕获/抛出),我的建议是您使用的是Java类的版本(在本例中为javax.net.ssl.HttpsURLConnection )没有以下方法签名:

javax.net.ssl.HttpsURLConnection.getSSLSocketFactory()

这个类可以在JRE / lib jsse.jar中找到(从编写本文时开始,JDK 1.6.0_21)。确保在Java CLASSPATH中声明了您的Java库和Apache CXF库。

根据您的caused例外,我可以帮助您。