These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Hibernate 3.1rc2 + JTA + bean not writing to the database
PostPosted: Wed Jan 04, 2006 11:06 pm 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
Hello,

I am having a strange behavior when running hibernate code in an mbean.
    Reading from the database is working fine.
    Writing to the database does not write.
    Although things works perfectly under the debugger.


Below is the piece of code I used - to be clear, exception handling code has been removed...

I am deploying as a har with second level caching and a sar. The code for the sar is below.

Has it happened already to anybody? It should be big.

I am calling the bean method from the jmx console - the user for JTA is probably anonymous.

Please help! thanks

Philippe


Hibernate version:
I am running AS 4.03SP1 with Hibernate 3.1rc2


Mapping documents:
the mapping used for the test is quite simple:
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping auto-import="true"
        package="com.evolab.evos.model.core" >
    <class name="Entity"
        table="CO07"
        optimistic-lock="version"
        lazy="true" >
        <comment>Entités</comment>
        <id name="Pkid"
            type="java.lang.Long"
            column="CO07_PKID" >
            <generator class="sequence" >
               <param name="sequence"> co07_pkid_seq </param>
            </generator>
        </id>
        <timestamp name="ModificationDate"
            column="CO07_MAJD" >
        </timestamp>
        <property name="CreationDate"
            type="timestamp" >
            <column name="CO07_CRED">
                <comment>Date de création</comment>
            </column>
        </property>
        <property name="Hierarchyref"
            type="java.lang.Long" >
            <column name="CO07_HIER">
                <comment>HierarchyRef</comment>
            </column>
        </property>
        <property name="Name"
            type="java.lang.String"
            length="64"
            unique="true" >
            <column name="CO07_NAME" sql-type="varchar(64)">
                <comment>Nom</comment>
            </column>
        </property>
        <property name="Summary"
            type="java.lang.String"
            length="80" >
            <column name="CO07_SMRY" sql-type="varchar(80)">
                <comment>Libellé</comment>
            </column>
        </property>
        <property name="Visibility"
            type="java.lang.Boolean" >
            <column name="CO07_VISI">
                <comment>Visibilité à l\'écran</comment>
            </column>
        </property>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
   /**
    * this is a test to verify that it is inserting into the database
    * @jmx.managed-operation
    */
   public void test() throws Exception
   {
      InitialContext cx= new InitialContext();
      UserTransaction ut = (UserTransaction)cx.lookup("UserTransaction");
      ut.begin();
      SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/evos/hibernate/SessionFactory");
       Session session = sf.getCurrentSession();
       session.beginTransaction();
       Entity entity= new Entity();
       entity.setName("TEST");
       session.save(entity);
      session.getTransaction().commit();
      session.close();   
   }

Full stack trace of any exception that occurs:
No exception.

Name and version of the database you are using:
The database is postgres 8.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Code:
2006-01-05 03:37:20,990 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: evos/hibernate/SessionFactory
2006-01-05 03:37:20,990 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=402880d008986bd70108986c3ea10004
2006-01-05 03:37:22,115 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2006-01-05 03:37:22,115 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11364286421
2006-01-05 03:37:23,350 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2006-01-05 03:37:23,350 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2006-01-05 03:37:23,350 DEBUG [org.hibernate.transaction.JTATransaction] begin
2006-01-05 03:37:23,350 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction begin
2006-01-05 03:37:25,928 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] saving transient instance
2006-01-05 03:37:25,943 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-05 03:37:25,943 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-01-05 03:37:25,990 DEBUG [org.hibernate.SQL]
    select
        nextval (' co07_pkid_seq ')
2006-01-05 03:37:25,990 INFO  [STDOUT] Hibernate:
    select
        nextval (' co07_pkid_seq ')
