I want to programm some simple JPA test. My project structure is
├── pom.xml
└── src
└── main
├── java
│ └── guest
│ ├── GuestDao.java
│ ├── Guest.java
│ ├── GuestRest.java
│ └── Rest.java
└── resources
└── META-INF
└── persistence.xml
persistence.xml
is
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="guestDB" transaction-type="JTA">
<jta-data-source>jdbc/guestDB</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
<property name="eclipselink.logging.level" value="FINE" />
</properties>
</persistence-unit>
</persistence>
However, if I deploy on glassfish 5, using asadmin deploy target/joe.war
, I get
remote failure: Error occurred during deployment:
Exception while deploying the app [joe] :
JNDI lookup failed for the resource: Name: [guestDB], Lookup: [jdbc/guestDB], Type: [javax.sql.DataSource].
Please see server.log for more details.
Command deploy failed.
The server log tells me:
...
Caused by: javax.naming.NameNotFoundException: guestDB not found
...
But I think, because of
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
in persistence.xml
, I do not have to create the DB, nor any connection pool.
However, if I create a JDBC Resource, like in the following picture
I get connection refused
error
remote failure: Error occurred during deployment: Exception while preparing the app : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException: Fehler beim Herstellen der Verbindung zu Server localhost auf Port 1.527 mit Meldung Verbindungsaufbau abgelehnt (Connection refused).
Error Code: 0. Please see server.log for more details.
Okay, you might say, "use an IDE like Netbeans", but I'm trying to get the basics, so that's not an option for now.