简体   繁体   English

与DataSource一起引发的HibernatePersistence javax.naming.NameNotFoundException

[英]HibernatePersistence javax.naming.NameNotFoundException thrown with DataSource

I am building a Tomcat Servlet application using Hibernate with a jta data source. 我正在使用带有jta数据源的Hibernate构建Tomcat Servlet应用程序。 My persistence.xml has the following content: 我的persistence.xml具有以下内容:

 <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="metadata.model" transaction-type="JTA">
     <provider>org.hibernate.ejb.HibernatePersistence</provider>
     <jta-data-source>jdbc/BitronixJTADataSource</jta-data-source>

...
</persistence>

In my ${web-app}/WebContent/META-INF/Context.xml , I have the following content: 在我的${web-app}/WebContent/META-INF/Context.xml ,我具有以下内容:

<Context>
<Resource name="jdbc/BitronixJTADataSource" auth="Container"
           type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           username="root" password="mysecretpassword"
           driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/metadatadb" />
</Context>

Right after the application is started, I issue: 在应用程序启动后,我立即发出:

emf = Persistence.createEntityManagerFactory("metadata.model");
entityManager = emf.createEntityManager();

and get a 并得到一个

javax.naming.NameNotFoundException: Name [jdbc/BitronixJTADataSource] is not bound in this Context. Unable to find [jdbc].

Do you have any idea why this is occuring? 您知道为什么会这样吗?

似乎在persistence.xml中, jta-data-source应该具有java:comp/env/jdbc/BitronixJTADataSource值,以便在InitialContext中找到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javax.naming.NameNotFoundException:CDIExtension - javax.naming.NameNotFoundException: CDIExtension 使用javax.naming.NameNotFoundException部署到Weblogic - Deploying to Weblogic with javax.naming.NameNotFoundException javax.naming.NameNotFoundException: fsmDS 未绑定 - javax.naming.NameNotFoundException: fsmDS not bound 工厂方法&#39;dataSource&#39;抛出异常; 嵌套的异常是javax.naming.NameNotFoundException - Factory method 'dataSource' threw exception; nested exception is javax.naming.NameNotFoundException 自定义SessionListener,此上下文中未绑定名称,javax.naming.NameNotFoundException - Custom SessionListener, name is not bound in this context, javax.naming.NameNotFoundException javax.naming.NameNotFoundException:名称[comp / env]未绑定在此Context中 - javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context 创建名称为“ myEmf”的bean时发生错误— javax.naming.NameNotFoundException:myPersistenceUnit - Error creating bean with name 'myEmf' — javax.naming.NameNotFoundException: myPersistenceUnit javax.naming.NameNotFoundException:名称java:comp在此上下文中未绑定 - javax.naming.NameNotFoundException: Name java:comp is not bound in this Context javax.naming.NameNotFoundException: java:jboss/jms/exampleApp/SampleQueueIn - javax.naming.NameNotFoundException: java:jboss/jms/exampleApp/SampleQueueIn 缺少资源的Tomcat 7 jndi - javax.naming.NameNotFoundException - Tomcat 7 jndi - javax.naming.NameNotFoundException on missing resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM