« Return to Thread: Q: tomcat 6 and Groovlets

Q: tomcat 6 and Groovlets

by grkuntzmd :: Rate this Message:

Reply to Author | View in Thread

I know this is not a tomcat forum, but I was hoping...

I am trying to do some very simple Groovlet/GSP samples from a tutorial I found at IBM DeveloperWorks.

I installed Tomcat 6.0.18 "out-of-the-box" using the Windows service installer on Vista. I have Groovy 1.5.6. I am running Java 6_10 (rc) and my JAVA_HOME is set correctly.

I created the following directory structure under webapps:

groove
groove/WEB-INF
groove/WEB-INF/lib
groove/WEB-INF/classes

In the groove/WEB-INF/lib directory, I copied groovy-all-1.5.6.jar.

I copy/pasted the web.xml file from the article into the groove/WEB-INF/web-xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation=
	 "http://java.sun.com/xml/ns/j2ee
	  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	 version="2.4">

  <display-name>Groovlet Demonstrator</display-name>
  <description>
	Show the use of Groovlets for Groovy
  </description>

  <servlet>
    <servlet-name>GroovyServlet</servlet-name>
    <servlet-class>groovy.servlet.GroovyServlet</servlet-class>
  </servlet>

  <servlet>
    <servlet-name>GroovyTemplate</servlet-name>
    <servlet-class>groovy.servlet.TemplateServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>GroovyServlet</servlet-name>
    <url-pattern>*.groovy</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>GroovyTemplate</servlet-name>
    <url-pattern>*.gsp</url-pattern>
  </servlet-mapping>
</web-app>

I just added the display-name and description elements.

I created a file called groove/example-1.gsp containing:

<html>
<head><title>index.gsp</title></head>
<body>
<b><% println "hello gsp" %></b>
<p>
<% wrd = "Groovy"
for (i in wrd){
%>
<h1> <%=i%> <br/>
<%} %>
</p>
</body>
</html>

When I connect to http://localhost:8080/groove/example-1.gsp, I get the following error:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

I also installed the sample.war file from the tomcat docs and when I connect to http://localhost:8080/sample/hello.jsp, it works fine, so I know that JSP can find the CATALINA_HOME/lib/servlet-api.jar file.

Any ideas?

G. Ralph Kuntz, MD

 « Return to Thread: Q: tomcat 6 and Groovlets