This is a "how to" procedure to make IIS redirect JSP's and Servlets execution to JBoss application server, which is useful to integrate existing IIS application with newly developed modules using Java technology. The existing IIS application should not be disturb and system should work with the minimum settings. The ISAPI filter is having capability of checking and redirecting any request made to IIS web server to any other web server or application server. It works with Jboss application server running on windows or Linux based systems.
Softwares required for Integration
1 Web Server - IIS version: 6
2 Application Server - JBoss 4.0.2 (having in-built Tomcat 5.5.9)
3 Java Development Kit - J2SE Development Kit 5.0 Update 7
4 Apache Jakarta Tomcat Connector - ISAPI Redirector 1.2.9
4 Operating System - Windows Server 2003 with SP2
Concept
Normally IIS can not execute Servlets and Java Server Pages (JSPs), configuring IIS to use the JK ISAPI redirector plug in will let IIS send servlet and JSP requests to Tomcat.
ISAPI Filter and Redirector for Tomcat
1) The IIS-Tomcat redirector is an IIS plugin (filter + extension), IIS loads the redirector plugin and calls its filter function for each in-coming request.
2) The filter then tests the request URL against a list of URI-paths held inside
uriworkermap.properties, If the current request matches one of the entries in the list of URI-paths, the filter transfers the request to the extension.
3) The extension collects the request parameters and forwards them to the appropriate worker using the ajp1X protocol.
4) The extension collects the response from the worker and returns it to the browser.
Tomcat Workers
A Tomcat worker (like a thread) is a Tomcat instance that is waiting to execute servlets on behalf of some web server. For example, we can have a web server such as Apache/IIS forwarding servlet requests to a Tomcat process (the worker) running behind it.
The scenario described above is a very simple one; in fact one can configure multiple Tomcat workers to serve servlets on behalf of a certain web server. The reasons for such configuration can be:
We want different contexts to be served by different Tomcat workers to provide a development environment where all the developers share the same web server but own a Tomcat worker of their own.
We want different virtual hosts served by different Tomcat processes to provide a clear separation between sites belonging to different companies.
We want to provide load balancing, meaning run multiple Tomcat workers each on a machine of its own and distribute the requests between them.
There are probably more reasons for having multiple workers but I guess that this list is enough...
There are probably more reasons for having multiple workers but I guess that this list is enough...
Tomcat workers are defined in a properties file dubbed workers.properties and this tutorial explains how to work with it.
Apache JServ Protocol version 1.3 (ajp13)
The ajp13 protocol is packet-oriented. A binary format was presumably chosen over the more readable plain text for reasons of performance. The web server communicates with the servlet container over TCP connections. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles.
Apache JServ Protocol version 1.3 (ajp13)
The ajp13 protocol is packet-oriented. A binary format was presumably chosen over the more readable plain text for reasons of performance. The web server communicates with the servlet container over TCP connections. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles.
Once a connection is assigned to a particular request, it will not be used for any others until the request-handling cycle has terminated. In other words, requests are not multiplexed over connections. This makes for much simpler code at either end of the connection, although it does cause more connections to be open at once.
Once the web server has opened a connection to the servlet container, the connection can be in one of the following states:
Idle - No request is being handled over this connection.
Assigned - The connecton is handling a specific request.
Idle - No request is being handled over this connection.
Assigned - The connecton is handling a specific request.
Once a connection is assigned to handle a particular request, the basic request information (e.g. HTTP headers, etc) is sent over the connection in a highly condensed form (e.g. common strings are encoded as integers). Details of that format are below in Request Packet Structure. If there is a body to the request (content-length > 0), that is sent in a separate packet immediately after.
Download Applications
JDK: jdk-1_5_0_07-windows-i586-p.exe
JBoss: jboss-4.0.2
Apache Jakarta Tomcat Connector (ISAPI Redirector): isapi_redirect-1.2.9.exe
Installation, Integration and Configuration Steps
Install jdk-1_5_0_07-windows-i586-p.exe to D:\Java\jdk1.5.0_07
Extract jboss-4.0.2 to D drive as D:\Java\jboss-4.0.2\
Install isapi_redirect-1.2.9.exe with default installation (Installation Path- C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\)
Install IIS 6 with default configuration
Set environment variables
JAVA_HOME
D:\Java\jdk1.5.0_03
JBOSS_HOME
D:\Java\jboss-4.0.2
Configurations
JBoss Configuration:
Deploy the application by creating war folder named "smartadmin.war" under D:\Java\jboss-4.0.2\server\
Download Applications
JDK: jdk-1_5_0_07-windows-i586-p.exe
JBoss: jboss-4.0.2
Apache Jakarta Tomcat Connector (ISAPI Redirector): isapi_redirect-1.2.9.exe
Installation, Integration and Configuration Steps
Install jdk-1_5_0_07-windows-i586-p.exe to D:\Java\jdk1.5.0_07
Extract jboss-4.0.2 to D drive as D:\Java\jboss-4.0.2\
Install isapi_redirect-1.2.9.exe with default installation (Installation Path- C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\)
Install IIS 6 with default configuration
Set environment variables
JAVA_HOME
D:\Java\jdk1.5.0_03
JBOSS_HOME
D:\Java\jboss-4.0.2
Configurations
JBoss Configuration:
Deploy the application by creating war folder named "smartadmin.war" under D:\Java\jboss-4.0.2\server\
default\deploy
Now create home page named "index.jsp" under the folder D:\Java\jboss-4.0.2\server\default\deploy\smartadmin.war
Edit the "index.jsp" using wordpad & copy the following content to the file.
<META http-equiv="refresh" content="0;URL=http://www.smartadmin.in/">
IIS Configuration:
"C:\Inetpub\wwwroot" will be the default home directory for the "Default Web Site"
Open IIS Manager (run>inetmgr) navigate to (local computer)>Web Sites> right click on "Default Web Site" click on properties, from the properties windows click on "ISAPI filters" tab click "Add" give filter name as "jakarta" (exact spelling & case required), add Executable path as "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirect.dll" apply the changes and click ok.
Now right click on the "Default Web Site" and create a "virtual directory" named "jakarta" (exact spelling & case) and set the path to "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin"
Give Read, Run Scripts and Execute permissions during the creation of virtual directory "jakarta"
Then navigate to (local computer)>Web Service Extensions from IIS Manager and right click on the right pane of the IIS Manager and click "Add a new Web service extension..." and create the extension named "jakarta" (exact spelling & case) with "Required Files" path to "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirect.dll" and set the extension statusto "Allowed".
Delete all the contents from the folder "C:\Inetpub\wwwroot" and create a new home page named "default.htm"
Edit the file "default.htm" using wordpad and copy the following content to the file
<META http-equiv="refresh" content="0;URL=http://localhost/smartadmin">
Redirector Configuration:
Modify the configuration file "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\uriworkermap.properties" using wordpad as shown below, where "smartadmin" is the name of application (war folder) deployed in Jboss (D:\Java\jboss-4.0.2\server\default\deploy\smartadmin.war)
# uriworker.properties -
#
# This file provides sample mappings for example
# ajp13w worker defined in workermap.properties.minimal
/smartadmin/*=ajp13w /smartadmin=ajp13w
# Now filter out all .jpeg files inside that context
# For no mapping the url has to start with exclamation (!)
!/servlets-examples/*.jpeg=ajp13w
Now restart the machine and run the jboss application server by running "D:\Java\jboss-4.0.2\bin\run.bat"
Test the application by accessing the url http://localhost/, you will get redirected to http://www.smartadmin.in/
Now create home page named "index.jsp" under the folder D:\Java\jboss-4.0.2\server\default\deploy\smartadmin.war
Edit the "index.jsp" using wordpad & copy the following content to the file.
<META http-equiv="refresh" content="0;URL=http://www.smartadmin.in/">
IIS Configuration:
"C:\Inetpub\wwwroot" will be the default home directory for the "Default Web Site"
Open IIS Manager (run>inetmgr) navigate to (local computer)>Web Sites> right click on "Default Web Site" click on properties, from the properties windows click on "ISAPI filters" tab click "Add" give filter name as "jakarta" (exact spelling & case required), add Executable path as "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirect.dll" apply the changes and click ok.
Now right click on the "Default Web Site" and create a "virtual directory" named "jakarta" (exact spelling & case) and set the path to "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin"
Give Read, Run Scripts and Execute permissions during the creation of virtual directory "jakarta"
Then navigate to (local computer)>Web Service Extensions from IIS Manager and right click on the right pane of the IIS Manager and click "Add a new Web service extension..." and create the extension named "jakarta" (exact spelling & case) with "Required Files" path to "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirect.dll" and set the extension statusto "Allowed".
Delete all the contents from the folder "C:\Inetpub\wwwroot" and create a new home page named "default.htm"
Edit the file "default.htm" using wordpad and copy the following content to the file
<META http-equiv="refresh" content="0;URL=http://localhost/smartadmin">
Redirector Configuration:
Modify the configuration file "C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\uriworkermap.properties" using wordpad as shown below, where "smartadmin" is the name of application (war folder) deployed in Jboss (D:\Java\jboss-4.0.2\server\default\deploy\smartadmin.war)
# uriworker.properties -
#
# This file provides sample mappings for example
# ajp13w worker defined in workermap.properties.minimal
/smartadmin/*=ajp13w /smartadmin=ajp13w
# Now filter out all .jpeg files inside that context
# For no mapping the url has to start with exclamation (!)
!/servlets-examples/*.jpeg=ajp13w
Now restart the machine and run the jboss application server by running "D:\Java\jboss-4.0.2\bin\run.bat"
Test the application by accessing the url http://localhost/, you will get redirected to http://www.smartadmin.in/
This entry was posted
on Thursday, October 9, 2008
at Thursday, October 09, 2008
and is filed under
JBoss,
Tips
. You can follow any responses to this entry through the
comments feed
.