Bug 16688 - JSP's not compiling - javac: invalid flag: C:\Java\jars\Tomcat
JSP's not compiling - javac: invalid flag: C:\Java\jars\Tomcat
Status: RESOLVED WORKSFORME
Product: Tomcat 4
Classification: Unclassified
Component: Jasper
4.1.24
PC All
: P3 blocker with 5 votes (vote)
: ---
Assigned To: Tomcat Developers Mailing List
http://jakarta.apache.org/tomcat/faq/...
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2003-02-03 04:58 UTC by Steve Vanspall
Modified: 2005-03-20 17:06 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Vanspall 2003-02-03 04:58:54 UTC
Using JDK 1.4.1
Have JAVA_HOME pointing to the JDK not just the JRE
The moment I try to compile a page I get the error listed below

Have been around the mailing list, solved a few of the problems, but then this 
happened again.

Regrds

Steve Vanspall

********************Error***********************




org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.



	at org.apache.jasper.compiler.DefaultErrorHandler.javacError
(DefaultErrorHandler.java:130)
	at org.apache.jasper.compiler.ErrorDispatcher.javacError
(ErrorDispatcher.java:293)
	at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:345)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:357)
	at org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:474)
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:184)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationDispatcher.invoke
(ApplicationDispatcher.java:684)
	at org.apache.catalina.core.ApplicationDispatcher.doForward
(ApplicationDispatcher.java:432)
	at org.apache.catalina.core.ApplicationDispatcher.forward
(ApplicationDispatcher.java:356)
	at org.apache.struts.action.RequestProcessor.doForward
(RequestProcessor.java:1014)
	at org.apache.struts.action.RequestProcessor.processForwardConfig
(RequestProcessor.java:417)
	at org.apache.struts.action.RequestProcessor.processActionForward
(RequestProcessor.java:390)
	at org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:271)
	at org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1292)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:260)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2415)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:172)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service
(CoyoteAdapter.java:223)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:594)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio
n(Http11Protocol.java:392)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:565)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:628)
	at java.lang.Thread.run(Thread.java:536)



-----------------------------------------------------------------------------
Comment 1 Sam 2003-04-02 08:32:29 UTC
I have the same problem, please help !!!
Comment 2 Steven Elliott 2003-04-10 17:14:02 UTC
I have the same problem on
Win2K Pro, jdk 1.4.1_02 running TC 4.1.24 downloaded today April 10, 2003

But I have not problem running:
Mac OSX 10.2.4, JDK 1.4.1 and TC 4.1.24 (same vintage).

Also have no problems with other versions:
TC 4.1.18 , TC 4.0.6 (on 1.3.1_02) on Win2k and MacOSX
Comment 3 Steve Fyfe 2003-04-13 17:44:05 UTC
Windows installer only installs the NT service correctly if JAVA_HOME is 
defined and it points to some version of Java SDK. If JAVA_HOME is not defined
before the install, or it is incorrect, the installer mostly appears to work but
Tomcat cannot compile JSPs.

There are two problems in the Tomcat 4 script for Nullsoft Installer, 
tomcat.nsi, v 1.33. I apologize for not providing a patch, but I have no way to
rebuild the installer to test these changes. I hope some committer can use this
information to fix these problems.

1. Function findJavaPath does not validate the path it finds. If the JAVA_HOME 
env variable is incorrect because it was set to point to an old Java that is no 
longer on the machine, the installer ends up using an invalid path for things 
like the shortcuts on the Start menu and to copy the tools.jar file. The 
function should verify that the folder it found does exist, and if the
JAVA_HOME setting is not valid it should fall back to using the registry.

2. Function findJVMPath only uses the JAVA_HOME setting to find the correct JVM,
even though the findJavaPath function is capable of finding the Java folder from
the registry settings. findJVMPath should call findJavaPath instead of relying 
on just the JAVA_HOME environment variable. In its current form, if JAVA_HOME 
is not defined or is incorrect, findJVMPath always fails to find the Java SDK 
and falls back to using the JRE. This leaves Tomcat unable to compile JSPs, 
because the Ant code cannot find Javac.exe.


To fix a system that was installed this way, do the following:
1. Change registry entry for 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
Apache Tomcat 4.1\Parameters\JVM Library

from (adjust these paths to your machine and java version)
C:\Program Files\Java\j2re1.4.1_02\bin\client\jvm.dll

to
C:\j2sdk1.4.1_02\jre\bin\server\jvm.dll

2. Copy tools.jar from your-jsdk\lib\tools.jar to your-
tomcat\common\lib\tools.jar This may not be necessary, but the installer does 
attempt to copy this file so it won't hurt to do the same.

