• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error compiling JSP  RSS feed

 
Czcz Cacaca
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a problem runnig tomcat under Fedora Linux.
I have Tomcat 4.1 and I want to run a small web site with a few JSPs but when I request the page from the browser I have an error on the shell that runs tomcat and the browser shows a blank page:
Unable to find a javac compiler;

[java] com.sun.tools.javac.Main is not on the classpath.
[java] Perhaps JAVA_HOME does not point to the JDK
[java] at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:140)

I set JAVA_HOME to point to the j2sdk1.4.2 directory and I try to set CLASSPATH environment variable too, to point to the jars in the j2sdk../lib directory. But the error remains.
I have also set up environment variables in the /etc/profile file too, with export command, but nothing appens.
I don't understand why this happens... because from the shell I can execute
java com.sun.tools.javac.Main
without errors.

thanx for any possible answer.
bye, czcz
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to set the CLASSPATH. Tomcat ignores it if you do.

I would try testing your JAVA_HOME environment variable to make sure it is correct.

At the shell type:
$JAVA_HOME/bin/javac

If the response is "command not found" then you know it's not set correctly.

You can also type:
echo $JAVA_HOME to see where it IS pointing.
 
Czcz Cacaca
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know what an environment variable is and $JAVA_HOME/bin/javac works.
But the problem is there. If I invoke javac it runs, but it doesn't exist if the invoker is tomcat.
I don't know how I can tell tomcat where com.sun.tools.javac.Main is located.

thanx,
czcz
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's in tools.jar under $JAVA_HOME/lib.
Tomcat finds it by adding "/lib/tools.jar" to it's the JAVA_HOME environment variable.

When you start tomcat, it usually prints the JAVA_HOME value to stdout.
Ex:
Using CATALINA_BASE: /home/bsouther/tomcat
Using CATALINA_HOME: /home/bsouther/tomcat
Using CATALINA_TMPDIR: /home/bsouther/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.5.0



Out of curiosity, why are you installing such an old version of Tomcat?

Using CATALINA_BASE: /home/bsouther/tomcat
Using CATALINA_HOME: /home/bsouther/tomcat
Using CATALINA_TMPDIR: /home/bsouther/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.5.0

[ May 02, 2005: Message edited by: Ben Souther ]
 
Czcz Cacaca
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I know that the class is in that jar too.
But the PROBLEM is HOW CAN INFORM TOMCAT TO USE THAT CLASS!

ps: I use Tomcat4 because the pages will be on a server which runs Tomcat4, which isn't mine, so I can't choose.

thanx if anyone can understand what the problem is.
bye
czcz
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by czcz cacaca:
But the PROBLEM is HOW CAN INFORM TOMCAT TO USE THAT CLASS!


Fist of all screaming (typing in caps) is not going to get you help any faster in here.

Second, I just told you how Tomcat finds that file.
It takes your JAVA_HOME environment variable and appends "/lib/tools.jar" to it.

If your JAVA_HOME variable is set correctly, Tomcat will find the compiler.
 
Czcz Cacaca
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx for your continuous posting...
If you think the problem is to set JAVA_HOME correctly, give me a method to set it correctly.
I've already said that I can type "ls $JAVA_HOME/lib/" showing the files in the lib directory.
I ask how can set the variable correctly because when I use it all works, but when is tomcat to use it, it seems not working...
Might I set it in any special or particular config file?
I've already said that I set JAVA_HOME in /etc/profile, because it is a general config file for the shell where environment variables are initialized.
I use the command "export JAVA_HOME=/opt/j2sdk1.4.2;". Is it correct?

thanx anyone can answer to the problem.
bye czcz
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you're doing everyting right.
When you start up tomcat, does it tell you what JAVA_HOME it's using?

Did you install Tomcat yourself?
If so, did you use an RPM or the tar.gz file?

If someone else installed it, you might want to look at TOMCAT_HOME/conf/startup.sh and TOMCAT_HOME/conf/catalina.sh to see if someone set the JAVA_HOME var in there (I sometimes to that).

Another thing that might stop compilation is a permissions problem.
Specifically, Jasper needs to be able to write to TOMCAT_HOME/work and all of it's sub directories.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"czcz cacaca",

Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

bear
Forum Bartender
 
Czcz Cacaca
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Bear edit: response removed as a violation of the "Be Nice" rule]
[ May 02, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"czcz cacaca",

Please see the Personal Message I sent to you and respond.

I have edited your message as it violates pretty much the only other rule we have here at the Ranch (besides the naming convention), and that's "Be Nice".

bear
Forum bartender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!