I am using:
TomEE 7.0 + EclipseLink + Vaadin (+ Vaadin JPA) + Maven
When I am running my app on server inside the Eclipse, TomEE ignores my DB params defined in persistence.xml
. It always uses build-in HSQL Database Engine even if i define eclipselink.target-database
property
persistence.xml:
<persistence-unit name="OFFERTER_JPA"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>OFFERTER_DS</non-jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.PostgreSQLPlatform"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/oferter" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="oferter" />
<property name="javax.persistence.jdbc.password" value="oferter" />
<property name="eclipselink.logging.level" value="ALL" />
</properties>
</persistence-unit>
The result on console shows that TomEE reads the params and tries to create connection but as a result connects to HSQL instead of PostgreSQL:
[EL Info]: 2015-06-22 14:54:23.491--ServerSession(1776533395)--Thread(Thread[http-bio-8080-exec-9,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.6.0.v20150309-bf26070
[EL Config]: 2015-06-22 14:54:23.501--ServerSession(1776533395)--Connection(1077694737)--Thread(Thread[http-bio-8080-exec-9,5,main])--connecting(DatabaseLogin(
platform=>PostgreSQLPlatform
user name=> "oferter"
connector=>JNDIConnector datasource name=>null
))
cze 22, 2015 2:54:23 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose start
cze 22, 2015 2:54:24 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose end
[EL Config]: 2015-06-22 14:54:24.073--ServerSession(1776533395)--Connection(2047991763)--Thread(Thread[http-bio-8080-exec-9,5,main])--Connected: jdbc:hsqldb:file:C:\Programowanie\workspace\java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\data\hsqldb\hsqldb
User: SA
Database: HSQL Database Engine Version: 2.3.2
Driver: HSQL Database Engine Driver Version: 2.3.2
[EL Finest]: 2015-06-22 14:54:24.073--ServerSession(1776533395)--Connection(933531057)--Thread(Thread[http-bio-8080-exec-9,5,main])--Connection acquired from connection pool [read].
[EL Finest]: 2015-06-22 14:54:24.074--ServerSession(1776533395)--Connection(933531057)--Thread(Thread[http-bio-8080-exec-9,5,main])--Connection released to connection pool [read].
What is strange. If I export the application to standalone .WAR using Export -> WAR file
from Eclipse and deploy it by hand on the same TomEE instance, it behaves correctly and connects to PostgreSQL
Similar problem is described here:
create /WEB-INF/resources.xml
and then try