2006-01-05 03:37:25,990 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-05 03:37:26,053 DEBUG [org.hibernate.id.SequenceGenerator] Sequence identifier generated: 3
2006-01-05 03:37:26,053 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-05 03:37:26,053 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-05 03:37:26,053 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-01-05 03:37:26,053 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-01-05 03:37:26,053 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 3, using strategy: org.hibernate.id.SequenceGenerator
2006-01-05 03:37:26,053 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [com.evolab.evos.model.core.Entity#3]
2006-01-05 03:37:26,053 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_SAVE_UPDATE for: com.evolab.evos.model.core.Entity
2006-01-05 03:37:26,053 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_SAVE_UPDATE for: com.evolab.evos.model.core.Entity
2006-01-05 03:37:26,053 DEBUG [org.hibernate.engine.Versioning] Seeding: 2006-01-05 03:37:26.053
2006-01-05 03:37:26,147 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_SAVE_UPDATE for: com.evolab.evos.model.core.Entity
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Ressources
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Ressources
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Discussions
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Discussions
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Helps
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Helps
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Scores
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Scores
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Wikis
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.evolab.evos.model.core.Entity.Wikis
2006-01-05 03:37:26,162 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_SAVE_UPDATE for: com.evolab.evos.model.core.Entity
2006-01-05 03:37:27,193 DEBUG [org.hibernate.transaction.JTATransaction] commit
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /hib/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 0
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /_default_/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 1
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /props/ maxNodes 0 TimeToIdleSeconds 0current eviction queue size is 0
2006-01-05 03:37:27,365 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 03:37:28,287 DEBUG [org.hibernate.impl.SessionImpl] closing session
2006-01-05 03:37:28,287 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action


Top
 Profile  
 
 Post subject: more info
PostPosted: Thu Jan 05, 2006 12:13 am 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
If I flush the session before or after the commit() then I have more hibernate debug information, and can see traces of insert but still, nothing is actually written to the database.

Here are additionnal traces with flush:
Quote:
2006-01-05 05:03:51,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
2006-01-05 05:03:51,928 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushing entities and processing referenced collections
2006-01-05 05:03:51,928 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: com.evolab.evos.model.core.Entity.Ressources
2006-01-05 05:03:51,928 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: com.evolab.evos.model.core.Entity.Discussions
2006-01-05 05:03:51,943 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: com.evolab.evos.model.core.Entity.Helps
2006-01-05 05:03:51,943 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: com.evolab.evos.model.core.Entity.Scores
2006-01-05 05:03:51,943 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: com.evolab.evos.model.core.Entity.Wikis
2006-01-05 05:03:51,959 DEBUG [org.hibernate.engine.Collections] Collection found: [com.evolab.evos.model.core.Entity.Ressources#8], was: [<unreferenced>] (initialized)
2006-01-05 05:03:51,959 DEBUG [org.hibernate.engine.Collections] Collection found: [com.evolab.evos.model.core.Entity.Discussions#8], was: [<unreferenced>] (initialized)
2006-01-05 05:03:51,959 DEBUG [org.hibernate.engine.Collections] Collection found: [com.evolab.evos.model.core.Entity.Helps#8], was: [<unreferenced>] (initialized)
2006-01-05 05:03:51,959 DEBUG [org.hibernate.engine.Collections] Collection found: [com.evolab.evos.model.core.Entity.Scores#8], was: [<unreferenced>] (initialized)
2006-01-05 05:03:51,959 DEBUG [org.hibernate.engine.Collections] Collection found: [com.evolab.evos.model.core.Entity.Wikis#8], was: [<unreferenced>] (initialized)
2006-01-05 05:03:51,959 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Processing unreferenced collections
2006-01-05 05:03:51,959 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
2006-01-05 05:03:51,990 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2006-01-05 05:03:51,990 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 5 (re)creations, 0 updates, 0 removals to 5 collections
2006-01-05 05:03:51,990 DEBUG [org.hibernate.pretty.Printer] listing entities:
2006-01-05 05:03:52,006 DEBUG [org.hibernate.pretty.Printer] com.evolab.evos.model.core.Entity{Visibility=null, Scores=[], Helps=[], Summary=null, Wikis=[], Ressources=[], ModificationDate=2006-01-05 05:03:51, Discussions=[], Name=TEST, Hierarchyref=null, Pkid=8, CreationDate=null}
2006-01-05 05:03:52,006 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] executing flush
2006-01-05 05:03:52,006 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [CO07]
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, child_name=hib/org/hibernate/cache/UpdateTimestampsCache
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child hib/org/hibernate/cache/UpdateTimestampsCache
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO07, child_name=CO07
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child CO07
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO07
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO07, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO07, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/CO07", item, 11364338920)
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO07
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO07
2006-01-05 05:03:52,006 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/CO07: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,022 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,022 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Inserting entity: [com.evolab.evos.model.core.Entity#8]
2006-01-05 05:03:52,022 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Version: 2006-01-05 05:03:51.053
2006-01-05 05:03:52,022 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-05 05:03:52,022 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-01-05 05:03:52,022 DEBUG [org.hibernate.SQL]
insert
into
CO07
(CO07_MAJD, CO07_CRED, CO07_HIER, CO07_NAME, CO07_SMRY, CO07_VISI, CO07_PKID)
values
(?, ?, ?, ?, ?, ?, ?)
2006-01-05 05:03:52,022 INFO [STDOUT] Hibernate:
insert
into
CO07
(CO07_MAJD, CO07_CRED, CO07_HIER, CO07_NAME, CO07_SMRY, CO07_VISI, CO07_PKID)
values
(?, ?, ?, ?, ?, ?, ?)
2006-01-05 05:03:52,022 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-05 05:03:52,022 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Dehydrating entity: [com.evolab.evos.model.core.Entity#8]
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.TimestampType] binding '2006-01-05 05:03:51' to parameter: 1
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.TimestampType] binding null to parameter: 2
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.LongType] binding null to parameter: 3
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.StringType] binding 'TEST' to parameter: 4
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.StringType] binding null to parameter: 5
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.BooleanType] binding null to parameter: 6
2006-01-05 05:03:52,037 DEBUG [org.hibernate.type.LongType] binding '8' to parameter: 7
2006-01-05 05:03:52,037 DEBUG [org.hibernate.jdbc.AbstractBatcher] Adding to batch
2006-01-05 05:03:52,037 DEBUG [org.hibernate.jdbc.AbstractBatcher] Executing batch size: 1
2006-01-05 05:03:52,084 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-05 05:03:52,084 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-05 05:03:52,084 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-01-05 05:03:52,084 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-01-05 05:03:52,084 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [CO06_CF38]
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38, child_name=CO06_CF38
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child CO06_CF38
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38
2006-01-05 05:03:52,084 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38", item, 11364338920)
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/CO06_CF38: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,100 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [CO02_D003]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003, child_name=CO02_D003
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child CO02_D003
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003", item, 11364338921)
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/CO02_D003: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,100 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,115 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [H001_H003]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003, child_name=H001_H003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child H001_H003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003", item, 11364338921)
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/H001_H003: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,115 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [CO04_S003]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003, child_name=CO04_S003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child CO04_S003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003", item, 11364338921)
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/CO04_S003: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,115 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,131 DEBUG [org.hibernate.cache.UpdateTimestampsCache] Pre-invalidating space [CO01_W003]
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.Node] acquiring RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.Node] acquired RL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.Node] createChild: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003, child_name=CO01_W003
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.interceptors.LockInterceptor] created child CO01_W003
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeAdded(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.Node] acquiring WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=<unlocked>
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.Node] acquired WL: fqn=/hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003, caller=Thread[http-0.0.0.0-8080-1,5,jboss], lock=write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.TreeCache] _put(null, "/hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003", item, 11364338921)
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeModified(): redirecting to node visited. fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.eviction.LRUPolicy] nodeVisited(): fqn- /hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache/CO01_W003: write owner=Thread[http-0.0.0.0-8080-1,5,jboss]
2006-01-05 05:03:52,131 DEBUG [org.jboss.cache.interceptors.UnlockInterceptor] releasing lock for /hib/org/hibernate/cache/UpdateTimestampsCache: read owners=[Thread[http-0.0.0.0-8080-1,5,jboss]]
2006-01-05 05:03:52,131 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] post flush
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /hib/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 0
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 13 node events
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /_default_/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 1
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /props/ maxNodes 0 TimeToIdleSeconds 0current eviction queue size is 0
2006-01-05 05:03:52,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:03:55,990 DEBUG [org.hibernate.transaction.JTATransaction] commit
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /hib/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 7
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /_default_/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 1
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /props/ maxNodes 0 TimeToIdleSeconds 0current eviction queue size is 0
2006-01-05 05:03:57,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:03:58,740 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()
2006-01-05 05:03:58,740 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()
2006-01-05 05:03:58,740 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /hib/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 7
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /_default_/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 1
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /props/ maxNodes 0 TimeToIdleSeconds 0current eviction queue size is 0
2006-01-05 05:04:02,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /hib/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 7
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /_default_/ maxNodes 10000 TimeToIdleSeconds 1000current eviction queue size is 1
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processing the node events in region: Regions--- fqn: /props/ maxNodes 0 TimeToIdleSeconds 0current eviction queue size is 0
2006-01-05 05:04:07,522 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processed 0 node events
2006-01-05 05:04:08,834 DEBUG [org.hibernate.impl.SessionImpl] closing session
2006-01-05 05:04:08,834 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action


Top
 Profile  
 
 Post subject: searching UserTransaction
PostPosted: Thu Jan 05, 2006 12:17 am 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
It seems that the problem is recurring from time to time in the forum, unfortunately in different contexts and is sort of ignored by the hibernate team. It is actually simple to reproduce.


Top
 Profile  
 
 Post subject: Sounds like an hibernate bug to me.
PostPosted: Thu Jan 05, 2006 2:45 am 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
I found a workaround! Sounds like an hibernate bug to me.

The folowing code does not work:
Code:
   /**
    * this is a test to verify that it is inserting into the database
    * @jmx.managed-operation
    */
   public void test() throws Exception
   {
      InitialContext cx= new InitialContext();
      UserTransaction ut = (UserTransaction)cx.lookup("UserTransaction");
      ut.begin();
      SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/evos/hibernate/SessionFactory");
       Session session = sf.getCurrentSession();
       session.beginTransaction();
       Entity entity= new Entity();
       entity.setName("TEST");
       session.save(entity);
      session.getTransaction().commit();
      session.close();   
   }


The following code works!

Code:
      InitialContext cx= new InitialContext();
      UserTransaction ut = (UserTransaction)cx.lookup("UserTransaction");
      ut.begin();
      SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/evos/hibernate/SessionFactory");
       Session session = sf.getCurrentSession();
       Entity entity= new Entity();
       entity.setName("TEST");
       session.save(entity);
       session.flush();
       ut.commit();


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 6:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Certainly not.
Read the JTATransaction code.
If a Tx has already begun, Hibernate will not commit it, which is the only safe choice.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: ok but...
PostPosted: Thu Jan 05, 2006 11:00 am 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
if I do not execute ut.begin() then hibernate throws an exception saying that it could not locate the JTA Transaction.




