无法实例化指定的TransactionFactory类[org.transaction.JDBCTransactionFactory] [英] Unable to instantiate specified TransactionFactory class [org.transaction.JDBCTransactionFactory]

查看:78
本文介绍了无法实例化指定的TransactionFactory类[org.transaction.JDBCTransactionFactory]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我是休眠的新手,我想用HibernateOGM编写一个非常简单的例子。我收到一个异常,说:

引起:org.hibernate.HibernateException:无法实例化指定的TransactionFactory类[org.transaction.JDBCTransactionFactory] ​​



我搜索了很多,但我找不到解决方案。据我所知,这个问题发生在这一行:

  sessionfactory = cfgogm.buildSessionFactory(serviceregistry); 

如果我评论其他行,我不会例外,只有INFOS。



这是我的Stacktrace:

  at org.hibernate.engine.transaction.internal.TransactionFactoryInitiator。在org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator处的org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator.buildServiceInstance(OgmTransactionFactoryInitiator.java:61)
处启动服务(TransactionFactoryInitiator.java:80)
。 buildServiceInstance(OgmTransactionFactoryInitiator.java:41)
at org.hibernate.ogm.service.impl.OptionalServiceInitiator.initiateService(OptionalServiceInitiator.java:37)
at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService( StandardServiceRegistryImpl.java:69)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)

在这里你可以找到我的代码和hib ernate.cfg.xml和pom.xml:

  OgmConfiguration cfgogm = new OgmConfiguration(); 
cfgogm.configure(hibernate.cfg.xml);
serviceregistry = new ServiceRegistryBuilder()。applySettings(cfgogm.getProperties())。buildServiceRegistry();
sessionfactory = cfgogm.buildSessionFactory(serviceregistry)

hibernate.cfg .xml 是:

 <?xml version =1.0encoding =UTF-8 >?; 
<!DOCTYPE hibernate-configuration PUBLIC - // Hibernate / Hibernate Configuration DTD 3.0 // ENhttp://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">
< hibernate-configuration>
< session-factory>


< property name =hibernate.current_session_context_class>线程< / property>
< property name =hibernate.ogm.datastore.grid_dialect> org.hibernate.ogm.dialect.mongodb.MongoDBDialect< / property>
< property name =hibernate.ogm.datastore.provider> mongodb< / property>
< property name =hibernate.ogm.mongodb.database> rcfdb< / property>
< property name =hibernate.ogm.mongodb.host> 127.0.0.1< / property>
< property name =hibernate.ogm.mongodb.port> 27017< / property>
< mapping resource =hibernate-contact.hbm.xml/>
< / session-factory>
< / hibernate-configuration>

pom.xml

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http:/ /www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven -4.0.0.xsd>
< modelVersion> 4.0.0< / modelVersion>
< groupId> hogm< / groupId>
< artifactId> HibernateOGM_MongoDB< / artifactId>
< version> 1.0-SNAPSHOT< / version>
<包装> jar< / packaging>
< name> HibernateOGM_MongoDB< / name>
< url> http://maven.apache.org< / url>
< build>
< plugins>
< plugin>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> exec-maven-plugin< / artifactId>
< version> 1.2.1< / version>
<执行次数>
<执行>
<目标>
< goal> exec< / goal>
< /目标>
< /执行>
< /执行次数>
< / plugin>
< / plugins>
< / build>

<依赖关系>
< dependency>
< groupId> org.hibernate.ogm< / groupId>
< artifactId> hibernate-ogm-mongodb< / artifactId>
< version> 4.0.0.Beta1< / version>
< /依赖关系>
< dependency>
< groupId> org.hibernate.ogm< / groupId>
< artifactId> hibernate-ogm-core< / artifactId>
< version> 4.0.0.Beta2< / version>
< /依赖关系>

< dependency>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.11< / version>
< scope> test< / scope>
< type> jar< / type>
< /依赖关系>
< /依赖关系>
< / project>

你能帮我解决这个问题吗? Hibernate对象/网格映射器(OGM)是一种持久性引擎,为 NoSQL 提供了Java持久性(JPA)支持, / strong>数据存储。那么你为什么在derby中使用 hibernate-ogm



查看有关mangoDB的hibernate-ogm官方指南



- 编辑 -



在你的任何配置文件中是否存在类似于 JDBCTransactionFactory 的东西?尝试删除它。


I have a problem. I am new in hibernate and I want to write a very simple example with HibernateOGM. I get an Exception that says:

Caused by: org.hibernate.HibernateException: Unable to instantiate specified TransactionFactory class [org.transaction.JDBCTransactionFactory]

I have searched really alot, but I couldn't find any solution for my problem. As I understand, the problem occures in this line:

sessionfactory=cfgogm.buildSessionFactory(serviceregistry);

If I comment the other lines I have no exception, only INFOS.

this is my Stacktrace:

at org.hibernate.engine.transaction.internal.TransactionFactoryInitiator.initiateService(TransactionFactoryInitiator.java:80)
    at org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator.buildServiceInstance(OgmTransactionFactoryInitiator.java:61)
    at org.hibernate.ogm.transaction.impl.OgmTransactionFactoryInitiator.buildServiceInstance(OgmTransactionFactoryInitiator.java:41)
    at org.hibernate.ogm.service.impl.OptionalServiceInitiator.initiateService(OptionalServiceInitiator.java:37)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)

here you can find my code and hibernate.cfg.xml and pom.xml:

 OgmConfiguration cfgogm=new OgmConfiguration();
            cfgogm.configure("hibernate.cfg.xml");
            serviceregistry=new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
            sessionfactory=cfgogm.buildSessionFactory(serviceregistry)

hibernate.cfg.xml is:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>  
  <session-factory>


    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.ogm.datastore.grid_dialect">org.hibernate.ogm.dialect.mongodb.MongoDBDialect</property>
    <property name="hibernate.ogm.datastore.provider">mongodb</property>
    <property name="hibernate.ogm.mongodb.database">rcfdb</property>
    <property name="hibernate.ogm.mongodb.host">127.0.0.1</property>
    <property name="hibernate.ogm.mongodb.port">27017</property>
    <mapping resource="hibernate-contact.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>hogm</groupId>
  <artifactId>HibernateOGM_MongoDB</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>HibernateOGM_MongoDB</name>
  <url>http://maven.apache.org</url>
  <build>
          <plugins>
              <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>exec-maven-plugin</artifactId>
                  <version>1.2.1</version>
                  <executions>
                      <execution>
                          <goals>
                                  <goal>exec</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
  </build>

 <dependencies>
     <dependency>
         <groupId>org.hibernate.ogm</groupId>
         <artifactId>hibernate-ogm-mongodb</artifactId>
         <version>4.0.0.Beta1</version>
     </dependency>
     <dependency>
         <groupId>org.hibernate.ogm</groupId>
         <artifactId>hibernate-ogm-core</artifactId>
         <version>4.0.0.Beta2</version>
     </dependency>   

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
   <type>jar</type>
  </dependency>
 </dependencies>
</project>

could you please help me to solve this problem?

解决方案

Hibernate Object/Grid Mapper (OGM) is a persistence engine providing Java Persistence (JPA) support for NoSQL datastores. so why do you use hibernate-ogm with derby?

check out the official guide for hibernate-ogm with mangoDB

--edit--

is there something like JDBCTransactionFactory in any of your configuration file? try remove it.

这篇关于无法实例化指定的TransactionFactory类[org.transaction.JDBCTransactionFactory]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