Total Pageviews

Showing posts with label tomcat. Show all posts
Showing posts with label tomcat. Show all posts

Monday, March 05, 2012

Stopping Tomcat with remote JMX enabled through script

Tomcat comes with handy start and stop scripts in the bin folder. Those scripts are working very well.
With this script it's pretty simple to start/stop Tomcat on linux systems.

But if you decide to add jmxremote properties to your start script using $JAVA_OPTS variable, stopping of Tomcat (and mostly any other AppServer started with these options) will not succeed.

There will be an error message stating that the address is already in use (BindException) and you have to kill the process manually.

The solution is very simple. Make sure the stop command does not contain the jmxremote properties definition. So you might declare a $JAVA_OPTS for the start command as usual:

 JAVA_OPTS="-Xmx256m -XX:MaxPermSize=128m 
-Dcom.sun.management.jmxremote.port=3336 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Djava.rmi.server.hostname=192.168.1.5"  


but for the stop command you must omit those jmx definitions and declare it for example like this:

 JAVA_OPTS_STOP="-Xmx256m -XX:MaxPermSize=128m"  
.
The stop command then forks a JVM with the $JAVA_OPTS_STOP definition NOT trying to open another listening socket on an already bound port.


Wednesday, September 12, 2007

Spring, JPA and using managed datasources with Tomcat

I was struggling for a few weeks now to get managed datasources in Tomcat6 to work with Spring and JPA. Well, finally it seems I have found a solution (I cannot prove it, because I did not implement it yet, but it looks good to me so far).
I have found two blogs covering this issue you might want to check out:
  1. http://turgayzengin.blogspot.com/2007/09/multiple-persistence-units-with-spring.html
  2. http://asrijaffar.blogspot.com/2007/02/spring-jpa-tomcat.html

Monday, August 27, 2007

Tomcat not removing files when using undeploy task

I am using Tomcat 6.0.14 for a new project and Maven2 for build management. Recently I wanted to deploy and undeploy my webapp using the Maven2 cargo plugin. Deploy works fine, but undeploy does not remove all JARs in the webapp and work directory of my Tomcat installation.
This seems to be a general issue with the Tomcat Manager component. To avoid these problems simply put the following attributes into your context.xml

antiJARLocking="true"
antiResourceLocking="true"