How to connect jconsole to a remote tomcat on a linux machine resolving connection refused issue

Follow these steps:

open the jmx port on the tomcat jvm

fill the setEnv.sh (under TOMCAT-HOME/bin) with the following parameters


CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9011 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false"

It’s important to use CATALINA_OPTS and not JAVA_OPTS to resolve tomcat shutdown issue

On linux it’s likely to have a connection refused issue.

So start jconsole in debugging mode (jconsole -debug from a terminal). If you see a local (from server point of view) ip (e.g. 127.0.1.1) you must go on server, type hostname -i and see how the hostname it’s resolved by the server (e.g. 127.0.1.1). Then you must change the row of etc/hosts file where the server hostname is translated into the local ip (127.0.1.1). You can delete the row and use the DNS or insert the server ip.

References

http://muzso.hu/2008/11/28/connecting-to-a-tomcat-instance-with-jconsole

http://docs.oracle.com/javase/6/docs/technotes/guides/management/faq.html

Advertisements
Categories: My Work Tags: , , ,

How to resolve out of memory errors during maven test phase

November 5, 2012 Leave a comment

Sometimes during maven test phase, jvm out of memory errors occur. It must know that maven tests, are executed in a forked jvm (this for default).
So if you launch maven with the usual parameters -Xmx512M -XX:MaxPermSize=512M etc. etc. these will not propagated to the forked test jvm.
The solution is to use this parameter: -Dmaven.surefire.debug.

So if you want increase the memory used during the test execution, you must use a command like this:
mvn -Dmaven.surefire.debug=”-server -Xmx512M -XX:MaxPermSize=512M” test
here I’ve used the “-server” parameter to force the jvm to use the parallel throughput gc, increasing the performance of the forked jvm about releasing memory.

The maven reference: http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html

Categories: My Work Tags: , , ,

How to set access logging in tomcat (tested on version 5 and 6)

Add a valve to server.xml

<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="${catalina.base}/logs"
prefix="access_log"
fileDateFormat="yyyy-MM-dd.HH"
suffix=".log"
pattern="%t %H cookie:%{SESSIONID}c request:%{SESSIONID}r %m %U %s %q %r %T"
/>

http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Access_Log_Valve

Categories: My Work

How to change the maven plugin’s embedded tomcat port number

February 15, 2012 Leave a comment

Use the maven.tomcat.port system property.
E.g mvn -Dmaven.tomcat.port=8181 tomcat:run changes the port from 8080 (the default) to 8181

Categories: My Work

How to set timeout on burlap protocol caucho’s implementation

October 29, 2011 Leave a comment

Burlap can be easily used with spring, but with caucho’s implementation. actually it doesn’t seem possible to set the connection timeout.
The only method i’ve found is to set the default timeout for jvm’s http client with these jvm’s properties

Categories: My Work

How to generate serialVersionUID with intellij idea (no external plugin needed)

September 16, 2011 4 comments

Select the Serializzation issues inspections:

Then use the idea tools to generate the field (click on the lamp)

Categories: My Work

How to log transaction informations in jboss 4.2.3.GA

September 2, 2011 2 comments

You have to change two files:

1: jbossjta-properties.xml (for logging more info at arjuna level)

from:

...
<property name="com.arjuna.common.util.logging.DebugLevel"
            type="System" value="0x00000000">
...

to:

...
<property name="com.arjuna.common.util.logging.DebugLevel"
            type="System" value="0xffffffff">
...

2: jboss-log4j.xml (to configure log4j) adding the following lines

...
   <category name="com.arjuna">
      <priority value="DEBUG"/>
   </category>

  <category name="org.jboss.tm">
      <priority value="DEBUG"/>
   </category>

  <category name="org.jboss.resource">
      <priority value="TRACE"/>
   </category>
...

to filter log and show which resources was enlisted in a specific transaction, we can use a command like this:
grep -a “7f000101:c2ab:4e65eaa4:1eb” server.log | grep -a Enlisting

Categories: My Work