Integration of Jboss and Apache2 and SSL

My Application(.ear) is running in Jboss with any issues on 7001 port. There are following requirement as such with me.

Task 1. Integrate Jboss with Apache2 so all the request should be coming from Apache Instead of jboss

Task 2. Implement SSLwith apache2 so it should open with https instead of http.

For task 1, I have followed carefully community.jboss.org/wiki/UsingModjk12WithJBoss with some issues. 1. Application is getting up and running without any issues but logout has some issues. 2. I want to stop JBOSS access point but not getting any clue

For task 2 Once this is up and running, i will have to implement SSL with Apache so it should only get open with HTTPS instead of http. any help on this front as well..any links or Reference.

To follow this issues properly, you can find my work update on this link..I will keep posted the issues…

Tagged : / / / / /

How to automatically recover Tomcat from crashes

rajeshkumar created the topic: How to automatically recover Tomcat from crashes

How to automatically recover Tomcat from crashes

Tomcat occasionally crashes if you do frequent hot-deploys or if you are running it on a machine with low memory. Every time tomcat crashes someone has to manually restart it, so I wrote a script which automatically detects that tomcat has crashed and restarts it.

Here’s the pseudo logic:

1. every few minutes {  
   2.   check tomcat status;  
   3.   
   4.   if (status is "not running") {  
   5.     start tomcat;  
   6.   }  
   7. }

Here’s a shell script to implement the above logic. It assumes that you are running on a unix/linux system and have /etc/init.d/tomcat* script setup to manage tomcat.

Adjust the path to “/etc/init.d/tomcat” in the script below to reflect the correct path on your computer. Sometimes it is called /etc/init.d/tomcat5 or /etc/init.d/tomcat6 depending on your tomcat version. Also make sure that the message “Tomcat Servlet Container is not running.” matches with the message that you get when you run the script when tomcat is stopped.

# #! /bin/sh  
# SERVICE=/etc/init.d/tomcat  
# STOPPED_MESSAGE="Tomcat Servlet Container is not running."  
#   
# if [ "`$SERVICE status`" == "$STOPPED_MESSAGE"];  
# then  
# {  
#   $SERVICE start  
# }  
# fi

To run the script every 10 minutes:

1. Save the above script to “/root/bin/recover-tomcat.sh”.

2. Add execute permission:

1. chmod +x /root/bin/recover-tomcat.sh

chmod +x /root/bin/recover-tomcat.sh

3. Add this to root’s crontab, type the following as root:

1. crontab -e

crontab -e

4. Add the following lines to the crontab:

1. # monitor tomcat every 10 minutes
2. */10 * * * * /root/bin/recover-tomcat.sh

What if I don’t have /etc/init.d/tomcat* script on my computer?

Tomcat creates a pid file, typically in the TOMCAT_HOME/bin directory. This file contains the process id of the tomcat process running on the machine. The pseudo logic in that case would be:

1. if (the PID file does not exist) {  
   2.   // conclude that tomcat is not running  
   3.   start tomcat  
   4. }  
   5. else {  
   6.   read the process id from the PID file  
   7.   if (no process that id is running) {  
   8.     // conclude that tomcat has crashed  
   9.     start tomcat  
  10.   }  
  11. }

You can implement the above logic as follows. The following is experimental and is merely a suggested way, test it on your computer before using it.

   1. # adjust this to reflect tomcat home on your computer  
   2. TOMCAT_HOME=/opt/tomcat5  
   3.   
   4. if [ -f $TOMCAT_HOME/bin/tomcat.pid ]  
   5. then  
   6.   echo "PID file exists"  
   7.   pid="`cat $TOMCAT_HOME/bin/tomcat.pid`"  
   8.   if [ "X`ps -p $pid | awk '{print $1}' | tail -1`" = "X"]  
   9.   then  
  10.     echo "Tomcat is running"  
  11.   else  
  12.     echo "Tomcat had crashed"  
  13.     $TOMCAT_HOME/bin/startup.sh  
  14.   fi  
  15. else  
  16.   echo "PID file does not exist. Restarting..."  
  17.   $TOMCAT_HOME/bin/startup.sh  
  18. fi

Why would tomcat crash?

The most common reason is low memory. For example, if you have allocated 1024MB of max memory to tomcat and enough memory is not available on that machine. Other reasons may involve repeated hot-deploys causing memory leaks, rare JVM bugs causing the JVM to crash.

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Apache Tomcat – Tomcat 7 Finalized – Tomcat 7 Introduction

tomcat-7

The volunteer developers behind Apache Tomcat have released version 7.0.6 of the open-source Java servlet container.

“This is the first stable release of the Tomcat 7 branch,” developer Mark Thomas wrote in an e-mail announcing the release on various Tomcat developer mailing lists.

While not a full application server, Tomcat implements the functionality described in the Java Enterprise Edition Web profile specifications. Most notably, it supports version 3.0 of the Servlet API (application programming interface) and version 2.2 of JavaServer Pages, both part of the recently ratified JEE 6. A servlet container manages Java-based applications that can be accessed from a Web browser.

The use of Servlet 3.0 will bring a lot of new capabilities to Tomcat, noted Tomcat contributor Tim Funk, in a presentation at the ApacheCon conference in Atlanta in November.

One big area of improvement is in configuration management for Web applications. Previous versions required all Web app configuration changes to be entered in a central file called web.xml, a process that led to unwieldy web.xml files as well as security risks.

The new approach, called annotations, breaks configuration instructions into multiple files. Separate files are kept for security, for configuring new connections, for initial parameters and for handling third-party libraries.

Other benefits of Servlet 3.0 include advanced cookie management and asynchronous thread support, which should increase the number of connections Tomcat can handle.

In preparation for the release, various beta versions of Tomcat 7 have been distributed since April 2010. Version 7.0.6 fixes some longtime memory leak issues and includes a number of other bug fixes as well.

In addition to making the source code and various binaries available, the development team has packaged a version of the software that can be embedded in other applications.

Tomcat is one of almost 150 open-source projects maintained by the Apache Software Foundation.

Tagged : / / / / / / / / / / / / / / / / /