Monday, September 3, 2007

JBoss - JasperException in JSP using generics and 'for each'

JBoss 4.2.0 throws the following exception while using generics in JSP even if java version is 1.5 or greater

Syntax error, parameterized types are only available if source level is 5.0
Syntax error, 'for each' statements are only available if source level is 5.0

The workaround for this issue is to add the following XML configuration to
${jboss.home}/server/default/deploy/jboss-web.deployer/conf/web.xml

Add

<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>

inside <servlet> tag with <servlet-name>jsp</servlet-name> inside it.
(Note that there are many servlet tags in this web.xml, so be careful)

7 comments:

Anonymous said...

thank you !
this has perfectly solved my problem which was caused by this code:
List<> lp=new ArrayList<>();
with a class name between those <>
same error
Syntax error, parameterized types are only available if source level is 5.0

Unknown said...

Thank !!!
it worked my problem too, with a List

Anonymous said...

designer fashion handbags
Louis Vuitton
gucci
hermes
chanel
designer fashion handbags
replica Louis Vuitton handbags
replica gucci handbags
replica hermes handbags
replica chanel handbags
designer fashion handbags
designer Louis Vuitton handbags
designer gucci handbags
designer hermes handbags
designer chanel handbags
designer fashion handbags
knockoff Louis Vuitton handbags
knockoff gucci handbags
knockoff hermes handbags
knockoff chanel handbags
designer fashion handbags
cheap Louis Vuitton handbags
cheap gucci handbags
cheap hermes handbags
cheap chanel handbags
designer fashion handbags
discount Louis Vuitton handbags
discount gucci handbags
discount hermes handbags
discount chanel handbags

Louis Vuitton outlet
gucci outlet
chanel purses
hermes birkin
笑话大全

Anonymous said...

You are the guy. Thank you so much.

Anonymous said...

Thanks a lot. That helped.

Hk said...
This comment has been removed by the author.
Hk said...

I had the same issue on JBoss-4.0.5.GA, so I did the same that is suggested in this post, add those init parms to the servlet, and the problem was solved.

The path for the web.xml changed a little bit:

${jboss.home}/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml