EclipseLink不会从Websphere Liberty Profile

时间:2016-04-14 18:14:33

标签: jpa jdbc eclipselink datasource websphere-liberty

我在Websphere Liberty Profile中配置JPA时遇到问题。 EclipseLink是WAS中具有jpa-2.1功能的默认提供程序,它不会读取server.xml DataSource中创建的属性。我试图在没有JPA的情况下从这个数据源获得连接,这种连接是成功的,我可以访问数据库。但是当我使用JPA然后从我的PerstistenceUnit创建EntityManagerFactory时,我得到了异常,在我看来这意味着我没有提供必要的参数,如url,用户名和密码。我测试了WAS认识到EclipseLink提供程序,但现在我不知道该怎么办这个问题。谷歌没有帮助我。

的persistence.xml

<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="test-unit" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>java:comp/env/jdbc/PostgreDS</jta-data-source>
    <properties>
        <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
        <property name="eclipselink.ddl-generation.output-mode"
            value="database" />
    </properties>
</persistence-unit>

server.xml(仅部分使用我的JDBC和DS设置)

<jdbcDriver id="myJDBCDriver" libraryRef="JDBCLib" javax.sql.XADataSource="org.postgresql.xa.PGXADataSource" >
</jdbcDriver>
<library id="JDBCLib" name="PostgreLib">
    <file name="/home/hubert/JavaLibs/postgresql-9.4-1206-jdbc41.jar" id="JDBC_JAR"></file>
</library>

<dataSource id="PostrgreConnection" jdbcDriverRef="myJDBCDriver" jndiName="jdbc/PostgreDS" type="javax.sql.XADataSource">
    <properties URL="jdbc:postgresql://localhost/GotSpotDB" databaseName="GotSpotDB" password="testtest" portNumber="5432" serverName="localhost" user="GotSpotAdmin"/>

</dataSource>

日志

[ERROR   ] CWWJP9992E: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.6.1.WAS-v20160106-a06c2b3): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
[ERROR   ] SRVE0777E: Exception thrown by application class 'org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy:837'
javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.6.1.WAS-v20160106-a06c2b3): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:837)
    at [internal classes]
    at pl.almost.done.TestServlet.doGet(TestServlet.java:52)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at [internal classes]
Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.6.1.WAS-v20160106-a06c2b3): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:383)
    ... 4 more

0 个答案:

没有答案