-->
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.  [ 2 posts ] 
Author Message
 Post subject: Tomcat + Hibernate + JOTM intergration problem
PostPosted: Thu Mar 09, 2006 7:35 am 
Newbie

Joined: Thu Mar 09, 2006 7:02 am
Posts: 6
Location: Kiev
Hello,

I'm trying to use Hibernate + Tomcat in cluster. For cache provider I chose JBoss Treecache (it's only one provider that I can use in cluster with supporting query cache).

The case strategy is "transactional"(ready-only is not applicable for my system), so I need in any case to specify hibernate.transaction.manager_lookup_class. So I decided to integrate JOTM in Tomcat and use org.hibernate.transaction.JOTMTransactionManagerLookup.

I integrated JOTM in Tomcat: Copied jars to common/lib:
* jotm.jar - JOTM
* jotm_jrmp_stubs.jar - JOTM stubs for RMI/JRMP
* jotm_iiop_stubs.jar - JOTM stubs for RMI/IIOP
* jta-spec1_0_1.jar - JTA
* jts1_0.jar - JTSTM (Java Transaction Service)
* jonas_timer.jar - JOnAS timer
* commons-logging.jar
* log4j.jar - Log4JTM
* commons-cli.jar - CLITM (Command-line interface) library (used only by standalone JOTM)

The problem is when I'm trying to begin transaction, I'm getting an Exception. Actually the exception even happend when I do :
UserTransaction ut = (UserTransaction)ctx.lookup("java:comp/UserTransaction"); in servlet.
Does it mean that Tomcat can't add to JNDI UserTransactionFactory ?

I would appreciate your help a lot,
Thank you very much

Hibernate version: 3.1
Tomcat version: 5.5
JOTM version: 2.0.10

Mapping documents:

server.xml
<Context path="/hiber" reloadable="true" docBase="C:\dev\hiber" workDir="C:\dev\hiber\work">

<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"/>
<ResourceParams name="UserTransaction">
<parameter>
<name>factory</name>
<value>org.objectweb.jotm.UserTransactionFactory</value>
</parameter>
<parameter>
<name>jotm.timeout</name>
<value>60</value>
</parameter>
</ResourceParams>

</Context>

hibetnate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory name="foo">
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<mapping resource="hibernate/Image.hbm.xml"/>
<class-cache
class="hibernate.Image"
region="wotan"
usage="transactional"/>
</session-factory>
</hibernate-configuration>

hibernate.properties

######################
### Query Language ###
######################

## define query language constants / function names

hibernate.query.substitutions yes 'Y', no 'N'


#################
### Platforms ###
#################

## Oracle

#hibernate.dialect org.hibernate.dialect.OracleDialect
hibernate.dialect org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username sstmobil_template
hibernate.connection.password vignette
hibernate.connection.url jdbc:oracle:thin:@clapanther:1521:sspant


#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 5



###########################
### C3P0 Connection Pool###
###########################

hibernate.c3p0.max_size 10
hibernate.c3p0.min_size 2
hibernate.c3p0.timeout 5000
hibernate.c3p0.max_statements 100
hibernate.c3p0.idle_test_period 3000
hibernate.c3p0.acquire_increment 1
hibernate.c3p0.validate false



#######################
### Transaction API ###
#######################


## the Transaction API abstracts application code from the underlying JTA or JDBC transactions

hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory
#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory



## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager


hibernate.transaction.manager_lookup_class org.hibernate.transaction.JOTMTransactionManagerLookup



##############################
### Miscellaneous Settings ###
##############################

## print all generated SQL to the console

hibernate.show_sql true


## format SQL in log and console

hibernate.format_sql true


## set the maximum depth of the outer join fetch tree

hibernate.max_fetch_depth 1


## set the default batch size for batch fetching

hibernate.default_batch_fetch_size 4


#####################
### JDBC Settings ###
#####################

## specify a JDBC isolation level

hibernate.connection.isolation 2


## enable batch updates even for versioned data

hibernate.jdbc.batch_versioned_data true


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true


##########################
### Second-level Cache ###
##########################

## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)

hibernate.cache.use_minimal_puts true


## set a prefix for cache region names

hibernate.cache.region_prefix wotan



## enable the query cache

hibernate.cache.use_query_cache true


## store the second-level cache entries in a more human-friendly format

#hibernate.cache.use_structured_entries true


## choose a cache implementation

hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider




Code between sessionFactory.openSession() and session.close():
session.beginTransaction();

Image a = (Image)session.load(Image.class, new Long(40438));
System.out.println("Image "+a.getName());

session.getTransaction().commit();

Full stack trace of any exception that occurs:
8047 [http-8080-Processor25] INFO org.hibernate.impl.SessionFactoryObjectFactory - Factory name: foo
8047 [http-8080-Processor25] INFO org.hibernate.util.NamingHelper - JNDI InitialContext properties:{}
8047 [http-8080-Processor25] INFO org.hibernate.impl.SessionFactoryObjectFactory - Bound factory to JNDI name: foo
8047 [http-8080-Processor25] WARN org.hibernate.impl.SessionFactoryObjectFactory - InitialContext did not implement EventContext
8062 [http-8080-Processor25] INFO org.hibernate.cache.UpdateTimestampsCache - starting update timestamps cache at region: wotan.org.hibernate.cache.UpdateTimestampsCache
8062 [http-8080-Processor25] INFO org.hibernate.cache.StandardQueryCache - starting query cache at region: wotan.org.hibernate.cache.StandardQueryCache
9172 [http-8080-Processor25] ERROR org.hibernate.transaction.JTATransaction - Could not find UserTransaction in JNDI
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:98)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:53)
at org.hibernate.jdbc.JDBCContext.getTransaction(JDBCContext.java:173)
at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1300)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1308)
at hiber.HiberServlet.doGet(HiberServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.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:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
9187 [http-8080-Processor25] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/hiber].[HibernateServ] - Servlet.service() for servlet HibernateServ threw exception
org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:64)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:53)
at org.hibernate.jdbc.JDBCContext.getTransaction(JDBCContext.java:173)
at org.hibernate.impl.SessionImpl.getTransaction(SessionImpl.java:1300)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1308)
at hiber.HiberServlet.doGet(HiberServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.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:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:98)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
... 21 more


Name and version of the database you are using: Oracle 9

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
Oleksandr Markelov
SCJP, SCWCD, SCBCD


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 09, 2006 10:42 am 
Newbie

Joined: Thu Mar 09, 2006 7:02 am
Posts: 6
Location: Kiev
I found the problem :
http://static.raibledesigns.com/downloa ... -jotm.html

I should make changes in server.xml.

<Transaction factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60"/>

_________________
Oleksandr Markelov
SCJP, SCWCD, SCBCD


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.