0

我正在尝试使用 JPA 从实体生成表,但是当我尝试这样做时,我收到:

[EL Config]: The foreign key column name for the mapping element [offer] is being defaulted to: OFFER_OID.
....
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
java.lang.RuntimeException: Orb initialization erorr
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)
    at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:364)
    at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:371)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:401)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:346)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:654)
    at javax.naming.InitialContext.lookup(InitialContext.java:415)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
    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:83)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:74)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:61)
Caused by: java.lang.NullPointerException
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)
    ... 20 more
[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 [jdbc/MySQLJDBCResource].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/MySQLJDBCResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
    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:83)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:74)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:61)
Caused by: javax.naming.NamingException: Lookup failed for 'jdbc/MySQLJDBCResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:654)
    at javax.naming.InitialContext.lookup(InitialContext.java:415)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
    ... 11 more
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:351)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
    ... 15 more
Caused by: java.lang.RuntimeException: Orb initialization erorr
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)
    at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:364)
    at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:371)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:401)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:346)
    ... 16 more
Caused by: java.lang.NullPointerException
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)
    ... 20 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 [jdbc/MySQLJDBCResource].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/MySQLJDBCResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
    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:83)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:74)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:61)
Caused by: Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/MySQLJDBCResource].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/MySQLJDBCResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
    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.NamingException: Lookup failed for 'jdbc/MySQLJDBCResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:654)
    at javax.naming.InitialContext.lookup(InitialContext.java:415)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
    ... 11 more
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:351)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
    ... 15 more
Caused by: java.lang.RuntimeException: Orb initialization erorr
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)
    at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:364)
    at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:371)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:401)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:346)
    ... 16 more
Caused by: java.lang.NullPointerException
    at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)
    ... 20 more

所以,我认为主要问题在这里:“jdbc/MySQLJDBCResource”的查找失败。在我的 persistence.xml 中,我设置了 jta-data-source,如您所见:

<?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="acmeauction" transaction-type ="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/MySQLJDBCResource</jta-data-source>
        <class>...[cutted]...</class>
    </persistence-unit>
</persistence>

我正在使用 Glassfish v3、JPA EclipseLink:我很乐意提供任何有用的附加信息。谢谢, 安

4

1 回答 1

0

看起来 Glassfish 设置正确。您似乎正在从 Eclipse 运行?

尝试在 Eclipse 之外运行。

于 2012-06-20T13:07:56.160 回答