Eclipse 中的 TomEE 始终使用 HSQL 数据库引擎而不是在 persistence.xml (EclipseLink) 中定义
TomEE in Eclipse always uses HSQL Database Engine instead of defined in persistence.xml (EclipseLink)
我正在使用:
TomEE 7.0 + EclipseLink + Vaadin(+ Vaadin JPA)+ Maven
当我在 Eclipse 内的服务器上 运行 我的应用程序时,TomEE 忽略了我在 persistence.xml
中定义的数据库参数。它总是使用内置的 HSQL 数据库引擎,即使我定义 eclipselink.target-database
属性
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>
控制台上的结果显示 TomEE 读取参数 并尝试创建连接,但 结果连接到 HSQL 而不是 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].
有什么奇怪的。 如果我使用 Export -> WAR file
从 Eclipse 将应用程序导出到独立的 .WAR 并在同一个 TomEE 实例上手动部署它,它的行为是正确的并连接到 PostgreSQL
这里描述了类似的问题:
创建 /WEB-INF/resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="myDS" type="DataSource">
JdbcDriver = org.postgresql.Driver
JdbcUrl = jdbc:postgresql://112.216.148.236:5432/ncore
UserName = xxx
Password = xxx
</Resource>
</tomee>
然后尝试
我正在使用:
TomEE 7.0 + EclipseLink + Vaadin(+ Vaadin JPA)+ Maven
当我在 Eclipse 内的服务器上 运行 我的应用程序时,TomEE 忽略了我在 persistence.xml
中定义的数据库参数。它总是使用内置的 HSQL 数据库引擎,即使我定义 eclipselink.target-database
属性
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>
控制台上的结果显示 TomEE 读取参数 并尝试创建连接,但 结果连接到 HSQL 而不是 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].
有什么奇怪的。 如果我使用 Export -> WAR file
从 Eclipse 将应用程序导出到独立的 .WAR 并在同一个 TomEE 实例上手动部署它,它的行为是正确的并连接到 PostgreSQL
这里描述了类似的问题:
创建 /WEB-INF/resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="myDS" type="DataSource">
JdbcDriver = org.postgresql.Driver
JdbcUrl = jdbc:postgresql://112.216.148.236:5432/ncore
UserName = xxx
Password = xxx
</Resource>
</tomee>
然后尝试