2016-03-15 90 views
6

我瞭解RESTful Web服務上運行應用程序時/時間/ TemporalField,我建立一個簡單的OpenShiftHTTP狀態500 - java.lang.NoClassDefFoundError:JAVA /時間OpenShift

的免費主機

在App我OpenShift上的服務器和數據庫:jbossews-2.0(Tomcat 7); PostgreSQL的-9.2 This is my lib

當我在本地主機測試我不明白的錯誤,但是當我運行OpenShift主機應用程序I在頁面上看到:

HTTP Status 500 - java.lang.NoClassDefFoundError: java/time/temporal/TemporalField 

type Exception report 

message java.lang.NoClassDefFoundError: java/time/temporal/TemporalField 

description The server encountered an internal error that prevented it from fulfilling this request. 

exception 

javax.servlet.ServletException: java.lang.NoClassDefFoundError: java/time/temporal/TemporalField 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

root cause 

java.lang.NoClassDefFoundError: java/time/temporal/TemporalField 
    org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:320) 
    org.postgresql.Driver.makeConnection(Driver.java:406) 
    org.postgresql.Driver.connect(Driver.java:274) 
    java.sql.DriverManager.getConnection(DriverManager.java:571) 
    java.sql.DriverManager.getConnection(DriverManager.java:215) 
    service.TestService.main(TestService.java:126) 
    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$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    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.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:1542) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

root cause 

java.lang.ClassNotFoundException: java.time.temporal.TemporalField 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) 
    org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:320) 
    org.postgresql.Driver.makeConnection(Driver.java:406) 
    org.postgresql.Driver.connect(Driver.java:274) 
    java.sql.DriverManager.getConnection(DriverManager.java:571) 
    java.sql.DriverManager.getConnection(DriverManager.java:215) 
    service.TestService.main(TestService.java:126) 
    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$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) 
    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.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:1542) 
    com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) 
    com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) 
    com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) 
    com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 

PS:我改變文件postgresql-9.4.1208.jar(用於jdk 8)到我的WEB-INF庫中的prostgresql-9.4.1208.jre7.jar(用於jdk 7),現在一切正常。 非常感謝大家!玩的很開心 !!!

+0

您使用哪種jboss墨盒? –

+1

'java.time.temporal.TemporalField'僅在Java 1.8以後才存在。 – Berger

回答

3

根據Java docstime/temporal/TemporalField已於版本1.8

介紹我創建一個Tomcat 7(JBoss的EWS 2.0)的墨盒並檢查版本:

$ ssh $MY_APP 
$ java -version 
java version "1.7.0_95" 
+0

是的,我也這麼認爲。但我無法找到問題的解決方案:((( – TearsRiver

+0

完成,感謝您的幫助;) – TearsRiver

0

更改爲9.4.1208.jre7解決了我問題,似乎他們編譯爲jdk8

0

在我的情況下(SLES 11.3上的Tomcat 8),事實證明,雖然我已經安裝了Java 8 SDK而不卸載Java 7,並相應地設置了JAVA_HOME,但JRE_HOME是s直到指向我的Java 7安裝。解決這個問題。

相關問題