使用WAS 7.0 Java中的数据源打开JPA异常

时间:2012-05-23 17:02:43

标签: java openjpa

我正在使用Open JPA获得Exception。

我创建了WAS数据源。这是My Persistence XML

http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd“>

<persistence-unit name="App11" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>java:comp/env/jdbc/mydatasource</jta-data-source>  
     <class>vo.Entity</class>
     <properties>
        <property name="openjpa.TransactionMode" value="managed"/>
                <property name="openjpa.ConnectionFactoryMode" value="managed"/>
    </properties>
    </persistence-unit>

我在执行时遇到此异常。

aused by:org.apache.commons.lang.exception.NestableRuntimeException:在JNDI查找名称“java:comp / env / jdbc / mydatasource”时出错。     在org.apache.openjpa.lib.conf.Configurations.lookup(Configurations.java:592)     在org.apache.openjpa.conf.OpenJPAConfigurationImpl.lookupConnectionFactory(OpenJPAConfigurationImpl.java:966)     在org.apache.openjpa.conf.OpenJPAConfigurationImpl.getConnectionFactory(OpenJPAConfigurationImpl.java:954)     at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:801)     在org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:568)     在org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1221)     在org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:476)     在org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:401)     在org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)     在org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:82)     在org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:861)     在org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:852)     在org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:640)     在org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:171)

任何帮助赞赏。

谢谢, 萨姆

2 个答案:

答案 0 :(得分:1)

这是我的问题的解决方案......

我在web.xml中错过了这个

jdbc / Mysource javax.sql.DataSource Container Unshareable

答案 1 :(得分:0)

尝试按Websphere Datasource with a given JNDI name?

中的建议在resource-ref中添加web.xml运行时描述符文件ibm-web-bnd.xml}