0

乱数を生成してデータベースに入れる非常に単純な Web アプリがあります。

サーブレットを呼び出すボタンをクリックすると、次のエラーが発生します。

Aug 22, 2013 10:05:22 AM com.nrs.hibernate.dao.FileUploadDAO persist_cs_with_cfg
INFO: Persisting FileUploadPojo instance ...
Aug 22, 2013 10:05:23 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Aug 22, 2013 10:05:23 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: FileUploadPojo.hbm.xml
Aug 22, 2013 10:05:23 AM org.hibernate.cfg.Configuration doConfigure


**INFO: HHH000041: Configured SessionFactory: null**


Aug 22, 2013 10:05:23 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.ogm.dialect.NoopDialect
Aug 22, 2013 10:05:23 AM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
Aug 22, 2013 10:05:24 AM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
Aug 22, 2013 10:05:24 AM com.nrs.hibernate.util.HibernateUtil <clinit>
SEVERE: Initial SessionFactory creation failed !

私のhtmlは簡単です:

<form action="LuckyNumberServlet" method="POST">
    <input type="submit" value="Generate Lucky Number">
</form>

私のJavaメソッドは非常に単純です(LuckyNumberDAOから):

public void persist_cs_with_cfg(LuckyNumberPojo transientInstance) throws Exception {

        log.log(Level.INFO, "Persisting LuckyNumberPojo instance ...");
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        try {
            session.beginTransaction();
            session.persist(transientInstance);
            session.getTransaction().commit();

            log.log(Level.INFO, "Persist successful...");
        } catch (RuntimeException re) {
            session.getTransaction().rollback();
            log.log(Level.SEVERE, "Persist failed...", re);
            throw re;
        }
    }

私は何が欠けていますか?

編集: 構成ファイル:

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.ogm.datastore.provider">mongodb</property>
    <property name="hibernate.ogm.datastore.grid_dialect">org.hibernate.ogm.dialect.mongodb.MongoDBDialect</property>
    <property name="hibernate.ogm.mongodb.database">tomcat_db</property>
    <property name="hibernate.ogm.mongodb.host">127.0.0.1</property>
    <property name="hibernate.ogm.mongodb.port">27017</property>
    <mapping resource="LuckyNumberPojo.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

LuckyNumberPojo.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.nrs.hibernate.pojo.LuckyNumberPojo" table="jdbc">
        <id name="id" type="string">
            <column name="id" />
            <generator class="uuid2" />
        </id>
        <property name="luckynumber" type="int">
            <column name="luckynumber"/>
        </property>
    </class>
</hibernate-mapping>

HibernateUtil.java:

 static {
        try {
            // create a new instance of OmgConfiguration
            OgmConfiguration cfgogm = new OgmConfiguration();

            //process configuration and mapping files
            cfgogm.configure();
            // create the SessionFactory
            serviceRegistry = new ServiceRegistryBuilder().applySettings(cfgogm.getProperties()).buildServiceRegistry();
            sessionFactory = cfgogm.buildSessionFactory(serviceRegistry);
        } catch (Throwable ex) {
            log.log(Level.SEVERE, "Initial SessionFactory creation failed !", ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

ディレクトリ構造:

ディレクトリ構造

4

0 に答える 0