NetBeans 6.1 and 6.5 workaround - Servlet API classes are not on the classpath


When we import existing Maven projects or create a new Maven project using Mevenide plugin in NetBeans 6.1 or NetBeans 6.5 Beta and then open a JSP, we get the following message at the bottom of the editor

Servlet API classes are not on the classpath , some scriptlet editing features are disabled

This prevents autocomplete feature being available for special tags like tags related to JSF [the usual h: and f:].

Let us discuss how to avoid this. When a Maven project is imported or created using Mevenide plugin, NetBeans 6.1 or 6.5 Beta  does  not add the servlet api and related jar files in the classpath. May be it treats Maven projects as if they are simple Java projects and not as web applications.

Hence we have to add the following jar files (dependencies) in the POM.xml so that the servlet api jars are added to the classpath of the application. The scope is set to provided so that they are not copied into the war file.

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.16</version>
 <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>el-api</artifactId>
<version>6.0.16</version>
 <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jsp-api</artifactId>
<version>6.0.16</version>
 <scope>provided</scope>
</dependency>

 
 
 
 
Comments:

Well, I consider this an issue with the j2ee support of netbeans, rather than of maven support. The issue is that ant based projects put automatically the app server's jars on classpath of the project, therefore assume servlet api is on classpath. In maven, it's not feasible to put the complete app server binaries when opening in netbeans (you would either do it dynamically and break command line builds, or you would populate people's pom.xml files with rubbish. So I consider your workaround really a proper way of doing things, if you want servlet API, you should add it to the POM. However when a servlet for example is added to project sources, the IDE (j2ee support) shall make sure to add servlet api on classpath. That's not happening now, feel free to file it as a bug (not sure if it already is or not)

Posted by Milos Kleint on August 17, 2008 at 01:41 PM CDT #

Post a Comment:
  • HTML Syntax: Allowed
 

« January 2009
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Valid XHTML or CSS?

[This is a Roller site]
 
© Karthik