Variable Length Argument List with Tomcat/JSP fails to compile.

S

smm1

I have a method that takes a variable length arg list:
"testmethod(int...in)".

Using this method from a 'regular' java program (i.e. via 'main') works
just fine, but when invoked from Tomcat/JSP I get an error:

"Generated servlet error:
The method testmethod(int[]) in the type testclass is not applicable
for the arguments (int, int, int)"

The java:

package testpackage ;
public class testclass {
public static int testmethod(int... in) {
return in[1] ;
}
public static void main(String[] args) {
System.out.println(testmethod(1,2,3)) ;
}
}

The JSP:
<%@ page import="testpackage.testclass.*" %>
<%
out.println(testpackage.testclass.testmethod(1,2,3));
%>

I'm using Tomcat 5.5.12 and java 1.5.0_06.

Any ideas on how I can get this JSP to compile? Thanks for any help.
 
S

smm1

Juha-
Thanks for pointing me in the right direction.

Eventually I got it going by downloading current copies of:
- jasper-compiler-jdt.jar
- jasper-compiler.jar
- jasper-runtime.jar
This solves the problem, with no config required.

But before, that I found another solution:

1. Adding the following lines to conf/web.xml
<servlet>
<servlet-name>jsp</servlet-name>

<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>

<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<!-- added these lines...
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
....
This by itself does not solve the problem.

2. remove common/lib/jasper-compiler-jdt.jar

3. Download the current ant release from
http://ant.apache.org/bindownload.cgi and copy ant.jar to
common/lib/ant.jar

4. Copy tools.jar from $JAVA_HOME/lib to common/lib
 
S

smm1

Juha-
Thanks for pointing me in the right direction.

Eventually I got it going by downloading current copies of:
- jasper-compiler-jdt.jar
- jasper-compiler.jar
- jasper-runtime.jar
This solves the problem, with no config required.

But before, that I found another solution:

1. Adding the following lines to conf/web.xml
<servlet>
<servlet-name>jsp</servlet-name>

<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>

<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<!-- added these lines...
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
....
This by itself does not solve the problem.

2. remove common/lib/jasper-compiler-jdt.jar

3. Download the current ant release from
http://ant.apache.org/bindownload.cgi and copy ant.jar to
common/lib/ant.jar

4. Copy tools.jar from $JAVA_HOME/lib to common/lib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top