-->
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.  [ 6 posts ] 
Author Message
 Post subject: PB with hibernate / MySQL as tomcat 5
PostPosted: Wed Dec 22, 2004 9:38 am 
Newbie

Joined: Tue Aug 17, 2004 5:32 am
Posts: 4
i have a war with classes that use hibernate. this component has been build and tested under zindows without error (tomcat + mysql on localhost)

second stage i try to put this war on a linux machine (tomcat 5 + mysql 4.0.22) and i already have the same pb of jdbc connection:

at the beginning i believed that the pb came from the policy in tomcat but i have delete all policy and start tomcat without the option -policy.

i have test my db user with mysql ... no pb.
i use chainsow to trace log and hibernate say me the it found the right info
about the db (driver and jdbc url seems to be fine)
my url is: connection.url=jdbc:mysql://localhost:3306/bd
driver:connection.driver_class=com.mysql.jdbc.Driver

i have turn log4j level to TRACE and no more errors appears.
this error qppeqrs qt the beginning in the class:
net.sf.hibernate.cfg.SettingsFactory when it try to get metadata from db>

i use a debian system without a deb package of tomcat5 (from http://apt.leapster.org/tomcat).
I don't use jndi ressource to get a jdbc connection, is it important ?


any help is welcome
Thx
Christophe


Hibernate version:2.1.4

Mapping documents:<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>

<!-- Settings for a remote MySQL database. -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property> -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/bd</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>

<!-- Use the C3P0 connection pool. -->
<!-- <property name="c3p0.min_size">5</property> -->
<!-- <property name="c3p0.max_size">20</property> -->
<!-- <property name="c3p0.timeout">1800</property> -->
<!-- <property name="c3p0.max_statements">50</property> -->

<!-- Use EHCache but not the query cache. -->
<!-- <property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property> -->
<!-- <property name="cache.use_query_cache">false</property> -->
<!-- <property name="cache.use_minimal_puts">false</property> -->
<!-- properties -->


<!-- Print SQL to stdout. -->
<property name="show_sql">true</property>

<!-- mapping files -->
<mapping resource="org/jteam/bd/hibernate/Album.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Realisation.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Auteur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Collection.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Editeur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Edition.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Pays.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Serie.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/User.hbm.xml"/>

</session-factory>

</hibernate-configuration>


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

Full stack trace of any exception that occurs:java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690)
at com.mysql.jdbc.Connection.<init>(Connection.java:427)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3302)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3282)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2227)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:282)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:228)
at org.jteam.bd.MainPage.initTextTitle(MainPage.java:60)
at org.jteam.bd.MainPage.<init>(MainPage.java:38)
at org.jteam.bd.MyBdInstance.initContent(MyBdInstance.java:120)
at org.jteam.bd.MyBdInstance.init(MyBdInstance.java:91)
at nextapp.echo.EchoInstance.doInit(EchoInstance.java:186)
at nextapp.echoservlet.InstancePeer.init(InstancePeer.java:792)
at nextapp.echoservlet.Initializer.service(Initializer.java:229)
at nextapp.echoservlet.Connection.process(Connection.java:459)
at nextapp.echoservlet.EchoServer.process(EchoServer.java:314)
at nextapp.echoservlet.EchoServer.doPost(EchoServer.java:234)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)


Name and version of the database you are using:mysql 4.0.22

The generated SQL (show_sql=true):not yet because the error is on the connection

Debug level Hibernate log excerpt:TRACE


Top
 Profile  
 
 Post subject: Re: PB with hibernate / MySQL as tomcat 5
PostPosted: Wed Dec 22, 2004 9:46 am 
Newbie

Joined: Wed Dec 15, 2004 9:14 am
Posts: 4
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused

You probably don't have sufficient permissions in the mysql database to access your database.
See if user@host.domain has permissions in the user table and database table.

Loïc


ctof wrote:
i have a war with classes that use hibernate. this component has been build and tested under zindows without error (tomcat + mysql on localhost)

second stage i try to put this war on a linux machine (tomcat 5 + mysql 4.0.22) and i already have the same pb of jdbc connection:

at the beginning i believed that the pb came from the policy in tomcat but i have delete all policy and start tomcat without the option -policy.

i have test my db user with mysql ... no pb.
i use chainsow to trace log and hibernate say me the it found the right info
about the db (driver and jdbc url seems to be fine)
my url is: connection.url=jdbc:mysql://localhost:3306/bd
driver:connection.driver_class=com.mysql.jdbc.Driver

