This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 184283 - Run .jsp File fails on Tomcat
Summary: Run .jsp File fails on Tomcat
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-15 13:59 UTC by Martin Schovanek
Modified: 2010-05-10 09:16 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schovanek 2010-04-15 13:59:35 UTC
[Nb 6.9 Beta, jdk1.6, Tomcat 6.0.26]

to reproduce:
-------------
1) create a new: Samples > Java Web > JSTL Examples project
2) change the Target Server to Tomcat
3) right click the ShowSource.jsp and choose Run File

ERROR: compile-jsps task fails with:
...
compile-jsps:
Created dir: /Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src
Created dir: /Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/classes
Compiling 1 source file to /Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/classes
/Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src/org/apache/jsp/ShowSource_jsp.java:93: cannot find symbol
symbol  : method evaluateExpression(java.lang.String,java.lang.Class<java.lang.String>,javax.servlet.jsp.PageContext,<nulltype>)
location: class org.apache.jasper.runtime.PageContextImpl
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${filename}", java.lang.String.class, (PageContext)_jspx_page_context, null));
/Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src/org/apache/jsp/ShowSource_jsp.java:124: cannot find symbol
symbol  : method evaluateExpression(java.lang.String,java.lang.Class<java.lang.Object>,javax.servlet.jsp.PageContext,<nulltype>)
location: class org.apache.jasper.runtime.PageContextImpl
    _jspx_th_c_out_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${filename}", java.lang.Object.class, (PageContext)_jspx_page_context, null));
/Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src/org/apache/jsp/ShowSource_jsp.java:143: cannot find symbol
symbol  : method evaluateExpression(java.lang.String,java.lang.Class<java.lang.String>,javax.servlet.jsp.PageContext,<nulltype>)
location: class org.apache.jasper.runtime.PageContextImpl
    _jspx_th_c_import_0.setUrl((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${filepath}", java.lang.String.class, (PageContext)_jspx_page_context, null));
/Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src/org/apache/jsp/ShowSource_jsp.java:190: cannot find symbol
symbol  : method evaluateExpression(java.lang.String,java.lang.Class<java.lang.Object>,javax.servlet.jsp.PageContext,<nulltype>)
location: class org.apache.jasper.runtime.PageContextImpl
    _jspx_th_ex_escapeHtml_0.setReader((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${reader}", java.lang.Object.class, (PageContext)_jspx_page_context, null));
Note: /Users/ms113234/NetBeansProjects/EnterpriseApplication32/JSTLExamples/build/generated/src/org/apache/jsp/ShowSource_jsp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
Comment 1 Martin Schovanek 2010-04-19 10:16:45 UTC
After some discussion downgrading to P2.
Comment 2 David Konecny 2010-04-20 20:06:02 UTC
The problem is most likely in setup of the sample project. I would try to recreate it from scratch in NB69 and see if ti works first. If it worked in 68 it should work in 69.
Comment 3 Tomas Mysik 2010-04-22 11:25:12 UTC
Well, I tried the steps in NB 6.8 and it works there. So I had a look what are the changes in this particular example for NB 6.9 and found out that nothing has changed... So the problem must be somewhere else (I verified by opening this sample in NB 6.8 directly from trunk).

I will investigate more.
Comment 4 Tomas Mysik 2010-04-22 11:40:29 UTC
(In reply to comment #2)
> The problem is most likely in setup of the sample project. I would try to
> recreate it from scratch in NB69 and see if ti works first. If it worked in 68
> it should work in 69.

The result is the same. I will continue...
Comment 5 Tomas Mysik 2010-04-22 12:54:23 UTC
It seems to me that the problem is that "j2ee.platform.classpath" is not on the CP for JspCSingle so the JSP is compiled by the bundled GF parser and not by the Tomcat parser.

The reason why this works in NB 6.8 is that in 6.8 the "j2ee.platform.classpath" was part of "jspc.classpath" (<userdir>/build.properties), e.g.:
jspc.classpath=/home/gapon/Download/netbeans/java3/ant/lib/ant.jar:/home/gapon/Download/netbeans/enterprise6/modules/ext/servlet2.5-jsp2.1-api.jar:${j2ee.platform.classpath}:/home/gapon/Download/netbeans/enterprise6/modules/ext/glassfish-jspparser-2.0.jar:/home/gapon/Download/netbeans/enterprise6/modules/ext/glassfish-logging-2.0.jar:/home/gapon/Download/netbeans/ide12/modules/ext/commons-logging-1.1.jar:/home/gapon/Download/netbeans/java3/ant/lib/ant-launcher.jar

But for NB 6.9, I guess "jspc.classpath" was replaced with "libs.jsp-compilation.classpath" - am I right? But there's no "j2ee.platform.classpath" in it any more - Davide, do you know the reason?
libs.jsp-compilation.classpath=/opt/netbeans-dev/java/ant/lib/ant.jar:/opt/netbeans-dev/enterprise/modules/ext/servlet2.5-jsp2.1-api.jar:/opt/netbeans-dev/enterprise/modules/ext/glassfish-jspparser-2.0.jar:/opt/netbeans-dev/enterprise/modules/ext/glassfish-logging-2.0.jar:/opt/netbeans-dev/ide/modules/ext/commons-logging-1.1.jar:/opt/netbeans-dev/java/ant/lib/ant-launcher.jar

So, I'm not really sure how the right fix should look like, so it would be great if David could fix this or at least tell me what should be done.

Thanks.
Comment 6 Tomas Mysik 2010-04-22 13:22:49 UTC
Seems to be introduced by fixing issue #154275.
Comment 7 David Konecny 2010-04-23 04:04:36 UTC
(In reply to comment #5)
> It seems to me that the problem is that "j2ee.platform.classpath" is not on the
> CP for JspCSingle so the JSP is compiled by the bundled GF parser and not by
> the Tomcat parser.

That might be the cause. Looking at http://hg.netbeans.org/main/rev/3b043cf14b0e and how WebProjectModule setup the classpaths it does look like j2ee.platform.classpath is missing from org.netbeans.modules.web.project.ant.JspC classpath. I wonder why exactly it is needed though and what's missing on classpath when Tomcat is used. Fix could be to just add j2ee.platform.classpath to build-impl.xml to classpath definition.
Comment 8 Tomas Mysik 2010-04-23 04:30:24 UTC
(In reply to comment #7)
> I wonder why exactly it is
> needed though and what's missing on classpath when Tomcat is used.

Tomcat is not able to find some classes - seems to me that the GF parser generates the Java source a bit differently then Tomcat parser (some classes from jasper.runtime package were missing).

> Fix could be
> to just add j2ee.platform.classpath to build-impl.xml to classpath definition.

I can do that, but j2ee.platform.classpath must be before libs.jsp-compilation.classpath to have a effect - but have a look at http://hg.netbeans.org/main/rev/3b043cf14b0e, particularly:
//XXX This is fix for issue #74250. This is a hack and should be solved in the glassfish's jasper
// also it must be moved before J2EE_PLATFORM_CLASSPATH, because a server (JBoss) can expose
// old jsp api, and the compiler is not then able compile some jsp pages with tag lib declarations

Is there a way to put j2ee.platform.classpath to the exactly same place as it used to be? That would be the correct fix, IMHO. But when I tried to put it there manually (to the <userdir>/build.properties), ${j2ee.platform.classpath} property has not been processed (replaced), I have no idea why...

Thanks.
Comment 9 David Konecny 2010-04-23 23:01:44 UTC
(In reply to comment #8)
> Tomcat is not able to find some classes - seems to me that the GF parser
> generates the Java source a bit differently then Tomcat parser (some classes
> from jasper.runtime package were missing).

But error happens when JSPs are compiled to Java and that's done by GF parser which we bundle so how is Tomcat parser related to this? It possible I miss something obvious as I have not looked in detail into this issue - but why Tomcat server jars are needed?

> I can do that, but j2ee.platform.classpath must be before
> libs.jsp-compilation.classpath to have a effect - 

Why does it have to be first to "have an effect"? 

> but have a look at
> http://hg.netbeans.org/main/rev/3b043cf14b0e, particularly:
> //XXX This is fix for issue #74250. This is a hack and should be solved in the
> glassfish's jasper
> // also it must be moved before J2EE_PLATFORM_CLASSPATH, because a server
> (JBoss) can expose
> // old jsp api, and the compiler is not then able compile some jsp pages with
> tag lib declarations

That make sense. I wonder what APIs are missing that JSP compiler fails. Perhaps just these APIs should be bundled in our JSP Compile/JSP Compilation libraries. Then we would not have to add server to classpath.
Comment 10 Tomas Mysik 2010-04-25 18:53:36 UTC
(In reply to comment #9)
> But error happens when JSPs are compiled to Java and that's done by GF parser
> which we bundle so how is Tomcat parser related to this? It possible I miss
> something obvious as I have not looked in detail into this issue - but why
> Tomcat server jars are needed?

I need to investigate this.

> Why does it have to be first to "have an effect"? 

Otherwise GF parser is used.

> That make sense. I wonder what APIs are missing that JSP compiler fails.
> Perhaps just these APIs should be bundled in our JSP Compile/JSP Compilation
> libraries. Then we would not have to add server to classpath.

That would be fine but hard to say how much time it could take.
Comment 11 David Konecny 2010-05-03 19:43:38 UTC
Looking at this issue in more detail the problem is following: compilation of JSPs into Java is OK; it is compilation of Java files generated from JSP which is failing. And that compilation already contains j2ee.platform.classpath so problem is somewhere else. And it is here:
* j2ee.platform.classpath is at the beginning of classpath and
* Tomcat server classpath contains different version of JSP compiler (jasper) than one bundled with the IDE
And that causes "cannot find method org.apache.jasper.runtime.PageContextImpl.evaluateExpression(...)" compilation error. One fix obviously is to not expose internal server jars on server classpath - Tomcat should not list jasper.jar as it is implementation jar and not an API jar. Different fix is to move j2ee.platform.classpath to the end of classpath when compiling Java files generated from JSP. And this is what I'm going to do because I think it is more correct. It is hard to say whether it will have some side effects - in theory it should not. But only testing can prove that. 

Fixed: 6775fb25bcd4
Comment 12 Quality Engineering 2010-05-10 09:16:15 UTC
Integrated into 'main-golden', will be available in build *201005100200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/
User: 
Log: