4 Replies Latest reply on Apr 3, 2006 7:40 PM by Isaac Chua

    JSPs with JDK5.0 features do not compile

    Isaac Chua Newbie

      Hello everyone,

      I'm currently having a problem; in essence, as in the title, is about JSPs with JDK5.0 features that do not compile.

      I'm running JBoss 4.0.3 SP1 with the default integrated Tomcat 5.5, with JDK5.0.

      I wrote a very simple JSP in Eclipse 3.1.2 with the JBoss IDE 1.5.1 GA, packaged and deployed into JBoss. There is no problem with starting JBoss or deploying the WAR. This is the JSP:

      <?xml version="1.0" encoding="UTF-8" ?>
      <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      <%
      java.util.Vector<String> v = new java.util.Vector<String>();
      %>


      It's just the declaration and definition of a Vector using JDK5.0's generics feature.

      However, when I tried to access this JSP through the browser, I get this error:

      02:14:15,000 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      org.apache.jasper.JasperException: Unable to compile class for JSP
      
      An error occurred at line: 3 in the jsp file: /index.jsp
      Generated servlet error:
      Syntax error on token "<", invalid AssignmentOperator
      
      An error occurred at line: 3 in the jsp file: /index.jsp
      Generated servlet error:
      Syntax error on token "=", != expected
      
      An error occurred at line: 3 in the jsp file: /index.jsp
      Generated servlet error:
      Syntax error on token "<", ( expected
      
      An error occurred at line: 3 in the jsp file: /index.jsp
      Generated servlet error:
      Syntax error on token "(", invalid Expression
      
      
       at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
       at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
       at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
       ... etc


      Ok, this basically means that the compiler did not recognize the JDK5.0 features. I had already set the following options in Tomcat's conf/web.xml file:

      <servlet>
       <servlet-name>jsp</servlet-name>
       <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
       <init-param>
       <param-name>fork</param-name>
       <param-value>false</param-value>
       </init-param>
       <init-param>
       <param-name>xpoweredBy</param-name>
       <param-value>false</param-value>
       </init-param>
      <init-param>
       <param-name>compilerSourceVM</param-name>
       <param-value>1.5</param-value>
       </init-param>
       <init-param>
       <param-name>compilerTargetVM</param-name>
       <param-value>1.5</param-value>
       </init-param>
       ...
       </servlet>


      It still does not work, it does not compile.

      I did search Google for any possible solutions but to no avail. For some reason it seems as if no one encountered it before; either I'm not searching properly or there are no articles on this issue. I did find a thing about Tomcat versions prior to 5.5.16 (this issue was fixed in 5.5.16):

      http://issues.apache.org/bugzilla/show_bug.cgi?id=38389

      The problem was regarding the compilerSourceVM and compilerTargetVM as mentioned above.

      However, I'm very sure that the version of Tomcat that came with JBoss 4.0.3 SP1 is not 5.5.16, although I was unable to find which version was it.

      I believe if I were to integrate Tomcat 5.5.16 into JBoss, the issue might be resolved. However I'm unable to find any such tutorial or resource to accomplish this on Google.

      Another note is that I'm unwilling to use JBoss 4.0.4 RC1 because there is a bug with EJB3's TransactionManager (yes, I'm using EJB3; RC5 integrated into default server configuration):

      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=78114

      Basically I'm stumped. Tried all I can. Can anyone please tell me how to resolve this issue in JBoss 4.0.3 SP1? Please direct me to any existing resolutions, if any. I would also appreciate links to articles that describe how to integrate Tomcat 5.5.x into JBoss. Thanks!