i have turn log4j level to TRACE and no more errors appears.
this error qppeqrs qt the beginning in the class:
net.sf.hibernate.cfg.SettingsFactory when it try to get metadata from db>

i use a debian system without a deb package of tomcat5 (from http://apt.leapster.org/tomcat).
I don't use jndi ressource to get a jdbc connection, is it important ?


any help is welcome
Thx
Christophe


Hibernate version:2.1.4

Mapping documents:<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>

<!-- Settings for a remote MySQL database. -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property> -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/bd</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>

<!-- Use the C3P0 connection pool. -->
<!-- <property name="c3p0.min_size">5</property> -->
<!-- <property name="c3p0.max_size">20</property> -->
<!-- <property name="c3p0.timeout">1800</property> -->
<!-- <property name="c3p0.max_statements">50</property> -->

<!-- Use EHCache but not the query cache. -->
<!-- <property name="cache.provider_class">net.sf.ehcache.hibernate.Provider</property> -->
<!-- <property name="cache.use_query_cache">false</property> -->
<!-- <property name="cache.use_minimal_puts">false</property> -->
<!-- properties -->


<!-- Print SQL to stdout. -->
<property name="show_sql">true</property>

<!-- mapping files -->
<mapping resource="org/jteam/bd/hibernate/Album.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Realisation.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Auteur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Collection.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Editeur.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Edition.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Pays.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/Serie.hbm.xml"/>
<mapping resource="org/jteam/bd/hibernate/User.hbm.xml"/>

</session-factory>

</hibernate-configuration>


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

Full stack trace of any exception that occurs:java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690)
at com.mysql.jdbc.Connection.<init>(Connection.java:427)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3302)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3282)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2227)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:282)
at org.jteam.bd.util.HibernateUtil.find(HibernateUtil.java:228)
at org.jteam.bd.MainPage.initTextTitle(MainPage.java:60)
at org.jteam.bd.MainPage.<init>(MainPage.java:38)
at org.jteam.bd.MyBdInstance.initContent(MyBdInstance.java:120)
at org.jteam.bd.MyBdInstance.init(MyBdInstance.java:91)
at nextapp.echo.EchoInstance.doInit(EchoInstance.java:186)
at nextapp.echoservlet.InstancePeer.init(InstancePeer.java:792)
at nextapp.echoservlet.Initializer.service(Initializer.java:229)
at nextapp.echoservlet.Connection.process(Connection.java:459)
at nextapp.echoservlet.EchoServer.process(EchoServer.java:314)
at nextapp.echoservlet.EchoServer.doPost(EchoServer.java:234)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)


Name and version of the database you are using:mysql 4.0.22

The generated SQL (show_sql=true):not yet because the error is on the connection

Debug level Hibernate log excerpt:TRACE


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2004 9:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Try getting a plain JDBC connection to work first.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 10:04 am 
Newbie

Joined: Tue Aug 17, 2004 5:32 am
Posts: 4
i'm sure that the db user is right (in fact root with no password and authorized from % host ...)

i don't understand because the catalina.policy are the same under windows and linux. I have tried to set AllPermission for all webapps without succes)
i 'avce tried with tomcat 5.0, 5.5 ... the same error

in fact is i believe that the pb come from mysql driver. i have the feeling that it is not loaded by the classloader .. i don't know why .. but i'm sure the property is correctly read from my hibernate.xml (when i set error level to trace i can see a msg from the hibernate that it read the right classe name...

what tou you mean by plain connection ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 10:08 am 
Newbie

Joined: Tue Aug 17, 2004 5:32 am
Posts: 4
another point, i have an information message from C3P0:
> Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@c2cf83 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@140fee [ acquireIncrement -> 1, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 50, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1c5af2e [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost/bd, properties -> {user=root, password=} ] , propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -> null, numHelperThreads -> 3 ]

And i feel strange that the DriverClass is null .... ans i have no other error msg. if i test wihtout C3P0 pool, i have the same pb of ConnectionRefused.

Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 5:44 am 
Newbie

Joined: Tue Aug 17, 2004 5:32 am
Posts: 4
ok,

i have found the pb.
it cames from mysql installation. in fact, on a debian, by default the TCP_IP is not activate (just unix socket) and i don't why, but the jdbc driver try to open a TCP/IP connection (even if the both process are on the same machine)

Christophe


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