我在我的亚马逊 ec2 上运行 glassfish 3.1.2.2 实例,我在 jax-rs 中有一个网络应用程序“KowricService”网络服务,我最近在 java derby 中的表用户中添加了一些列(Facebook_id、LinkedIn_id、Twitter_id、Gmail_id)后端,在此之前我的应用程序运行良好,没有错误。我现在注意到,当我部署我的war文件时,我的glassfish管理员上出现ConnectionException错误,这通常在数据库未运行时发生,同时我的数据库正在运行,我注意到每次部署它都会导致错误并关闭derby,偶尔它部署良好,然后在一段时间后关闭,可能是什么原因?可能是我创建的额外列吗?这是我的错误堆栈的一部分。
[#|2013-11- 14T16:19:24.439+0000|INFO|glassfish3.1.2|org.eclipse.persistence.session.file:/home/ubuntu/ glassfish3/glassfish/domains/domain1/applications/KowricService/WEB-INF/classes/$
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server $
Error Code: 0
Call: SELECT USER_ID, EMAIL, FACEBOOK_ID, FIRST_NAME, GOOGLE_ID, LAST_NAME, LINKEDIN_ID, PASSWORD, STATUS, TWITTER_ID, USER_TYPE FROM USERS
Query: ReadAllQuery(referenceClass=Users sql="SELECT USER_ID, EMAIL, FACEBOOK_ID, FIRST_NAME, GOOGLE_ID, LAST_NAME, LINKEDIN_ID, PASSWORD, STATUS, TWITTER_ID, USER_TYPE FROM USERS").$
在错误堆栈跟踪中,它指向 WebService 类中的休息资源方法
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at rest.UserResource.userList(UserResource.java:613)
方法看起来像这样,
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("/userslist")
public List<Users> userList(){
return em.createQuery("select u from Users u ").getResultList();
}
我想知道我是否添加了额外的列,为什么这会导致错误,请帮助解决。
编辑:
i read further into the stack trace and noticed a ConnectionPool Exception,i actually have 2 copies of a JNDI resource pointing to the same pool,could this be the reason;
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server 54.200.6.$
at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:120)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
... 122 more
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
... 122 more
Caused by: javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error conne$
at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManager Impl.java:307)
at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImp l.java:190)
at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImp l.java:165)
at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImp l.java:160)
at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:113)
... 123 more