3. If you use the shortcuts on the Start Menu, edit their properties to fix the 
path to java.exe.
Comment 4 Remy Maucherat 2003-04-13 17:47:34 UTC
What you posted is incorrect, as the installer will also check the registry.
Quite frankly, if you can't make it work, then it's really your own fault (using
the default Sun JDK installer will setup everything needed). The 5.0 installer
allows choosing the Java path, so that users have an easier way out (although I
assume they will fail to select the right path).

This "bug" will not be resolved, please do not reopen it.
Comment 5 Daniel Schmitt 2003-05-29 22:29:14 UTC
The Bug is still there. I have the same Problem.
Here is my Testcase:
1. I made a clean W2k Server install. (VMware rulez)
2. I installed SP3 (SP2 is needed for the new Sun SDK)
3. I installed j2sdk-1_4_1_02-windows-i586.exe with the default settings.
4. I installed jakarta-tomcat-4.1.24-LE-jdk14.exe, default settings,
   but NT Service checked.
5. I opened the shortcut "Tomcat Administration" -> same Error as stated by
   Steve Vanspall
6. I stopped the NT service and opened the shortcut "Start Tomcat" 
   -> opened "Tomcat Administration"
   -> everything is working fine.

I have the same wrong entry in 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Apache Tomcat 4.1
\Parameters\JVM Library as stated by Steve Fyfe. After I fixed it the tomcat 
service is working.

BTW. After my installation i have three jvm.dll on my system:
Two with the same size in:
C:\j2sdk1.4.1_02\jre\bin\client  and
C:\Program Files\Java\j2re1.4.1_02\bin\client
and one bigger in:
C:\j2sdk1.4.1_02\jre\bin\server

I think tomcat needs the server one.

I have not found where the wrong registry value for the service is set in 
tomcat.nsi so could someone give me a hint?

kind regards
Daniel
Comment 6 David Lovvorn 2003-06-20 18:22:59 UTC
This is actually not a bug report, but a possible way to fix a problem users 
might experience. 

I am unable to compile my JSP! 
Are you seeing this? 
      org.apache.jasper.JasperException: Unable to compile
      class for JSP

      An error occurred at line: -1 in the jsp file: null

      Generated servlet error:
          [javac] Since fork is true, ignoring compiler
      setting.
          [javac] Compiling 1 source file
         [javac] Since fork is true, ignoring compiler
      setting.


Like others, I have downloaded and installed the latest Java and Tomcat. 
Installed Java and it was running fine. Installed Tomcat (multiple tries) with 
no success. I followed all the comments I could find. The environment 
variables, tricks, with the NT service and without, but I kept getting the 
compile error message, until...

During the Tomcat install there is a pop-up message toward the end that talks 
about testing, the port 8080, user admin, password blank. During every attempt 
to install Tomcat, I had always put a password in. This last time, I tried it 
without a password and it worked.

If you have questions send me an e-mail dlovvorn@rtkl.com
Comment 7 Ralf Hauser 2003-07-19 07:29:01 UTC
I have the same problem with a different spin to it:

In the browser, I see
<<org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] javac: invalid flag: C:\Java\jars\Tomcat
    [javac] Usage: javac  
    [javac] where possible options include:
    [javac]   -g                        Generate all debugging info
    [javac]   -g:none                   Generate no debugging info
    [javac]   -g:{lines,vars,source}    Generate only some debugging info
    [javac]   -nowarn                   Generate no warnings
    [javac]   -verbose                  Output messages about what the compiler
is doing
    [javac]   -deprecation              Output source locations where deprecated
APIs are used
    [javac]   -classpath          Specify where to find user class files
    [javac]   -sourcepath         Specify where to find input source files
    [javac]   -bootclasspath      Override location of bootstrap class files
    [javac]   -extdirs            Override location of installed extensions
    [javac]   -d             Specify where to place generated class files
    [javac]   -encoding       Specify character encoding used by source files
    [javac]   -source          Provide source compatibility with specified release
    [javac]   -target          Generate class files for specific VM version
    [javac]   -help                     Print a synopsis of standard options




	at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
	at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
	at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
....>>
In catalina.out
<<19.07.2003 07:52:43 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8443
Compile failed; see the compiler error output for details.
	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:842)
	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:682)
	at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:317)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
...>>

I solved it by re-installing tomcat in a directory that has no spaces in its
path. I don't know how I fell into this problem, because before, I ran tomcat
dozens of times successfully even with the space in the "..cat 4.1".

Suggestions:
For the exception case, have org.apache.jasper.compiler.Compiler.compile or
org.apache.tools.ant.taskdefs.Javac.compile with which arguments they call javac
and where they get them from!

One more strange observation:
- even though I installed with windows installer, the windows registry is
unchanged (still has the old paths with spaces e.g. in "JVM Option Number 0" or
"System.err File")
- it even has as "JVM library" a jdk1.3... that I deleted months ago
Comment 8 Tim Funk 2004-02-08 23:10:53 UTC
This is handled by the FAQ.

http://jakarta.apache.org/tomcat/faq/misc.html#compile