Cannot deploy war to GlassFish 4.1.2 server because database can't be found

I'm working through a book on GlassFish4 application server and have trouble deploying a sample war to the server. The server says:

"Error occurred during deployment: Exception while deploying the app [jpaintro-1.0] : 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: The connection was refused because the database customerdb was not found. Error Code: 0. Please see server.log for more details."

The database server is Derby that comes with GlassFish. The database was created with this from the ./ij prompt:

connect 'jdbc:derby://localhost:1527/customerdb;create=true';

Next I could logon:

connect 'jdbc:derby://localhost:1527/customerdb;user=dev;password=dev';

and successfully enter table creation data and insert table data. Next I could retrieve this data with SQL. All fine, so the database exists.

Physical location database: /home/fedora/GlassFish/glassfish4/glassfish/databases/1527/customerdb

The DERBY_HOME environment value was set. I had to set up the following resources from the command line prompt:

./asadmin create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.DataSource --property DatabaseName=customerdb:User=dev:password=dev CustomerDBPool

./asadmin create-jdbc-resource --connectionpoolid CustomerDBPool jdbc/__CustomerDBPool

And I could verify in the GlassFish console that they were created successfully. The JDBC connection pool does indeed have an entry CustomerDBPool with an "additional property" name=DatabaseName, value=customerdb as well as user/password dev/dev. Also in the console is a JDBC resource with JNDI name jdbc/__CustomerDBPool and pool name CustomerDBPool

The war-file that I can't deploy contains a JPA-entity Customer and CDI named bean JpaDemoBean. The latter constructs a few Customer object and persists them to the database.

In the persistence.xml there is merely a jta-data-source element with value jdbc/__CustomerDBPool

I am all following literally "from the book".

Now why can't I deploy the war?

And all of a sudden I can't connect to the database via command line tool ij either: ERROR 08004: The connection was refused because the database customerdb was not found.

I can stop and start the database server from the command line, but during startup I get the message: "Invalid database home directory: /home/fedora/GlassFish/glassfish4/glassfish/databases"

Nevertheless the startup process continues and says it started the database successfully.

Thanks in advance!

链接地址: http://www.djcxy.com/p/41248.html

上一篇: WPF vs Silverlight

下一篇: 由于无法找到数据库,因此无法将战争部署到GlassFish 4.1.2服务器