简体   繁体   English

我怎么能定义 <non-jta-data-source></non-jta-data-source> 在persistence.xml中?

[英]How can i defind <non-jta-data-source> </non-jta-data-source> in persistence.xml?

How can i define <non-jta-data-source> </non-jta-data-source> in persistence.xml? 如何在persistence.xml中定义<non-jta-data-source> </non-jta-data-source>

My project runs well in Tomcat 6 and Tomcat 7. 我的项目在Tomcat 6和Tomcat 7中运行良好。

now i am using 现在我正在使用

  1. Struts 2 Struts 2
  2. Spring 3.0.5 Spring 3.0.5
  3. JPA 2 JPA 2
  4. Jboss 6 Jboss 6

my persistence.xml looks likes this 我的persistence.xml看起来像这样

       <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.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_1_0.xsd">
    <persistence-unit name="axw-db" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    **<non-jta-data-source></non-jta-data-source>**
    <properties>
     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
    <property name="hibernate.connection.username" value="root"/>
    <property name="hibernate.connection.password" value="root"/>
    <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/abc"/>
    <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    <property name="hibernate.ejb.autodetection" value="class"/>
    </properties>
    </persistence-unit>
    </persistence>

now i am getting this exception 现在我得到了这个例外

[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/icc-web-struts2-1.0.0-SNAPSHOT]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [vfs:/D:/workspace/icc-temp/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1319268021951/deploy/icc-web-struts2.war/WEB-INF/lib/icc-core.jar/core-config.xml]: Initialization of bean failed; [org.apache.catalina.core.ContainerBase。[jboss.web]。[localhost]。[/ icc-web-struts2-1.0.0-SNAPSHOT]]将上下文初始化事件发送到类org.springframework的侦听器实例的异常。 web.context.ContextLoaderListener:org.springframework.beans.factory.BeanCreationException:在URL [vfs:/ D:/ workspace / icc-temp /中定义的名称'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'创建bean时出错.metadata / .plugins / org.jboss.ide.eclipse.as.core / JBoss_6.x_Runtime_Server1319268021951 /部署/ ICC-web的struts2.war / WEB-INF / LIB / ICC-core.jar添加/芯-config.xml中] :bean的初始化失败; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [vfs:/D:/workspace/icc-temp/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1319268021951/deploy/icc-web-struts2.war/WEB-INF/lib/icc-core.jar/core-config.xml]: Invocation of init method failed; 嵌套异常是org.springframework.beans.factory.BeanCreationException:在URL中定义名为'entityManagerFactory'的bean时出错[vfs:/ D:/workspace/icc-temp/.metadata/.plugins/org.jboss.ide.eclipse .as.core / JBoss_6.x_Runtime_Server1319268021951 / deploy / icc-web-struts2.war / WEB-INF / lib / icc-core.jar / core-config.xml]:调用init方法失败; nested exception is java.lang.RuntimeException: error trying to scan : vfs:/D:/workspace/icc-temp/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1319268021951/deploy/icc-web-struts2.war/WEB-INF/lib/icc-domain.jar/ 嵌套异常是java.lang.RuntimeException:尝试扫描时出错:vfs:/ D:/workspace/icc-temp/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1319268021951/deploy/ ICC-网络struts2.war / WEB-INF / lib目录/ ICC-domain.jar /

The non-jta-data-source is used to define a datasource which doesn't use the existing JTA manager. 非jta-data-source用于定义不使用现有JTA管理器的数据源。 If you're interested exactly in this feature, than it accepts the JNDI location of the non-JTA data source (ie java:app/jdbc/yourNonJTAsource ). 如果您对此功能完全感兴趣,那么它接受非JTA数据源的JNDI位置(即java:app / jdbc / yourNonJTAsource )。

The Datasource should be configured in your application server and this configuration is vendor-specific. 应在应用程序服务器中配置数据源,此配置是特定于供应商的。 Try accessing the JBoss web admin console and create/define the Pool/Datasource there. 尝试访问JBoss Web管理控制台并在那里创建/定义池/数据源。 If that's the case, than you can get rid of those user/password/url/... stuff from your persistence.xml as these information will be moved to the Application Server. 如果是这种情况,那么您可以从persistence.xml中删除那些用户/密码/ url / ...内容,因为这些信息将被移动到Application Server。

If you're using this persistence.xml totally outside of the container, than you probably don't need the non-jta nor the jta datasources, as you cannot rely on the JNDI outside the container. 如果你在容器之外完全使用这个persistence.xml,那么你可能不需要非jta和jta数据源,因为你不能依赖容器外的JNDI。

HTH. HTH。

暂无
暂无

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

相关问题 如何在 Spring 应用程序中使用非 jta-data-source 将选择查询重定向到复制数据库 - How to redirect select queries to replicated database using non-jta-data-source in Spring application 把什么放到jos-data-persistence.xml中? - What to put into jta-data-source of persistence.xml? 如何读取persistence.xml的标记值 <jta-data-source> 从文件config.properties中输入 - How I can do to read the tag value for my persistence.xml <jta-data-source> in from a file config.properties 部署时在persistence.xml中管理jta-data-source - Manege jta-data-source in persistence.xml on deploy 从Weblogic部署Plan.xml编辑Persistence.xml jta-data-source - Editing Persistence.xml jta-data-source from Weblogic deployment Plan.xml JPA:通过覆盖数据源,在JSE和JUnit中将jp-data-source与persistence.xml一起使用 - JPA: Reuse persistence.xml with jta-data-source in JSE and JUnit by overriding the datasource persistence.xml transaction-type =“ JTA” - persistence.xml transaction-type=“JTA” 如何将DRY应用于Liquibase数据源config和persistence.xml? - How to apply DRY for Liquibase data source config and persistence.xml? 如何在persistence.xml中添加数据源,以便IntelliJ IDEA看到它? - How do I add data source in persistence.xml so that IntelliJ IDEA sees it? 非jta数据源如何工作?是否有必要在persistence .xml本身中提供持久性单元? - How non-jta-datasource working ?is it necessary to provide the persistence unit inside persistence .xml itself?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM