[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - JSP build problem with JBoss AS 5.0.x

SkyBeam do-not-reply at jboss.com
Sat Mar 7 16:35:44 EST 2009


Hi all,

I am quite new to web development and run into problems using JBoss AS 5.0.x.

It seems that JBoss Web is not building the servlet class correctly when generating servlets from JSP. According to the specification it is allowed to put page directives at any location within a JSP (or its statically included files). Unfortunately it looks like JBoss 5 is not adding these includes to the header of the generated _jsp.java and therefore is unable to compile it.

A simple example:

WebContent/index.jsp:
<h1>Hello World</h1>

WebContent/WEB-INF/includes/header.jspf
<%@ page import='java.util.Vector'%>
  | 
  | <html>
  | <head>
  | <title>Test</title>
  | </head>
  | <body>
  | <p>
  | <%! boolean test=true; %>
  | <%
  | 	Vector v = new Vector();
  | 	v.add(new Integer(2));
  | %>
  | Value: <%= v.get(0).toString() %>
  | </p>

WebContent/WEB-INF/includes/footer.jspf
</body>
  | </html>

WebContent/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
  | <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  | 	id="WebApp_ID" version="2.5">
  | 	<display-name>Test</display-name>
  | 
  | 	<jsp-config>
  | 		<jsp-property-group>
  | 			<display-name>Test</display-name>
  | 			<url-pattern>/index.jsp</url-pattern>
  | 			<include-prelude>/WEB-INF/includes/header.jspf</include-prelude>
  | 			<include-coda>/WEB-INF/includes/footer.jspf</include-coda>
  | 		</jsp-property-group>
  | 	</jsp-config>
  | </web-app>


So far so good. Now I run the code (packed to a .war file) on JBoss 5.0.1.GA-jdk6. As soon as I access index.jsp JBoss starts to compile it. Unfortunately it terminates with the following exception:

<?xml version="1.0" encoding="UTF-8"?>
  | <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  | 	id="WebApp_ID" version="2.5">
  | 	<display-name>Test</display-name>
  | 
  | 	<jsp-config>
  | 		<jsp-property-group>
  | 			<display-name>Test</display-name>
  | 			<url-pattern>/index.jsp</url-pattern>
  | 			<include-prelude>/WEB-INF/includes/header.jspf</include-prelude>
  | 			<include-coda>/WEB-INF/includes/footer.jspf</include-coda>
  | 		</jsp-property-group>
  | 	</jsp-config>
  | </web-app>

So it seems to be unable to locate the "Vector" class which is imported within the header.

Looking at the generated index_jsp.java file reveals the following:

package org.apache.jsp;
  | 
  | import javax.servlet.*;
  | import javax.servlet.http.*;
  | import javax.servlet.jsp.*;
  | 
  | public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
  |     implements org.apache.jasper.runtime.JspSourceDependent {
  | 
  |  boolean test=true; 
  |   private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
  | 
  |   private static java.util.List _jspx_dependants;
  | 
  |   static {
  |     _jspx_dependants = new java.util.ArrayList(2);
  |     _jspx_dependants.add("/WEB-INF/includes/header.jspf");
  |     _jspx_dependants.add("/WEB-INF/includes/footer.jspf");
  |   }
  | ...

As you can see the class variable "test" of type boolean has been inserted but not the include.

I did not manage yet to find a work-around to this problem.

I tried JBoss 5.0.0.GA and 5.0.1.GA (both "normal" and "jdk6" editions). The same code runs perfectly on JBoss 4.2.3.
The code also works Tomcat 6.0.18.


As I am new to JBoss development somebody might point me the right direction to solve the problem or confirm that it is a bug.

Work-arounds or tryout versions of JBoss-Web are welcome too.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4215959#4215959

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4215959



More information about the jboss-user mailing list