gpt4 book ai didi

java - HTTP 状态 500 - java.lang.NoClassDefFoundError : java/time/temporal/TemporalField when run app on OpenShift

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:24:40 24 4
gpt4 key购买 nike

我正在学习 RESTFUL Webservice,我正在免费的 OpenShift 主机上构建一个简单的应用程序

我在 OpenShift 上的服务器和数据库:jbossews-2.0 (Tomcat 7); postgresql-9.2 This is my Java build path This is my lib

当我在本地主机上测试时,我没有收到错误,但是当我在 OpenShift 主机上运行应用程序时,我在页面上看到:

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:我在我的 WEB-INF 库中将文件 postgresql-9.4.1208.jar(对于 jdk 8)更改为 prostgresql-9.4.1208.jre7.jar(对于 jdk 7),现在一切正常。非常感谢大家!玩得开心!!!

最佳答案

根据 Java docs time/temporal/TemporalField 是在 1.8 版中引入的

我创建了一个 Tomcat 7 (JBoss EWS 2.0) Cartridge 并检查了版本:

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

关于java - HTTP 状态 500 - java.lang.NoClassDefFoundError : java/time/temporal/TemporalField when run app on OpenShift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36008094/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com