2

I imported a java project(war file) to eclipse. When I tried to run it , I got following error :

java.lang.Error: Unresolved compilation problems: 
The type List is not generic; it cannot be parameterized with arguments <User>
Syntax error, parameterized types are only available if source level is 5.0

I tried to google it. I found that I have to change compliance settings. I changed the compiler compliance level to 5 but it did not solve the problem. Can anybody help me to solve this problem? Thanks in advance.

1
  • Is this inside a JSP, or proper Java code? Commented Oct 29, 2010 at 11:29

4 Answers 4

2

There are two things you might have to take care of.

  1. The compiler setting.
  2. The runtime setting.

I guess you should have taken care of (1). What you may have missed is the second one. When you try to run that war file, go to "Run As" --> "Run configurations". There you can select the Java version. I assume this is the place you are having an issue. Try setting it to Java 1.5 or higher.

http://img638.imageshack.us/img638/8845/runconfig.jpg

Sign up to request clarification or add additional context in comments.

Comments

1

Check java version for your servlet container. You can check Java version in shell by typing

java -version

If its not 1.5+ point to relevant JDK of higher version..

1 Comment

It is java "1.5.0_11" version.
0

That war is using 'generics' somewhere. and generics is only available with java 5 and above thats the error is saying

please check your java compiler level

1 Comment

I am using java version 1.5.0_11" .
0

The first step to resolving this issue, is to completely ignore the hint "-source 1.5 to enable generics". That message will take you nowhere! The reason being that it originates from the javac compiler, while you need to configure the jasper JSP compiler. This is fortunately quite easy, although finding out on the Tomcat site is quite convoluted. All you need to do is to edit your TOMCAT_INSTALL\conf\web.xml. Add to the org.apache.jasper.servlet.JspServlet the following lines

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

such that the servlet looks something like the following

[web.xml]

<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>
    <load-on-startup>3</load-on-startup>
</servlet>

You have now configured your Tomcat JSP server... Configuring Eclipse The EE edition of Eclipse has a nice feature of enabling you to create a Dynamic web project - essentially an exploded war file and manage the server instance for you and set up debugging. Convenient once you know how it works. Basically what the standard setup does, is that it copies the Tomcat configuration files from your install directory onto some obscure path similar to c:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\conf\ The first thing to realize is that it copies the files from your installed Tomcat directory quite frequently, so editing your web.xml in this directory as instructed above will only work for a short time.

You may also try editing the web.xml under the Servers project Eclipse installs when you setup your first server. I had a very hard time making Eclipse pick up changes in this file..

Instead, simply delete your server instance and re-create it. Your changes will now have been picked up and you are ready to go!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.