Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:35:45+00:00 2026-06-10T05:35:45+00:00

I had a perfectly working webapp that uses Tomcat and Hibernate + c3p0. I’m

  • 0

I had a perfectly working webapp that uses Tomcat and Hibernate + c3p0.
I’m configuring hibernate programmatically, loading the model classes using getClass().getResource(/a/b/model) and adding the annotated classes.

Now, I was asked to change c3p0 and use Tomcat JDBC Connection Pool instead. I followed a couple of articles and apparently everything is setup correctly. The problem now is that I’m getting errors when trying to load the model classes and configure hibernate.

The class that is configuring hibernate (HibernateConnector.class) is located inside a jar (MyJar) in webapps\MyApp\WEB-INF\lib\MyJar.jar.

If I do getClass().getResource(“HibernateConnector.class”) I correctly obtain the path:
jar:file:/C:/apache-tomcat-7.0.29/webapps/MyApp/WEB-INF/lib/MyJar.jar!/a/b/c/HibernateConnector.class

Since I removed c3p0 and configured Tomcat Connection Pool when I ask for getClass().getResource(/a/b/model) I get file:/C:/apache-tomcat-7.0.29/work/Catalina/localhost/MyApp/loader/a/b/model

I didn’t touch any of the code regarding the loading so obviously something weird is happening with the new configuration. Does anyone have an idea on how to solve this? And why is the path changing to work/Catalina….?

Sorry for the long post and thanks in Advance!!


Here are the changes I made to use the Tomcat Connection Pool.
In web.xml I added:

<resource-ref>
 <description>This is a MySQL database connection</description>
 <res-ref-name>jdbc/myDb</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

context.xml:

<Context antiJARLocking="true" path="MyApp">
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="30" maxIdle="10" maxWait="10000" name="jdbc/myDb" password="pass"
type="javax.sql.DataSource" url="jdbc:mysql://localhost/myDb" username="user"/>
</Context>

And configuring Hibernate programmatically:

props.put("hibernate.connection.datasource", "java:comp/env/jdbc/myDb");
props.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:35:46+00:00Added an answer on June 10, 2026 at 5:35 am

    After going through a lot of resources regarding class loaders and the way tomcat loads everything, I couldn’t find anything particularly useful for my problem (although I did learn a lot on the subject).

    Anyway, I started going through Tomcat’s documentation regarding the per-web-application context XML file that I listed in my question above.

    I switched antiJARLocking=true to antiResourceLocking=true thinking that something was being locked and that I needed more extensive antilocking efforts. With that setting I was able to run my app. But antiResourceLocking will have a significant negative impact in the startup time, so just to try I deleted the attribute (both default to false), and that also worked!!! :-D.

    My context.xml ended looking like this:

    <Context path="MyApp">
       <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="30" maxIdle="10"    maxWait="10000" name="jdbc/myDb" password="pass" type="javax.sql.DataSource" url="jdbc:mysql://localhost/myDb" username="user"/>
    </Context>
    

    Hope this helps someone in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have to admit, that I had this code working perfectly up until
Uh, and it's broken: I had a perfectly working regex that allowed all the
Up until yesterday I had a perfectly working app on my iPhone. I made
From previous experience I had been under the impression that it's perfectly legal (though
Had a page that was working fine. Only change I made was to add
My program has been working perfectly so far, but it turns out that I've
I had my form processes working perfectly but after renaming the form action to
Essentially, my route is working perfectly, Passenger seems to be loading - all is
So I had my listview working perfectly then I decided to add a context
I have a little app that downloads stock prices and was working perfectly (for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.