It seems to me that I am configuring the use of JTA properly, but obviously I am missing something.


Code:
      <!-- Transaction integration -->
      <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
      <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
      <attribute name="FlushBeforeCompletionEnabled">true</attribute>
      <attribute name="AutoCloseSessionEnabled">true</attribute>




Full detail is below.


Here is the bean descriptors:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE server>
<server>
   <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" />

    <mbean code="org.jboss.cache.TreeCache" name="evolab:service=SecondLevelCache">
      <depends>jboss:service=Naming</depends>
      <depends>jboss:service=TransactionManager</depends>
     
      <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>       
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
       <attribute name="CacheMode">LOCAL</attribute>
       
        
       <!-- attribute name="CacheLoaderClass">org.jboss.cache.loader.bdbje.BdbjeCacheLoader</attribute-->
       <attribute name="CacheLoaderClass">org.jboss.cache.loader.FileCacheLoader</attribute>
       <attribute name="CacheLoaderConfig" replace="false">
         location=C:\\pmn\\pmn-deploy\\HIB-3-portal-2.2-jboss-4.0.3SP1\\server\\default\\data\\evolab-cache
       </attribute>
       <attribute name="CacheLoaderShared">true</attribute>
       <attribute name="CacheLoaderPreload">/</attribute>
       <attribute name="CacheLoaderFetchTransientState">false</attribute>
       <attribute name="CacheLoaderFetchPersistentState">true</attribute>

      <!-- Name of the eviction policy class. -->
      <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
      <!-- Specific eviction policy configurations. This is LRU -->
      <attribute name="EvictionPolicyConfig">
         <config>
            <attribute name="wakeUpIntervalSeconds">5</attribute>
            <!-- Cache wide default -->
            <region name="/_default_">
               <attribute name="maxNodes">10000</attribute>
               <attribute name="timeToLiveSeconds">1000</attribute>
               <!-- Maximum time an object is kept in cache regardless of idle time -->
               <attribute name="maxAgeSeconds">120</attribute>
            </region>
            <!-- Region managed by Hibernate -->
            <region name="/hib">
               <attribute name="maxNodes">10000</attribute>
               <attribute name="timeToLiveSeconds">1000</attribute>
            </region>
            <!-- Region to store properties read once and rarely updated (no limit) -->
            <region name="/props">
               <attribute name="maxNodes">0</attribute>
               <attribute name="timeToLiveSeconds">0</attribute>
               <attribute name="maxAgeSeconds">0</attribute>
            </region>
         </config>
      </attribute>
   </mbean>


