caucho
Resin
FAQ
Reference Guide
Demo
Tutorial

Installation
SSL
Class Loader
Configuration
JSP/Servlet
Debugging
Misc
 Classloading and Compilation

SSL
FAQ
Configuration

  1. Where do I put my jars and classes?
  2. Where does Resin generate *.java and *.class files?
  3. Resin doesn't update changed servlets and JSP pages
  4. Servlets don't compile
  5. ClassNotFoundException for servlet or bean
  6. How do I get the application class loader?
  7. The application gets reloaded on each request
  8. What is the classloader order?

Where do I put my jars and classes?

Application classes belong in WEB-INF/classes. Jars belong in WEB-INF/lib.

Look at the standard installation and check the HelloWorld example. The HelloWorld source is in resin-2.1/doc/WEB-INF/classses. Resin will automatically compile that source when running the demo and put the class in the same directory.

If you change the app-dir to /usr/local/apache/htdocs, servlets and beans will belong in /usr/local/apache/htdocs/WEB-INF/classes.

Until you get your first servlets working, don't try to create your own web-apps. When you do start working with web-apps, look at the guest book examples to see where beans and servlets belong.

You can also change the default location with the <classpath> directive.

Application jars belong in WEB-INF/lib and standard libraries, like JDBC drivers, belong in the global classpath. In general, you should put standard libraries in the global classpath. Resin has several equivalent methods to add a jar to the classpath:

  1. Add the driver to the CLASSPATH environment variable.
  2. Start Resin with a -classpath argument including the driver.
  3. Put the jar file in resin1.1/lib.
  4. Put the classes in resin1.1/classes.

Only the last two will be automatically reloaded when the class or jar changes. For the first two, you'll need to restart Resin.

You can see Resin's global classpath by starting it with the -verbose option:

unix> httpd.sh -verbose

You must restart Resin to pick up the new classpath. When using the Win32 Resin, you must quit the Resin application. Just pressing the stop and start buttons will not suffice.

Where does Resin generate *.java and *.class files?

The <work-dir>'foo'</work-dir> attribute configures the directory where generated *.java (for JSP) and *.class files go. If unassigned, they go into /tmp/caucho on Unix and \temp\caucho on Windows.

Resin doesn't update changed servlets and JSP pages

Resin has a delay for testing updated servlets and JSP pages. The configuration variable for both is 'class-update-interval' in resin.conf. It's an application-level variable. The default is 15 seconds. So Resin will only check every 15 seconds for an updated page. You can set this value to 0 for development work.

<http-config class-update-interval='0'>
  ...
</http-config>

If you want Resin to check servlets for updates every hour, your resin.conf might look like:

<http-config class-update-interval='3600'>
  ...
</http-config>

Servlets don't compile

java.lang.NoClassDefFoundError: sun/tools/javac/Main

The JRE does not contain a Java compiler. You either need to get the JDK or use another compiler. To configure another compiler use:

<caucho.com>
  <java compiler='/usr/local/bin/jikes'/>
  ...
</caucho.com>

ClassNotFoundException for servlet or bean

First check that the class is in the right location. In the standard configuration, Java classes belong in resin/doc/WEB-INF/classes. If you're using Resin's autocompilation, the Java source file must be in the same location.

If you're using the automatic compilation, check that the package in the *.java file matches its location.

How do I get the application class loader?

cyou can get the application classloader from a servlet using the standard call Thread.getContextClassLoader().

The application gets reloaded on each request

Other symptoms are that sessions are killed on each request.

This may occur if your *.java files have a date in the future. When the *.class is compiled, it will have an date before the *.java. So Resin will think it's old and recompile on the next request.

This may occur, for example, if you work on NT and use Linux as a fileserver and the two clocks aren't properly synchronized.

The only solution is to synchronize the clocks for both machines.

What is the classloader order?

In Resin 2.1 the order is:

  1. The commandline classpath
  2. The resin/lib directory
  3. The envivonmental classpath
  4. An application's WEB-INF/lib and WEB-INF/classes

SSL
FAQ
Configuration
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.