我很抱歉,所以当我在netbeans的本地glassfish中部署项目时(从netbeans开始glassfish)我得到了我想要的结果,web服务可以从mysql获得数据(这里是url:http://localhost:8085/ServerSide/webresources/credit)但是当我从命令行启动glassfish并部署项目的.war时,看看项目是否可以在另一个本地工作,具有相同的链接(8085/ServerSide/webresources/credit),我得到了这个错误
root cause
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No database selected
Error Code: 1046
Call: SELECT id_Credit, AGENCE FROM credit
Query: ReadAllQuery(referenceClass=Credit sql="SELECT id_Credit, AGENCE FROM credit")
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No database selected
Error Code: 1046
Call: SELECT id_Credit, AGENCE FROM credit
Query: ReadAllQuery(referenceClass=Credit sql="SELECT id_Credit, AGENCE FROM credit")
root cause
java.sql.SQLException: No database selected
第一次当我想部署。war在glassfish我有这个错误
Error occurred during deployment: Exception while preparing the app : Invalid resource : bd__pm. Please see server.log for more details
但是当我在我的glassfish-resources.xml
我已经解决了这个问题,这里是方法:首先删除我手动创建的JDBC资源和JDBC连接池,然后部署项目。使用命令行War,并像这样添加glassfish-resources.xml:
cd C:Program Filesglassfishglassfishbin
asadmin> start-domain
asadmin> deploy ...project.war
asadmin> add-resources ...glassfish-resources.xml
asadmin> restart-domain