我在Java EE中有一个Web应用程序(Netbeans + Maven)支持Tomcat 8的本地安装,我的应用程序运行Jersey用于Web服务。我正在尝试添加EclipseLink以实现持久性(我正在访问的数据库是一个远程OracleDB),但我无法正确配置它,每次我尝试创建实体时都会遇到很多例外情况
这是我的代码:
EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager entityManager = factory.createEntityManager();
entityManager.getTransaction().begin();
它抛出
异常[EclipseLink-7060](Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):org.eclipse.persistence.exceptions.ValidationException 异常说明:无法获取数据源[jdbc / oracle]。 内部异常:javax.naming.NameNotFoundException:名称[jdbc / oracle]未绑定在此Context中。无法找到[jdbc]。
我一直在花费大量时间来配置web.xml,context.xml和persistence.xml,但没有任何作用
编辑: 当我添加
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@11.22.333.444:5555:XE"/>
<property name="javax.persistence.jdbc.user" value="xxxx"/>
<property name="javax.persistence.jdbc.password" value="xxxx"/>-->
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="eclipselink.logging.level" value="WARNING"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
到persistence.xml,我得到以下
javax.persistence.PersistenceException:java.lang.UnsupportedOperationException:BasicDataSource不支持 org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:762) org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204) org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182) org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527) org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140) org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177) javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
我做错了什么?