我通过netbeans从我的localhost做了一个宁静的服务,我选择glassfish 4.1.1作为我的网络服务器 然后我想测试它。 当它想给我一个xml响应时它正在工作但是当我试图得到一个JSON响应它给了我一个500 ERROR如下
GET RequestFailed RequestFailed --> Status: (500)
Response: {
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.ejb.EJBException
root cause
javax.ejb.EJBException
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Error Code: 0
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Error Code: 0
root cause
java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
root cause
java.net.ConnectException: Connection refused: connect
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.
GlassFish Server Open Source Edition 4.1.1
}
我在网上搜索并堆叠,看到它是因为eclipselink而发生的,所以我用eclipselink 2.6.3和2.6.1测试了它并重新安装了我的localhost但又出现了错误:
GET RequestFailed RequestFailed --> Status: (500)
Response: {
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
root cause
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
root cause
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.
GlassFish Server Open Source Edition 4.1.1
}
抱歉我的英语不好
非常感谢你为我的问题投入时间,即使只是阅读它。
答案 0 :(得分:1)
stacktrace显示代码失败,出现java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError:无法初始化类 org.eclipse.persistence.jaxb.BeanValidationHelper
确保运行时期间存在org.eclipse.persistence.jaxb.BeanValidationHelper类依赖性。
您可以阅读有关NoClassDefFoundError @ How to solve java.lang.NoClassDefFoundError?
的更多信息=============================================== ============================ 的更新强>
看起来GlassFish 4.1.1存在错误。 JIRA仍处于开放状态https://java.net/jira/browse/GLASSFISH-21440。泽西岛上还有一个JIRA https://java.net/jira/browse/JERSEY-2888。最后,他们为这个问题提供了一些解决方法。请使用该解决方法进行验证。
答案 1 :(得分:1)
使解决方案加粗明确,
记录到上面的答案,在这种情况下你只需要使用glassfish 4.1.1,只需安装glassfish 4.1并解决这个问题(因为解决4.1.1错误需要花费很长时间才能从我和我建议你不要试图解决它)