tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Trouble loading MS SQl Server database driver in Tomcat 7.0.37
Date Tue, 02 Apr 2013 17:33:44 GMT


Thanks for the response. Yes, I checked and the HibernateUtil.class is where you said it would
be. I also find hibernate3.jar under my WEB-INF/lib directory. Is there some kind of environment
variable I need to set so that the HibernateUtil.class file is found?




-----Original Message-----
From: Neven Cvetkovic <>
To: Tomcat Users List <>
Sent: Tue, Apr 2, 2013 12:45 pm
Subject: Re: Trouble loading MS SQl Server database driver in Tomcat 7.0.37


My bad, I gave you the wrong code for testing database connections. I was
just typing the code from my head, I did not test it myself. I probably
should have used Eclipse before I gave you the code ;)

Here's a better version:

    javax.naming.InitialContext naming = null;
    *java.sql.Connection* connection = null;
    *javax.sql.DataSource datasource = null;*
    try {
        naming = new javax.naming.InitialContext();
        datasource = (*javax.sql.DataSource*)
        connection = datasource.getConnection();
        out.println("Connection has successfully obtained from datasource.
connection=" + connection);
    } catch (javax.naming.NamingException ne) {
        out.println("Datasource is not bound to JNDI: " + ne);
    } catch (*java.sql.SQLException* sqle) {
        out.println("Problem with a SQL connection: " + sqle);
    } catch (Exception e) {
        out.println("Something else went wrong: " + e);

So the correct classes are:
java.sql.Connection, java.sql.SQLException, javax.sql.DataSource (thanks

Again, this is probably a very dirty way to test database connection pools
(datasources) managed by your Tomcat, and it just helps you troubleshoot
your connection setup.

About your second issue (unrelated) - Dan had a great question - check
where your *com.systemsmadesimple.hibernate.HibernateUtil* class is
deployed. This is a class that your developers wrote, and probably resides
in SystemsMadeSimple.war/WEB-INF/classes/com/systemsmadesimple/hibernate/Hibernate.class,
unless packaged as JAR.

Also, check that you have the Hibernate jar files as well. JBoss (I assume
you are migrating from JBoss 5.x) probably has Hibernate libraries
included, Tomcat does not, your application needs to pack these libraries.
All application-packaged third-party libraries (or your application shared
libraries) should reside in SystemsMadeSimple.war/WEB-INF/lib
directory. Although,
I think your previous console output showed that your Hibernate code was
being parsed, so Hibernate jars are probably packaged properly.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message