很抱歉,当我在 netbeans 的本地 galssfish 中部署项目时(从 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
第一次当我想在 glassfish 中部署 .war 时出现此错误
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 资源时,我解决了这个问题
最佳答案
这个问题我已经解决了,方法如下: 首先删除我手动创建的 jdbc 资源和 jdbc 连接池,然后使用命令行部署 project.war 并添加 glassfish-resources.xml,如下所示:
cd C:\Program Files\glassfish\glassfish\bin
asadmin> start-domain
asadmin> deploy ...\project.war
asadmin> add-resources ...\glassfish-resources.xml
asadmin> restart-domain
关于java - 无法在 glassfish 上部署 war 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32190350/