Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Initialize the web service

2009-05-14
2014-05-24
  • daniel zhou
    daniel zhou
    2009-05-14

    Code:
    ---------------------------------------------------------------------------------
             /**
         * Initialize the web service
         *
         * @throws MalformedURLException
         */
        public void WSInitialize() throws MalformedURLException {
            CertTools.installBCProvider();
            String urlstr = "https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl";

            System.setProperty("javax.net.ssl.trustStore", "p12/wstest.jks");
            System.setProperty("javax.net.ssl.trustStorePassword", "foo123");

            System.setProperty("javax.net.ssl.keyStore", "p12/wstest.jks");
            System.setProperty("javax.net.ssl.keyStorePassword", "foo123");

            QName qname = new QName("http://ws.protocol.core.ejbca.org/",
                    "EjbcaWSService");
            EjbcaWSService service = new EjbcaWSService(new URL(urlstr), qname);
            ejbcaraws = service.getEjbcaWSPort();
        }
    ---------------------------------------------------------------------------------------
    Exception:
    -----------------------------------------------------------------------------------------
    javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl. It failed with:
        java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl).
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:136)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:122)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:226)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:189)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:159)
        at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:81)
        at javax.xml.ws.Service.<init>(Service.java:56)
        at org.ejbca.core.protocol.ws.client.gen.EjbcaWSService.<init>(EjbcaWSService.java:36)
        at WS.WebServiceDemo.WSInitialize(WebServiceDemo.java:54)
        at WS.WebServiceDemo.main(WebServiceDemo.java:65)
    Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
        at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:179)
        at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:199)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:365)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:977)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
        at java.net.URL.openStream(URL.java:1009)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:785)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:236)
        at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:107)
        ... 8 more
    ------------------------------------------------------------------------------------------

    "java.security.NoSuchAlgorithmException", How to deal with it?

    Regards,
    daniel

     
    • Using JDK6? Do you have unlimited strength crypto policy installed?

       
      • liwf
        liwf
        2014-05-24

        I met the same problem, don't know how to solve it, can give me some advice.How to create the /wstest.jks?

         
    • daniel zhou
      daniel zhou
      2009-05-14

      Yes, I have copy the two jar files of “jce_policy-6.zip” to $JDK_HOME/JRE/lib/security and $JRE_HOME/lib/security, and i have used eight chars as new user password, and get certificate successfully.

      /Daniel