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>

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