Thursday, October 18, 2012

Changing or Renewing JSESSIONID in JBoss

I think if you reach this page by searching a keyword like this entry's title, I don't think you are expecting the answer to be something like below

session.invalidate();

Which you have tried and failed miserably. The JSESSIONID just won't change from its originally assigned value no matter what you did.

You are in luck if you are encountering this issue in your JBoss server, because I might have the answer for you.

So let's get started, first, you have to invalidate your session using the code I've posted above. Second, you have to locate server.xml files depending on the JBoss' version that you are using. For me, I'm using JBoss 4.2.3 GA, so the location is at JBOSS_HOME/server/default/deploy/jboss-web.deployer/ folder.

Located it? Great, now change all of the emptySessionPath value that you can find in this file to false.

Restart your JBoss, cross your fingers, and try again.

Cheers.

Tuesday, August 28, 2012

Pausing a Process in Linux

I was recently tasked to investigate on Java memory leak problem in production server. In order to do that, I'll have to create a memory dump. But before that, I'll have to pause the Java process from running and then resume the process after I've finished dumping the memory.

So how to do that in Linux?

To pause a process in Linux, just run the following command.

kill -SIGSTOP [PID]

Note: PID = process id, use ps command to see the process id.

To resume a paused process in Linux, run the following command.

kill -SIGCONT [PID]

That's about it. Don't worry, I didn't run this in production server, we have staging server for such troubleshooting purpose.

Chill.

Tuesday, April 3, 2012

Reverse Proxy Setup Encountered Permission Issue

Today when I setup reverse proxy for my Apache server, the reverse proxy refused to work. So I went to check on the log files and found out the following error:

Permission denied: proxy: HTTP: attempt to connect to

Seems like the Linux security prevented HTTPD process to connect to the network.

In order to solve this issue, just run the following command.

/usr/sbin/setsebool -P httpd_can_network_connect true

Alternatively, you can also set the security settings, Go to Security Level configurations and Change Tab to SELinux. And modify SELinux policy Check "Allow HTTPD scripts and modules to connect to the network" under HTTPD service.

Tuesday, April 12, 2011

Socket Accept Failed

Encountered funny error thrown by JBoss today when deploying JBoss 4.2.3GA

[JIoEndpoint] Socket accept failed
java.net.SocketException: Too many open files

Apparently JBoss somehow opened too many socket for some reason and start complaining itself.

So I've learned another new handy command to see what file handle are open using the following command.

lsof -p [PID]

Note: PID = process id, use ps command to see the process id.

If you want to count how many were open, can add wc command to it.

lsof -p [PID] | wc

Example output:

[root@localhost]# lsof -p 30328 | wc
1239 11141 153600

Translation: 1239 lines, 11141 words, 153600 chars.

So to solve this issue, go to jboss/server/default/deploy/jboss-web.deployer/ folder (might not be the exact path, depends on your JBoss version) and open server.xml file, replace the following

<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

with

<Executor name="appThreadpool" namePrefix="activeThread-"
maxThreads="150" minSpareThreads="3" maxIdleTime="30000" />

<Connector executor="appThreadpool" port="8080"
address="${jboss.bind.address}" maxThreads="150"
maxHttpHeaderSize="8192" minSpareThreads="3"
maxSpareThreads="20" emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

And then replace the following

<Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443" />

with

<Connector executor="appThreadpool" port="8009"
address="${jboss.bind.address}" protocol="AJP/1.3"
emptySessionPath="true" enableLookups="false" redirectPort="8443" />


Then save the server.xml and restart your JBoss.

Thursday, December 30, 2010

Recursively Remove .svn Directory and Files

Has it ever occurs to you that when you asked source code from your fellow developer, they will give you their whole workspace package including .svn files and you just want to delete these folders since you don't need it.

In that case, just quickly type in the following command so you have time to catch up for your coffee break with the above mentioned fellow developer.

rm -rf `find . -type d -name .svn`

Tuesday, June 22, 2010

Touch Files Modified Date Recursively in Unix

Sometimes you need to touch all your JSP files to current date so that your servlet container willing to re-compile your JSP again. It wouldn't be a problem if it's only one or two JSP files that you need to issue touch command.

When you need to touch a folder of JSPs recursively, the following command comes to your rescue

find jsp -exec touch {} \;

Saturday, April 10, 2010

View All Tables Record Counts in MySQL

To view all tables record counts in MySQL simply use this command

SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'database_name';

edit: it seems like the result returned is a cached result and it is not accurate, if you are looking for accurate result, I don't recommend the above mentioned approach.