ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Resin: The Instant Application Server

by Daniel Solin

Imagine a Java Web application server that runs on Unix, delivers incredible performance, is really easy to set up, and inexpensive to boot. Even crazier, imagine that this little app server offers all of the features you expect from a modern Java server, including JSP/servlets, XML/XSL, and EJB/CMP.

You can stop imagining. It actually exists, and it goes by the name of Resin. In this article, we will show you how to install Resin and get it running; we'll conclude with an EJB/CMP example that shows how Resin makes these techniques easily usable. If you have worked with installations of Java servers before, I think you will be amazed at how fast and simple Resin is. At an ISP I worked for, we had Resin up and running in a matter of minutes.

Getting And Installing Resin

We'll start out by installing Resin on our system. Since Resin is itself a Java application, it needs a Java environment to compile and run. If you don't already have them, you need to download and install both the Standard Edition (SE) and the Enterprise Edition (EE) of the JDK (version 1.3.1 or higher). See java.sun.com for instructions on how to accomplish this. Note that you will not be able to follow the steps later in this article if you don't have a working installation of JDK EE. This is because we will install the Enterprise Edition of Resin, which requires JDK EE to work.

With both the SE and EE JDKs set up, we can begin our adventure by downloading and unpacking the Resin source distribution, available here. At the time if this writing, the latest version of Resin-EE (Enterprise Edition) was 2.1.

When the file is on your local machine, just unpack it into your /usr/local directory.

root@localhost:~# resin-ee-2.1.4.tar.gz /usr/local
root@localhost:~# cd /usr/local
root@localhost:/usr/local# tar xvfz resin-2.1.4.tar.gz
root@localhost:/usr/local# ln -s resin-2.1.4 resin

Since we're going to run Resin as a standalone Web server, we need to change the port the server will listen on before we start it. This can be done by changing a line in /usr/local/resin/conf/resin.conf. Open resin.conf in an editor and locate the following line:

<http port='8080'/>

It's very common to use Resin in conjunction with Apache, letting Resin answer requests to JSP/servlets, and leaving the rest to Apache. This is why Resin is set to listen to port 8080 instead of 80, which is the standard port for Web servers. We are going to let Resin take care of all requests to our server (which it actually is very capable of!) so we will change the port to 80 in the above line. Save the file and exit the editor.

Now start Resin by executing the following:

root@localhost:~# /usr/local/resin/bin/httpd.sh

You should now see output that looks something like this:

Resin 2.1.4 (built Fri Aug 2 14:16:52 PDT 2002)
Copyright(c) 1998-2002 Caucho Technology. All rights reserved.

Starting Resin on Tue, 10 Sep 2002 09:31:46 +0200 (CET)
[2002-09-10 09:32:04.791] initializing application

[snip: loads of compilations]

[2002-09-10 09:36:34.618] initializing application 
[2002-09-10 09:36:34.619] initializing application 
[2002-09-10 09:36:34.620] initializing application 
[2002-09-10 09:36:34.621] initializing application 
[2002-09-10 09:36:34.622] initializing application 
[2002-09-10 09:36:34.624] initializing application 
[2002-09-10 09:36:34.625] initializing application 
[2002-09-10 09:36:34.626] initializing application 
[2002-09-10 09:36:34.627] initializing application 
[2002-09-10 09:36:34.628] initializing application 
http listening to *:80
srun listening to

Now, point your browser to http://localhost. You should now see the default Resin home page, as shown in Figure 1.

Figure 1. Resin home page.

Pages: 1, 2, 3

Next Pagearrow