Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] is not on the classpath on Ubuntu Natty


I installed jetty 6.1.24-6 on Ubuntu Natty 11.04 via apt-get install
jetty. I also installed openjdk-6-jdk 6b22-1.10.2-0ubuntu1~11.04.1
OpenJDK Development Kit (JDK). <<<--- Note that this is the JDK not
just the JRE. I started Jetty using start.jar and when Jetty went to
compile a .JSP page, I got an error as follows:

Unable to find a javac compiler; is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-sun-"
	at org.apache.jasper.compiler.AntCompiler.generateClass(
	at org.apache.jasper.compiler.Compiler.compile(
	at org.apache.jasper.compiler.Compiler.compile(
	at org.apache.jasper.compiler.Compiler.compile(
	at org.apache.jasper.JspCompilationContext.compile(
	at org.apache.jasper.servlet.JspServletWrapper.service(
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(
	at org.apache.jasper.servlet.JspServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.mortbay.jetty.servlet.ServletHolder.handle(

The Ant task Javac is looking to call classes that live in tools.jar,
and can't find them. Tools.jar is in

I tried a few things, and still got the same error.

1) Setting JAVA_HOME to /usr/lib/jvm/java-6-sun- in the
environment or even in /etc/profile doesn't seem to help.

2) java -classpath blah/blah -jar start.jar is no good 'cause java
ignores classpath arguments when using -jar

3) # tried w/ both open-jdk and sun jdk.
    sudo -u jetty bash
    export CLASSPATH=/usr/lib/jvm/java-6-sun/lib/tools.jar
    export JAVA_HOME=/usr/lib/jvm/java-6-sun/
    java -jar start.jar

The kludge that finally worked was to symlink tools.jar into
/usr/lib/jvm/java-6-sun- (Ugly, I know!)

I'm guessing that one or more of Jetty, Jasper and the Ant Javac task
starts subprocesses or does classloader tricks, so that setting the
classpath for the ant.taskdefs.Javac must be done by configuration
somewhere. I'm also guessing it's trying to be smart and determine the
classpath automatically from the location of the java executable.
There's a symlink pointing /usr/lib/jvm/java-6-sun/bin/java ->
/usr/lib/jvm/java-6-sun/jre/bin/java. This is true of both java-6-sun
and java-6-openjdk. So, I'm pretty sure the choice of directory
structure and symlinking is fouling up Ant's or Jetty's automagic
classpath wizardry. I'm I right?

I'm pretty sure it's not good that installing Jetty and a JDK via
apt-get leads to this error. Should this be considered a bug in the
apt-get packaging? In Jetty? In Ant? In my brain? Or somewhere else?

And finally, is there a simple bit of configuration that could solve
this whole dilema?

Thanks for sticking with a long-winded post and for any clues!

- Chris

Back to the top