Showing posts with label tomcat7. Show all posts
Showing posts with label tomcat7. Show all posts

Friday, December 1, 2017

java.lang.IllegalStateException while reloading Tomcat Server

I want to give you couple of choices. You can try it. Any option can fulfill your demand.
  1. Restart your tomcat and apache server because a long time of using, it keeps older version of your application.
  2. Clean your tomcat temp directory and restart
  3. As stated in error,
The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
It may be the real cause that at this moment you are in debugging mode and it doesn't clear the running thread. so remove your break point and run it not debugging
  1. If your code contains any kind of thread which are not properly terminated, then this type of error may occur. That you have init() method but no destroy() method, then this type of error may occur. For details, you can follow the link - http://www.javaspecialists.eu/archive/Issue056.html
  2. if the webapp has stopped, or is stopping, that means that the .war file or WEB-INF/web.xml timestamp changed, and the webapp might be reloading. Please check timestamp is OK or not.
  3. To turn it off, set reloadable="false" in the context definition of your app. It might be tomcat's server.xml. In details solution: The tomcat's server.xml of the reloadable Context is set to false. For example:
Context path="/expert" docBase="expert" debug="0" reloadable ="false"/>
The solution is easy, as long as the tomcat's server.xml in reloadable = "true" into false on the line, but to do so would lose the advantage of hot deployment, and for the development is not very convenient, simply change it or not. This error does not matter.
Error principle:
The reason is because the tomcat restart, because the previous tomcat thread has not completely shut down, restart tomcat will report this exception, but this does not affect the normal use, just jump abnormal annoying people. Used hibernate, spring or other large components, when a WEB application system has a lot of class,
if you turned the Tomcat reloadable = true, then whenever the relevant documents change, Tomcat stops web app and frees up memory, and then reload web app. it may be a huge project. So we always think if there is only a certain class of overloaded functions, will greatly meet our debugger.
UPDATE: For code related issue
First, I want to tell you that I have given you some solutions for tomcat basis. Now I want to give you a solution for code basis. Would you please cross check your code with this issue? Please follow the URL.
  1. http://www.coderanch.com/t/660126/Wiki/Illegal-State-Exception
UPDATE: For MySQL related issue
  1. There are 2 issues.
    • This web application instance has been stopped already. Could not load java.net.BindException.
    • This web application instance has been stopped already.Could not load com.mysql.jdbc.
This is because the MySQL JDBC driver on the application under the WEB-INF/lib directory, in the re-release of its loaded twice, so long as it can be copied to %TOMCAT_HOME%/lib can solve the problem. We can solve these two anomalies MySQL drivers from the WEB-INF/lib folder moved to %TOMCAT_HOME%/lib.
  1. I suspect this might be happening after the web application is restarted, where it's down for a short period of time. Then some finalize() method in the code is probably trying to do some cleanup too late. Whether or not that's in your code or the MySQL driver I can't say. You definitely should only have one version of a jar in a directory at a time. You might want to upgrade it to the latest (5.1.38 right now) in case something has been fixed that might be affecting you.(Number 9 is copied from @WhiteFang34)
Original Link: java.lang.IllegalStateException while reloading Tomcat Server

Slow Issue: Web application loading takes more time in tomcat7

For performance related issue, we need to follow the given rules:
  1. We can equalize and emphasize the size of xms and xmx for effectiveness.
  -Xms2048m
  -Xmx2048m
  1. We can also enable the PermGen to be garbage collected.
-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
  1. If the page changes too frequently to make this option logical, try temporarily caching the dynamic content, so that it doesn't need to be regenerated over and over again. Any techniques you can use to cache work that's already been done instead of doing it again should be used - this is the key to achieving the best Tomcat performance.
  2. If there any database related issue, then can follow sql query perfomance tuning
  3. rotating the Catalina.out log file, without restarting Tomcat.
In details,There are two ways.
The first, which is more direct, is that you can rotate Catalina.out by adding a simple pipe to the log rotation tool of your choice in Catalina's startup shell script. This will look something like:
"$CATALINA_BASE"/logs/catalina.out WeaponOfChoice 2>&1 &
Simply replace "WeaponOfChoice" with your favorite log rotation tool.
The second way is less direct, but ultimately better. The best way to handle the rotation of Catalina.out is to make sure it never needs to rotate. Simply set the "swallowOutput" property to true for all Contexts in "server.xml".
This will route System.err and System.out to whatever Logging implementation you have configured, or JULI, if you haven't configured.

Monday, January 30, 2017

CATALINA_HOME vs. CATALINA_BASE

Why are these two variables separated?
catalina.home points to the location of the common information.
catalina.base points to the directory where all the instance specific information are held.
So you have 1 home and can have more than 1 base.
When should they be separated? When should these two variables be the same?
If you have 1 tomcat you can set them to the same value but good practice would suggest you plan ahead and keep them separate: you never know if you need more than one tomcat. Ubuntu started following this way of thinking due to it being more logical: it makes it easier to run 2+ tomcats but does not disable running 1 tomcat where setting them both to the same value would require everyone to edit the base value. Makes more sense to keep them different.
What does this allow the administrator to do?
Allow for more than 1 tomcat to run at the same time where each tomcat instance can have their own apps.
What do you then place into each directory?
Home contains the binairy.
Base contains conf, logs, webapps, work and temp. 1 for every tomcat instance.

Where is catalina_base and catalina_home located for tomcat6?

Both are stored and can be set in /etc/default/tomcat6. By default, CATALINA_HOME is /usr/share/tomcat6, and CATALINA_BASE is /var/lib/tomcat6

Resource Link: http://askubuntu.com/a/46759