2016-07-09 84 views
1

我從我的本地主機netbeans做了一個寧靜的服務,我選擇glassfish 4.1.1作爲我的網絡服務器 然後我想測試它。 它工作時,它想給我一個XML響應,但是當我試圖讓一個JSON響應它給了我一個500錯誤如下越來越json在Java休息服務

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 

} 

我搜索網頁和堆棧,並認爲它occursed因爲的EclipseLink所以我的EclipseLink 2.6.3和2.6.1進行了測試和重新安裝我的本地主機,但再次得到了錯誤:

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

堆棧跟蹤顯示,代碼與java.lang.NoClassDefFoundError

失敗

java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper

確保org.eclipse.persistence.jaxb.BeanValidationHelper類dependecy是運行時在座。

您可以閱讀更多有關的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。最後,他們爲這個問題提供了一些解決方法。請通過該解決方法進行驗證。

+0

在netbeanse寧靜項目我沒有web.pom 我應該如何發現它的作品? –

+0

看起來GlassFish 4.1.1存在一個錯誤。 JIRA仍然是OPEN https://java.net/jira/browse/GLASSFISH-21440。我已經更新了我的答案。希望你能夠使用https://java.net/jira/browse/JERSEY-2888中提到的工作。 –

+0

是的這是約4.1歲的bug在4.1.1 我改變我的glassfish到4.1,一切工作正常 謝謝你的時間 –

1

爲了使解決方案大膽而清晰,

記錄到上的答案,在這種情況下,所有你需要不使用的GlassFish 4.1.1,只需安裝GlassFish 4.1和這件事情解決了(因爲解決從我4.1.1錯誤花了很長時間,我建議你不要試圖解決它