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 6587137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:52:47+00:00 2026-05-25T16:52:47+00:00

I have spring mvc application and Tomcat 7.0.21 as a servlet container. And when

  • 0

I have spring mvc application and Tomcat 7.0.21 as a servlet container.
And when I’m trying to use jdbcTemplate in my application it doesn’t redeploy correctly –
it prevents jvm from cleaning PermGen memory.
The simple example of bad code is the following
(of course breaking mvc concept for the sake of simplicity):

@Controller
class MainController {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    public void setDataSource(DataSource  dataSource) {
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }
    @RequestMapping("/")
    public String mainPage() {  
        jdbcTemplate.queryForObject("SELECT val FROM tbl WHERE id=1",
            String.class);
        return "main";
    }
}

without jdbcTemplate.queryForObject(...) it works perfectly, but
with it when deploying to tomcat it says that:

Sep 21, 2011 1:54:38 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/my] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 21, 2011 1:54:38 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/my] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

And after that I can see in VisualVM a growth in PermGen each time the app is redeployed.

Of course I can just restart my production server each time when I want
to redeploy my app, but I want to figure out what’s wrong.

P.S.: datasource implementation:

@Configuration
public class ApplicationConfig {
    @Bean
    DataSource dataSource(@Value("${jdbc.driver}") String driver, 
        @Value("${jdbc.url}") String url, @Value("${jdbc.user}") String user,
        @Value("${jdbc.password}") String password) {

        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setUsername(user);
        ds.setPassword(password);
        return ds;
    }
}
  • 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-05-25T16:52:47+00:00Added an answer on May 25, 2026 at 4:52 pm

    Unregistering JDBC drivers should be handled for you by the data source. See this related question. So check for a newer version of your data source implementation. BasicDataSource is not the best option for a datasource. Try using c3p0 and see if the problem is reproduced.

    Even if it isn’t, Tomcat clears that for you. Btw, upgrade your tomcat as well – it has an improvement for DriverManager leaks in the latest version.

    So, the PermGen issue lies somewhere else. It has been a long-known issue with tomcat, but they claim it it the application code that leaks. And this is mostly true, but it is hard to track what remains unregistered. Tomcat tries to clear common reasons for the PermGen issue, but can’t cover everything.

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

Sidebar

Related Questions

I have a Spring MVC application trying to use a rich domain model, with
I have a spring MVC based web application running on Tomcat 7.0. We are
I have SPRING MVC web application (my.war). It deploys on Tomcat 6 server to
I have a tomcat - spring mvc - jsp application. I have discovered that
We have Spring MVC application. We are trying to integrate the Spring security in
I have been trying to get a spring MVC test application to work. Here
I have a Spring Web MVC application that I'd like to serve a large,
I am using Spring MVC to build my web application, and I have a
I use Spring MVC 3.0 and JSP. I have an object: public class ObjectWrapper
Hello I'm building a Spring MVC web application that runs on Tomcat 6.0.20 and

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.