[color=blue]   <mbean
      code="com.evolab.evos.hibernate.EvosHibernateService"
      name="evolab:service=hibernate" >
      <depends>jboss:service=Naming</depends>
      <depends>jboss:service=TransactionManager</depends>
      <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends>
        <depends>evolab:service=SecondLevelCache</depends>
        
      <!-- evos attributes -->
      <!-- session attributes -->
      <attribute name="JndiName">java:/evos/hibernate/SessionFactory</attribute>
      <attribute name="Datasource">java:PortalDS</attribute>
      <attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
      <!-- Transaction integration -->
      <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
      <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
      <attribute name="FlushBeforeCompletionEnabled">true</attribute>
      <attribute name="AutoCloseSessionEnabled">true</attribute>
      <!-- Fetching options -->
      <attribute name="MaximumFetchDepth">5</attribute>
      <!-- Second-level caching -->
      <attribute name="SecondLevelCacheEnabled">true</attribute>
        <attribute name="CacheProviderClass">com.evolab.evos.hibernate.EvosTreeCacheProvider</attribute>
        <attribute name="CacheRegionPrefix">hib</attribute>
      <attribute name="QueryCacheEnabled">true</attribute>
      <!-- Logging -->
      <attribute name="ShowSqlEnabled">true</attribute>
      <!-- Mapping files -->
      <attribute name="MapResources">com/evolab/evos/model/core/Hierarchy.hbm.xml</attribute>
      
      <!-- <attribute name="Hbm2ddlAuto">create-drop</attribute>  -->
   </mbean>
</server>[/color]


Here is the com.evolab.evos.hibernate.EvosHibernateService:
It is only an extension of the org.hibernate.jmx.HibernateService to add some properties.

