Integrating Apache and Tomat with mod_jk

This post is a continuation of my previous post. In this post I’ll tell you what I did to access my tomcat apps via Apache.

All the files you edit here are very crucial. Take a backup and make a note of the changes you do. Otherwise, it may goof your Apache configuration.

Installing mon-jk library

$ sudo apt-get install libapache2-mod-jk

Make sure the AJP redirect port is enabled on tomcat/config/server.xml

<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />

Create a new worker file

sudo vi /etc/apache2/workers.properties

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

Reconfigure jk.conf

Change the JkWorkersFile property to /etc/apache2/workers.properties

sudo vi /etc/apache2/mods-available/jk.conf

# JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkWorkersFile /etc/apache2/workers.properties

Configure the URL Apache should pass through the Tomcat

sudo vi /etc/apache2/sites-enabled/000-default

and add the line starts with JKMount in your configurtation

<VirtualHost *:80>
…………………………………
…………………………………
JkMount /gplus* worker1
</VirtualHost *:80>

Restart apache

I found http://<apacheIP>/gplus worked.

Appreciations and thanks to http://thetechnocratnotebook.blogspot.sg/2012/05/installing-tomcat-7-and-apache2-with.html

 

 

 

 

 

Apache – Tomcat connector in Windows

This is another interesting assignment completed today. Though our CRM portal is no so busy, we want to in a robust infra. There are series of new releases available kn the market. JDK 7, Tomcat 7 etc. Previously the application was using tomcat itself as a web server. This is a risky situation since I expose the complete applivation to public. Hence I have installed the apache as web front-end and tomcat 7 as middleware.

Here is the procedure:

mod_proxy_ajp would be the easiest to use if you are using Apache 2.2. It is part of the Apache distribution so you don’t need to install any additional software.

In your httpd.conf you need to make sure that mod_proxy and mod_proxy_ajp are loaded:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Then you can use the ProxyPass and ProxyPassReverse directives as follows:

ProxyPass /portal ajp://localhost:8009/portal
ProxyPassReverse /portal ajp://localhost:8009/portal

As simple as that.

java.lang.NoSuchMethodError while starting tomcat 7 from Eclipse

My tomcat 7 server is starting and working fine by itself. When I stop it and try to start from Eclipse, it gives a NoSuchMethodError which aborts the server starting.

java.lang.NoSuchMethodError: org.eclipse.wst.server.core.model.ServerBehaviourDelegate.getTempDirectory(Z)Lorg/eclipse/core/runtime/IPath;

somebody is getting same error, but still not resolved. http://www.eclipse.org/forums/index.php?t=msg&goto=557431&S=432a9edd157438a3661ca16edfe4a4ab

I have raised a bug report to eclipse. Lets see.

>>>

I just got an update from Eclipse Bugzilla

Your Build Identifier indicates you are using Eclipse 3.5, which only works
with WTP 3.1.x.  WTP 3.2.x, which includes the new Tomcat 7.0 support, requires
Eclipse 3.6.x.  Running WTP 3.2.x with Eclipse 3.5.x is not supported.  You
will have to install Eclipse 3.6 since upgrading 3.5.x to 3.6 is not supported.
Once you have Eclipse 3.6 with WTP 3.2.x installed (using the Java EE package
is the easiest) you can create a new workspace and import your existing
projects, or you can simply open old workspace.  If you open the old workspace
with Eclipse 3.6 and WTP 3.2.x, using that workspace with Eclipse 3.5 and WTP
3.1.x is not supported.

Since Eclipse 3.5.x and WTP 3.2.x is not a supported combination, I’m marking
this bug as invalid.

Upgrade karega!

Target runtime Apache Tomcat v6.0 is not defined

I was upgrading the tomcat in my eclipse from version 6 to 7. Servers were added, old servers were removed. Tomcat 6 installed. But the server is not starting because of the following error.

Target runtime Apache Tomcat v6.0 is not defined.    <project name>        Unknown    Faceted Project Problem

It keeps my old server entry for the project.

We need to right click on the project, properties and Targeted Runtimes. Uncheck the old entry and enable the new entry. This should solve this error.

Targeted Runtimes

Targeted Runtimes

Still server is facing some other issue. Need to check up.

Way to Struts 1.2 DataSource

hurray

Today I had downloaded struts 1.2.7 and tried to write an application. (I know I am selecting a bit old.) I configured the datasource in struts. Alas. When I tried to start my server, tomcat 6.0, I got the error saying "java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource". With Googling I found struts-legacy.jar need to downloaded and copied to lib folder of Tomcat. (I couldnt get the recent version of struts-legacy. I found something in archive). Happily restarted the server. I saw java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool.. oof.. again I need to download commons-dbcp-1.2.2.jar and commons-pool.jar.

My search come to an end 🙂 It is working fine now.

Integrating tomcat 6.0 and Eclipse europa

Till now I was using eclipse and tomcat separately, I was not that much serious about deployment, generally I goto the web application folder and edit/compile there itself. I know tomcat can be integrated with Eclipse, but I never tried. Today I have no other go. I need to do it. Here are the steps.

Register Tomcat with Eclipse

Select Window>Preferences

select the server you want to add, here we are adding tomcat 6.0 available under apache node

fill the necessary details

Here you can see the server is added to the list

You can see a new Project called Servers added to the Project explorer, If it is already there, the server might have been appended to the list

now open the corresponding web project to be deployed and start running it (ctrl + F11). Select Run on Server option

specify the server in which the application is to be deployed.

Move the projects to be deployed to the server. Here we have only one.

Thats it. done! see the web page is getting loaded!