Glassfish での JTA について質問があります。何日もの間、私はこの問題を解決しようとしています。データベースにエンティティを書きたい。シンプルにするために、GlassfishDB を使用します。Glassfish-Admin Console では、
jdbc/__default
リソースとして。Connection-Pool の Ping が機能しています。persistence.xml で、私は JTA を使用していて、jdbc/__ のデフォルトが私のリソースであることを宣言しました。フィールドからテーブルを作成しようとすると、例外が発生します。
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600
java.lang.NullPointerException
at `enter code here`com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:569)
at javax.naming.InitialContext.lookup(InitialContext.java:415)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:110)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.perform(Main.java:85)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:76)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:63)
[EL Severe]: Local Exception Stack:
Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.0.1.v20100213-r6600):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/__default].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/__default' in
SerialContext [Root exception is javax.naming.NamingException: Unable to acquire
SerialContextProvider for SerialContext [Root exception is
java.lang.NullPointerException]]
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:451)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:116)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:369)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.perform(Main.java:85)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:76)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:63)
Caused by: javax.naming.NamingException: Lookup failed for 'jdbc/__default' in
SerialContext [Root exception is javax.naming.NamingException: Unable to acquire
SerialContextProvider for SerialContext [Root exception is
java.lang.NullPointerException]]
persistence.xml は次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="Test" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/__default</jta-data-source>
</persistence-unit>
</persistence>
Glassfish の domain.xmlの<resources>
-part は次のとおりです。
-<resources>
<jdbc-resource object-type="system-admin" jndi-name="jdbc/__TimerPool" pool-
name="__TimerPool"/>
<jdbc-resource jndi-name="jdbc/__default" pool-name="DerbyPool"/>
-<jdbc-connection-pool name="__TimerPool" res-type="javax.sql.XADataSource"
datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource">
<property name="databaseName"
value="${com.sun.aas.instanceRoot}/lib/databases/ejbtimer"/>
<property name="connectionAttributes" value=";create=true"/>
</jdbc-connection-pool>
-<jdbc-connection-pool name="DerbyPool" res-type="javax.sql.DataSource" datasource-
classname="org.apache.derby.jdbc.ClientDataSource" is-isolation-level-
guaranteed="false"> <property name="PortNumber" value="1527"/>
<property name="Password" value="APP"/>
<property name="User" value="APP"/> <property name="serverName" value="localhost"/>
<property name="DatabaseName" value="sun-appserv-samples"/>
<property name="connectionAttributes" value=";create=true"/>
</jdbc-connection-pool>
-<jdbc-connection-pool name="PostSQLPool" res-type="javax.sql.DataSource"
datasource-classname="org.postgresql.ds.PGSimpleDataSource" ping="true">
<property name="databaseName" value="PostSQLDatenbank"/>
<property name="password" value="philipp"/> <property name="portNumber"
value="5432"/>
<property name="serverName" value="localhost"/>
<property name="user" value="postgres"/>
<property name="URL" value="URL=jdbc:postgresql://localhost:5432/Time"/>
</jdbc-connection-pool> -
<jdbc-connection-pool name="PostPool" res-
type="javax.sql.DataSource" datasource-
classname="org.postgresql.ds.PGSimpleDataSource" ping="true">
<property name="Url" value="jdbc:postgresql://localhost:5432/PostSQLDatenbank"/>
<property name="URL" value="jdbc:postgresql://localhost:5432/PostSQLDatenbank"/>
<property name="databaseName" value="PostSQLDatenbank"/>
<property name="password" value="philipp"/>
<property name="portNumber" value="5432"/>
<property name="serverName" value="localhost"/>
<property name="user" value="postgres"/>
</jdbc-connection-pool>
</resources>