在Weblogic中获取Hibernate EntityManagerFactory时出现问题(EJB3应用程序)

hibernate jpa ejb-3.0 weblogic ejb

6269 观看

3回复

0 作者的声誉

从weblogic StartUp Class中的以下代码获取JPA中的EntityManagerFactory时,我遇到了一个问题


    EntityManagerFactory emf =
        Persistence.createEntityManagerFactory("testEJBPU");

    logger.info("Created EntityManagerFactory");

    Context ctx = new InitialContext();

    ctx.rebind("testEJBPU", emf);

上面的代码只返回OPenJPA EntityManagerFactory而不是Hibernate我在Presistence.xml文件中有以下内容


<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2006 Illuminatics, Inc.
All rights reserved.
-->

<persistence 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"
             version="1.0">
    <persistence-unit name="testEJBPU" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/evolvDS</jta-data-source>
        <properties>
            <property name="hibernate.ejb.cfgfile"
                      value="META-INF/hibernate.cfg.xml"/>
            <property name="hibernate.transaction.factory_class"
                      value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class"
                      value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
            <property name="hibernate.cache.provider_class"
                      value="org.hibernate.cache.EhCacheProvider"/>
            <property name="hibernate.cache.jndi"
                      value="evolv-cache"/>
        </properties>
    </persistence-unit>
</persistence>

并在应用程序启动时收到与openJPA相关的以下错误


<Apr 14, 2009 9:48:18 AM PKT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "binder", <1.0.0 fatal user error> org.apache.openjpa.util.UserException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
<1.0.0 fatal user error> org.apache.openjpa.util.UserException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
    at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:70)
    at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:802)
    at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:568)
    at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1185)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:450)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:375)
    at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)
    at kodo.conf.CachingMetaDataRepositoryPlugin.instantiate(CachingMetaDataRepositoryPlugin.java:29)
    at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:79)
    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:833)
    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:828)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:539)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.readResolve(AbstractBrokerFactory.java:381)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1033)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1728)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
    at weblogic.rmi.extensions.server.CBVInputStream.readObjectInternal(CBVInputStream.java:71)
    at weblogic.rmi.extensions.server.CBVInputStream.readObject(CBVInputStream.java:65)
    at weblogic.jndi.internal.JNDIHelper.copyObject(JNDIHelper.java:36)
    at weblogic.jndi.internal.WLEventContextImpl.copyObject(WLEventContextImpl.java:379)
    at weblogic.jndi.internal.WLEventContextImpl.rebind(WLEventContextImpl.java:114)
    at javax.naming.InitialContext.rebind(InitialContext.java:367)
    at com.illuminatics.test.weblogic.EntityManagerFactoryBinder.main(EntityManagerFactoryBinder.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeMain(ClassDeploymentManager.java:353)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:263)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClassDeployment(ClassDeploymentManager.java:198)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClassDeployments(ClassDeploymentManager.java:177)
    at weblogic.management.deploy.classdeployment.ClassDeploymentManager.runStartupsAfterAppActivation(ClassDeploymentManager.java:158)
    at weblogic.management.deploy.classdeployment.StartupClassPrelistenService.start(StartupClassPrelistenService.java:13)
    at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
> 

My EAR Structure is as:

testEJBProject.ear 
-->lib/ 
-->META-INF/ 
----->application.xml 
----->MANIFEST.MF 
-->testEJB.jar 
----->META-INF/ 
--------->hibernate.cfg.xml 
--------->INDEX.LST 
--------->MANIFEST>MF 
--------->persistence.xml 
----->com/../..*

如果有人以前遇到过它,请告诉我它的解决方案! 此致,Kazim Raza。

作者: Kazim Raza 的来源 发布者: 2009 年 4 月 14 日

回应 (3)


0

9198 作者的声誉

您设置数据源jdbc / evolvDS的方式看起来有问题。作为例外,说没有定义JDBC驱动程序名称。你能重新检查你的数据源配置吗?

作者: Bhushan Bhangale 发布者: 14.04.2009 05:36

0

9060 作者的声誉

您是否在web.xml中使用persistence-unit-ref引用了持久性单元?

类似的东西

persistence / testEJBPU ...

作者: MahdeTo 发布者: 14.04.2009 06:10

0

0 作者的声誉

决定

这个问题通过扩展HibernatePersistenceProvider课程来解决。

作者: Kazim Raza 发布者: 17.04.2009 06:41
32x32