-->
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.  [ 4 posts ] 
Author Message
 Post subject: Session.beginTransaction throws exception
PostPosted: Tue Feb 03, 2004 4:46 am 
Newbie

Joined: Sat Dec 06, 2003 5:09 am
Posts: 1
Hello everyone,

I am new to Hibernate and I am testing it for my app.

My setup:

Tomcat 4.1 using Hibernate 2.1 ,Struts 1.02 and DB2 8.1

I used to test my app using MySQL 3.x and it worked fine.

I recreated all the tables in DB2, changed the config settings and now I get errors in my action servlet.

The line of code that generated the error is

Transaction tx = session.beginTransaction();


My hibernate.config.xml contain these values

...

<property name="connection.datasource">java:comp/env/jdbc/portal</property >
<property name="show_sql">false</property>
<property name="hibernate.connection.driver.class">COM.ibm.db2.jdbc.app.DB2Driver</property>
<property name="hibernate.connection.url">jdbc:db2:valkyrie</property>
<property name="hibernate.connection.username">abc</property >
<property name="hibernate.connection.password">xyz</property>
<property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.hbm2ddl.auto">auto</property>
<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>

...

Here is the printStackTrace() log:

java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSo
urce.java:125)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:329)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnectio
n(DatasourceConnectionProvider.java:56)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:257
)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3157)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3140)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.ja
va:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(
JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2
158)
at valkyrie.web.struts.PortalLoginAction.perform(PortalLoginAction.java:
77)
at org.apache.struts.action.ActionServlet.processActionPerform(ActionSer
vlet.java:1787)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:158
6)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
3)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:380)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:533)
at java.lang.Thread.run(Thread.java:536)


Looking at the trace I seen that it has something to do with DBCP connection. I don't know what to make of it as the error was generated by getting a hibernate transaction handle and so I posted this problem here, hoping that someone here may have encountered this before.

Can somebody who's using tomcat/hibernate/struts/DB2 help me on this? Thank you.

Regards,
Clarence


Top
 Profile  
 
 Post subject: Possible lead
PostPosted: Thu Feb 05, 2004 12:16 pm 
Newbie

Joined: Wed Nov 05, 2003 9:10 am
Posts: 6
I had a problem that was extremely similar to this.

My UnsupportedOperationException was being thrown by PoolableDataSource because the createConnection(String uname, String password) method does nothing but throw this exception.

The source of this problem was that I was providing username and password information in both ( server.xml & web.xml ) AND ( hibernate.cfg.xml )

Providing the username and password in the latter will force the Commons DBCP pool to call the method mentioned above, using the connection propreties as parameters. If these properties do not exists, providing the username and password in the Tomcat XML files allows the PoolableDataSource object to look to its own fields to find the username and password-- and most importantly does not throw that UnsupportedOperationException.

My environment is almost completely different, and my error was happening on a different line, so this may not be your issue. If this doesn't work, try looking in the appropriate source file for the PoolingDataSource that you have.


Top
 Profile  
 
 Post subject: Session.beginTransaction throws UnsupportedOperationExceptio
PostPosted: Thu Jun 24, 2004 11:03 pm 
Newbie

Joined: Wed Jun 02, 2004 7:06 pm
Posts: 8
In my case - now 4 months after yours, but I post for those who may search for this later - :o) there was a hibernate.properties file (with no Dialect uncommented) ahead in the classpath of the hibernate.properties file that I thought I was using! I deleted the first hibernate.properties and all was ok.


Top
 Profile  
 
 Post subject: Re: Possible lead
PostPosted: Thu Jan 26, 2006 8:21 am 
Beginner
Beginner

Joined: Fri Jan 13, 2006 8:07 am
Posts: 29
bigfleet wrote:
I had a problem that was extremely similar to this.

My UnsupportedOperationException was being thrown by PoolableDataSource because the createConnection(String uname, String password) method does nothing but throw this exception.

The source of this problem was that I was providing username and password information in both ( server.xml & web.xml ) AND ( hibernate.cfg.xml )

Providing the username and password in the latter will force the Commons DBCP pool to call the method mentioned above, using the connection propreties as parameters. If these properties do not exists, providing the username and password in the Tomcat XML files allows the PoolableDataSource object to look to its own fields to find the username and password-- and most importantly does not throw that UnsupportedOperationException.

My environment is almost completely different, and my error was happening on a different line, so this may not be your issue. If this doesn't work, try looking in the appropriate source file for the PoolingDataSource that you have.



Hi,

Thank you very much. This was exactly my problem. I had given username and password in both server.xml and hibernate.cfg.xml. I solved the problem by removing the username and password that I had given in the hivernate.cfg.xml. Now its working.

Thanks,


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