Category Archives: Tomcat

Tomcat – Disable JSESSIONID in URL

When doing Testing to cover PCI Requirement 6, i face with issue exposed session id  in url, so i write this guie to help other one sort down their time to fix this issue. To fix this issue we have some solutions depend on environment.;jsessionid=557206C363324F1267A24AB769CA0DE4529.node01

1.Tomcat 6

In tomcat 6 we can disable by using disableURLRewriting. We create context.xml file and put following lines and make sure cookie is enable

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="PATH_TO_WEBAPP" path="/CONTEXT" disableURLRewriting="true">

2 . Tomcat 7 or above

With Tomcat 7 or above we can add follow lines into web.xml


Or we can using programatic



How to configure Apache 2 with Tomcat

Today i will guide how to install and configure apache 2 with tomcat on Centos server using mod_proxy plugin

Scenario of this configuration:

  • Server A install web server apache and have domain domain already point to server A)
  • Server B install tomcat server listen on port 8080
  • We need allow user access application run on tomcat server in server B through  domain

Continue reading How to configure Apache 2 with Tomcat

Eclipse and Tomcat:java.lang.OutOfMemoryError: PermGen space

When run web application in eclipse with tomcat server you maybe get this issue:

java.lang.OutOfMemoryError: PermGen space



Increase JVM parameters


You do as follow step to do that:

  • Open server on eclipse server tab
  • Choose Open launch configuration
  • Open Agurment-> add above parameters with increase to VM agurment session

For example i usually use


deploy jax-ws or metro web services on tomcat server

When deploy jax-ws application on tomcat you maybe get this issue

SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError:$Responses;

This error occur cause the version JAXWS we use difference with the version JAX-WS ship with java. We can check version ship with java by run wsimport

in $JAVA_HOME/bin by follow command:

wsimport -version

So solution you can using wsimport or wsgen ship with java version to build web service or web service client.
But what happend if you still want using new version JAX-WS?
Well let me show you solution. The answer for that is using the endorsed overriding mechanism.
This guide will help you on Tomcat 6 and 7.

  • Create folder endorsed in $CATALINA_HOME
  • Copy following file in $JAXWS_HOME/lib jax-ws.api.jar,jaxb-api.jar,webservices-api.jar into endorsed

With above change your tomcat will work well with version JAX-WS that you want.
If it still not work so that must has problem on tomcat’s startup script(linux/unix). In that case you must add following parameter into startup script(linux/unix) in JAVA_OPTS parameters

 export JAVA_OPTS="$JAVA_OPTS" -Djava.endorsed.dirs="path of endoresed folder"

tomcat logging using log4j

In normal install tomcat use JULI for logging and this logging framework has issues on some advance rotation log file  configuration. I got issue with my hard disk always full after tomcat run for a couple of week cause log files. So i wonder if i can limit number of log files generate and tomcat reuse the old one when limit is reach.
After some research i find a solution. Tomcat allow us integration with log4j logging framework so we can handle above issue so easy.
If you have same problem i can guide you through.
Steps to make Tomcat work with log4j

We download two files from extras on tomcat download section

  • tomcat-juli.jar
  • tomcat-juli-adapters.jar

Copy tomcat-juli.jar to $CATALINA_HOME\bin to replace old one

Copy tomcat-juli-adapters.jar to $CATALINA_HOME\lib

Delete in $CATALINA_HOME\conf

Create in $CATALINA_HOME\libs. This is sample of mine:

log4j.rootLogger=INFO, CATALINA

log4j.appender.CATALINA.layout.ConversionPattern=%d [%t] %-5p %c- %m%n

Download log4j version greater than 1.2 and copy to $CATALINA_HOME\lib

After that restart tomcat.