0

プロジェクトのエンティティからデータベース テーブルを生成しようとすると、以下の例外がスローされます。

私が正しく理解している場合、例外は次を指定することを提案しましたjava.naming.factory.initial
したがって、JBoss-Documentationのいくつかの部分を調べましたが、何を探しているのかよくわかりませんでしたjndi.properties

ところで: テーブルからのエンティティの生成 (その逆) は問題なく動作します。

[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Severe]: Local Exception Stack: 
Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:jboss/datasources/MySQLDS].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:497)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:109)
    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:206)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
    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.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
    ... 11 more

Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:jboss/datasources/MySQLDS].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
    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: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [java:jboss/datasources/MySQLDS].
Internal Exception: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:497)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:109)
    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:206)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)
    ... 7 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
    ... 11 more

私の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="DynamicWebProject" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>
    <class>hoho.model.generated.AvailabilityDeliveryMethod</class>
    <class>hoho.model.generated.AvailabilityItem</class>
    <class>hoho.model.generated.AvailabilityRestaurant</class>
    <class>hoho.model.generated.Category</class>
    <class>hoho.model.generated.ContactData</class>
    <class>hoho.model.generated.Deliverer</class>
    <class>hoho.model.generated.DeliveryMethod</class>
    <class>hoho.model.generated.DeliveryMethodHasPrice</class>
    <class>hoho.model.generated.Item</class>
    <class>hoho.model.generated.Label</class>
    <class>hoho.model.generated.OrderHasItem</class>
    <class>hoho.model.generated.OrderLimitation</class>
    <class>hoho.model.generated.PaymentMethod</class>
    <class>hoho.model.generated.Person</class>
    <class>hoho.model.generated.PersonPreference</class>
    <class>hoho.model.generated.Price</class>
    <class>hoho.model.generated.PurchaseOrder</class>
    <class>hoho.model.generated.Restaurant</class>
    <class>hoho.model.generated.Tag</class>
    <class>hoho.model.generated.Image</class>
    <class>hoho.model.generated.MimeType</class>
    <class>hoho.model.generated.TaxRate</class>
    <properties>
      <!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> -->
      <property name="javax.persistence.jtaDataSource" value="java:jboss/datasources/MySQLDS" />
    </properties>
  </persistence-unit>
</persistence>
4

1 に答える 1

1

JPA ツールは、リソース タイプ JTA では機能しません。一時的に RESOURCE_LOCAL に変更します。エンティティからのテーブルの生成も参照してください

于 2014-03-27T21:42:17.927 に答える