Code:
/**
* Implementation of <tt>HibernateServiceMBean</tt>.
* Extends <tt>HibernateService</tt><br>
* <br>
* All mapping documents are loaded as resources by the MBean.
* @see HibernateService
* @see HibernateServiceMBean
* @see org.hibernate.SessionFactory
* @author Philippe Marzin and Jean-Pierre Olivré
*/
public class EvosHibernateService extends HibernateService implements HibernateServiceMBean {

   private static final Log log = LogFactory.getLog(HibernateServiceMBean.class);
   private static final String EVOS_PROP_FILE = "hibernate.properties";
   private static final String EVOS_MAPPINGS_FILE = "mappings.properties";

   
   /**
    * Read properties from EVOS_PROP_FILE property file and add them prior to start
    */
   public void start() throws HibernateException {

      Properties props= new Properties();

      // load mappings
      try {
         InputStream defaultStream = ConfigHelper.getResourceAsStream(EVOS_MAPPINGS_FILE);
         props.load(defaultStream);
         defaultStream.close();
         String mappings= props.getProperty("mapping_files");
         if (mappings!=null)
            this.setMapResources(mappings);
      } catch (Exception  e){
         String msg = "Failed on reading properties from " + EVOS_MAPPINGS_FILE ;
         log.error(msg,e);
      }
      // load other properties
      try {
         InputStream defaultStream = ConfigHelper.getResourceAsStream(EVOS_PROP_FILE);
         props.clear();
         props.load(defaultStream);
         defaultStream.close();
      } catch (Exception  e){
         String msg = "Failed on reading properties from " + EVOS_PROP_FILE ;
         log.error(msg,e);
      }

      if (props!=null) {
         String key = null;
         String val = null;
           for (Enumeration e = props.propertyNames() ; e.hasMoreElements() ;) {
              key= (String) e.nextElement();
              val= props.getProperty(key);
               if (val != null) setProperty(key,val);
               log.info("PROPERTY:"+key+"="+val);
           }
        }
      
      super.start();
   }
      
}




Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 12:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You need to show logs and stacktrace for people to help you

_________________
Emmanuel


Top
 Profile  
 
 Post subject: sorry ... code and DEBUG trace
PostPosted: Thu Jan 05, 2006 12:40 pm 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
Sorry ...

I changed my test code to :

Code:
/**
    * this is a test to verify that it is inserting into the database
    * @jmx.managed-operation
    */
   public void test() throws Exception
   {
      SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/evos/hibernate/SessionFactory");
       Session session = sf.getCurrentSession();
       session.beginTransaction();
       Entity entity= new Entity();
       entity.setName("TEST");
       session.save(entity);
      session.getTransaction().commit();
      session.close();
}   


everything else is the same as above and I got :

Code:

2006-01-05 16:20:16,959 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/jmx-console].[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
RuntimeMBeanException: null Cause: org.hibernate.HibernateException: Unable to locate current JTA transaction
   at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:162)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:149)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:243)
   at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:208)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:247)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:85)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:67)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Thread.java:534)
Caused by: org.hibernate.HibernateException: Unable to locate current JTA transaction
   at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61)
   at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:604)
   at com.evolab.evos.service.ImportService.test(ImportService.java:148)
   at com.evolab.evos.service.ImportService.importData(ImportService.java:109)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   ... 33 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
To use sf.getCurrentSession(); you need to have a JTA transaction already started. This has actually been done to work inside a CMT environment

_________________
Emmanuel


Top
 Profile  
 
 Post subject: reuse the same hibernate service
PostPosted: Mon Jan 16, 2006 10:29 pm 
Newbie

Joined: Wed Jan 04, 2006 10:01 pm
Posts: 17
I know.

I am using an hibernate service in a CMT environment - so configured with JTA etc... and I want to use it also in the context of an mbean. How do I do that? It is confusing and not explained what is behind the scene. could you explain or what should I read?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.