2016-05-20 6 views
0

Ich versuche, auf OpenShift mit Tomcat 7 eine sehr einfache Reihe von Ruhe-Endpunkten auszuführen. Mein Code führt einen sehr einfachen HTTPUrlConnection-Test aus, der eine Ausnahme auslöst.Openshift, Tomcat 7, HTTPUrlConnection, javax.crypto.JceSecurity nicht gefunden

-Code ist dieser Grund:

@GET 
@Path("/basicTest") 
public Response basicTest(@QueryParam("hostName") String hostName) { 
    StringBuilder builder = new StringBuilder(); 
    Response response = null; 

    try{ 
     URL urlObject = new URL(hostName); 
     HttpURLConnection connection = (HttpURLConnection)urlObject.openConnection(); 
     BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 

     String inputLine; 

     while ((inputLine = in.readLine()) != null) 
      builder.append(inputLine); 
     in.close(); 

     response = Response.status(200).entity(builder.toString()).build(); 
    } catch(Exception e){ 
     response = Response.status(200).entity(e.getMessage()).build(); 
    } 

    return response; 
} 

Dies läuft nur lokal fein in Eclipse läuft Tomcat 7 und Java 7 auf meinem Mac entweder eine HTTP- oder HTTPS-URL. Gegen Openshift HTTP funktioniert, aber HTTPS ich diesen Fehler:

java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.JceSecurity 
javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:178) 
sun.security.ssl.JsseJce.getKeyAgreement(JsseJce.java:285) 
sun.security.ssl.JsseJce.isEcAvailable(JsseJce.java:198) 
sun.security.ssl.CipherSuite$KeyExchange.isAvailable(CipherSuite.java:376) 
sun.security.ssl.CipherSuite.isAvailable(CipherSuite.java:194) 
sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:338) 
sun.security.ssl.SSLContextImpl.getDefaultCipherSuiteList(SSLContextImpl.java:296) 
sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:595) 
sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:530) 
sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:73) 
sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:405) 
sun.net.NetworkClient.doConnect(NetworkClient.java:162) 
sun.net.www.http.HttpClient.openServer(HttpClient.java:432) 
sun.net.www.http.HttpClient.openServer(HttpClient.java:527) 
sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264) 
sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367) 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:934) 
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1302) 
sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) 
jim.controller.UberController.basicTest(UberController.java:69) 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
java.lang.reflect.Method.invoke(Method.java:606) 
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) 
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) 
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511) 
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442) 
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391) 
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381) 
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) 
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538) 
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
jim.servlet.RequestFilter.doFilter(RequestFilter.java:28) 

Ich habe auch einen Testendpunkt die mit allen von Openshift Systemeigenschaften Dumps.

http://www.jimflath.com/APITest/rest/jvmStat/details

+0

Ich habe das gleiche Problem –

+1

Ich bin mir nicht sicher, wie, aber mein Problem zufällig aufgeklärt, nachdem ich gestoppt/gestartet die Anwendung. – jimflath

+0

Ich habe gehört, dass es mit einer beschädigten Java-Installation verbunden ist, so dass es –

Antwort

0

Ich traf die gleiche Problem auf meine Verbindungen von http Ändern https arbeitet lokal in Ordnung, aber auf Openshift alle Antwort für das Erstellen eines Kontos (E-Mail-Bestätigungsmail Pistole) ist fehlgeschlagen richtige Antwort auf Benutzer zu machen:

java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.JceSecurity 
    javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:179) 
    sun.security.ssl.JsseJce.getKeyAgreement(JsseJce.java:286) 
    sun.security.ssl.JsseJce.isEcAvailable(JsseJce.java:199) 
    sun.security.ssl.CipherSuite$KeyExchange.isAvailable(CipherSuite.java:376) 
    sun.security.ssl.CipherSuite.isAvailable(CipherSuite.java:194) 
    sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:338) 
    sun.security.ssl.SSLContextImpl.getDefaultCipherSuiteList(SSLContextImpl.java:296) 
    sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:593) 
    sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:557) 
    sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:109) 
    com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:361) 
    com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236) 
    com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2020) 
    com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697) 
    javax.mail.Service.connect(Service.java:364) 
    javax.mail.Service.connect(Service.java:245) 
    com.cvs.util.SendMail.sendAccountConfirmation(SendMail.java:54) 
    com.cvs.controller.SignUp.doPost(SignUp.java:121) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

checkte ich ein paar Lösungen, die sie alle auf korrupten Java-Installation, meine Schlussfolgerung rein war wegen Hot deploy, Neustart der Anwendung löste das Problem.