1

Similar questions are there but none answers by concern ..

Here it says that "One hack to get around this problem is that JDBC driver to be loaded by common class loader than application classloader and you can do this by transferring driver's jar into tomcat lib instead of bundling it on web application's war file

Did not understand what it means to load by common class loader and how is it different from application classloader.

3 Answers 3

3

This means that the ClassLoader loading the JDBCDriver class is the class loader of your application server which is a parent of your application classloader. Therefore, the driver is available for every application on your server and not reloaded on every restart of your application (which can lead to permgen trouble if you are not unregistering it properly)

Sign up to request clarification or add additional context in comments.

Comments

1

Every time you deploy an application and load a class from there (to use it), it will be loaded by the application classloader. the more applications, the more "same" classes are loaded. If you use tomcats' "common" classloader, the class will only be loaded once per tomcat installation.

1 Comment

Are you sure this is how it works ? Loading class just once irrespective of how many times we are starting the application is possible ?
1

OutOfMemoryError: PermGen space is usually only a problem if your using the hot redeploy feature of Tomcat. It can also occur if you simply have a very large number of classes being used in your deployment.

Increasing the amount of PermGen available in the VM will solve the large number of classes problem. That can be done by adding -XX:MaxPermSize=128m or -XX:MaxPermSize=256m to the environment variable JAVA_OPTS or CATALINA_OPTS (this can usually be done in Tomcat launch script). If you are launching Tomcat directly you can export these environment variables in your shell.

Unfortunately this doesn't completely solve the redeploy issue it only make it so you can redeploy more times before running out of PermGen. To fix this issue you'll need to make sure your web app unloads correctly and completely. This involves making sure all threads started by your webapp stop, and JDBC drivers loaded are unregistered properly among other things. The other way to solve this is to not use hot redeploy and restart Tomcat when making changes to the application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.