JSP compiler configuration in JBoss 4.2.x for ATG
Wednesday, February 24, 2010 at 12:58AM By default, the JSP compiler in JBOSS does not generate code compliant with Java 5, even if Java 5 (or Java 6) is the only JVM present.
This leads to exceptions in JSP's that depend on autoboxing feature added by Java 5 - automatic conversion of primitive type (e.g. int) to their object wrapper equivalents (e.g. Integer). As soon as the JSPs depend on this feature, run time error occurs.
How to detect the problem:
If the following page throws exception, your JBoss settings are wrong:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h1>DEBUG PAGE</h1>
<h2>2+2 ${2+2}</h2>
<c:set var="someVar" value="<%= 10 %>" scope="request" />
The exception generated is
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /test/dbg1.jsp
The method setValue(Object) in the type SetTag is not applicable for the arguments (int)
3: <h1>DEBUG PAGE</h1>
4:
5: <h2>2+2 ${2+2}</h2>
6: <c:set var="someVar" value="<%= 10 %>" scope="request" />
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
... [[ truncated ]] ...
If the line 6 is changed to
<c:set var="someVariable" value="<%= new Integer(10) %>" scope="request" />
the JSP file will compile OK.
Error is caused by an attempt to assign int value 10 to variable of type Object
How to fix the error
As described in JBoss Howto the default value for compilerSourceVM and compilerTargetVM is 1.4. We need to set the init parameters to value 1.5.
In JBoss installation, locate the server used for ATG deployment (e.g. atg) and modify the web.xml file in SERVER/deploy/jboss-web.deployer/conf
Add the following init parameters:
<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>
Miro Adamy |
1 Comment | 
Reader Comments (1)
We had to do the same thing for our ATG 2007.1 application running on JBoss 4.0.5. It was in a slightly different folder though:
/deploy/jbossweb-tomcat55.sar/conf/web.xmlBy the way, it's always good to find ATG related blog entries. I've been working with ATG for less than two years, and I'm always looking for tips, "how tos", etc.
Thanks.