javax.servlet.UnavailableException: Servlet class com.vaadin.terminal.gwt.s

Hi all,

I’m fairly new to vaadin, but so far all I can say is: awesome work!

I’m having a problem running my application. I’m deploying it to a Jetty server at runtime, as I start the server I’m getting this exception:

HTTP ERROR 404

Problem accessing /prova-vaadin. Reason:

Servlet class com.vaadin.terminal.gwt.server.ApplicationServlet is not a javax.servlet.Servlet

Caused by:

javax.servlet.UnavailableException: Servlet class com.vaadin.terminal.gwt.server.ApplicationServlet is not a javax.servlet.Servlet
at org.eclipse.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:339)
at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:225)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:694)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:193)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:966)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:230)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at paripari.GUI.ServerStarter.startServer(ServerStarter.java:47)
at paripari.GUI.GUI.init(GUI.java:117)
at paripari.plugin.Plugin.go(Plugin.java:313)
at paripari.core.PariPariRunnable.run(PariPariRunnable.java:99)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

of which I can’t figure out the cause. If I run the application on Tomcat 6 or Jetty in eclipse everything goes fine.

Maybe I’m doing something wrong with the project setup: I have the gwt-dev and gwt-user jars, along with java servlet-api, vaadin and refresher jars, in my WebContent/WEB-INF/lib folder.

This is the web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>prova-vaadin</display-name>
  <context-param>
  	<description>
  	Vaadin production mode</description>
  	<param-name>productionMode</param-name>
  	<param-value>false</param-value>
  </context-param>
  <servlet>
  	<servlet-name>Prova_vaadin Application</servlet-name>
  	<servlet-class>
  	com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
  	<init-param>
  		<description>
  		Vaadin application class to start</description>
  		<param-name>application</param-name>
  		<param-value>com.example.prova_vaadin.Prova_vaadinApplication</param-value>
  	</init-param>
  	<init-param>
  		<description>
  		Application widgetset</description>
  		<param-name>widgetset</param-name>
  		<param-value>com.example.prova_vaadin.widgetset.Prova_vaadinWidgetset</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Prova_vaadin Application</servlet-name>
  	<url-pattern>/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
  	<servlet-name>Prova_vaadin Application</servlet-name>
  	<url-pattern>/VAADIN/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Hi,

Normally you’d only have the vaadin and refresher jars in WEB-INF/lib (and your problem sure sounds like a classloading problem).

(Did you use the Vaadin Eclipse plugin to set up the project structure? You don’t have to, but it might help.)

Best Regards,
Marc

Hi Marc,
thanks for the fast response.
Yes, I’m using the eclipse plugin, but I somehow still managed to mess it up :smiley:

As you suggested, I removed everythig from my WEB-INF/lib folder but the vaadin and refresher jars. I imported the whole gwt directory, moved the servlet-api jar to a /lib folder in the project root directory.

As I moved the servlet-api jar, the exception changed into a plain:

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass1(Native Method)
… (full stack trace included in the attached file)

This is why I put all the jars in the WEB-INF/lib folder in the first place. Should I export in some way the gwt libraries when making the WAR?
11391.txt (3.17 KB)

Hi,

Try making a new project with the plugin and look how that’s structured; in the first screenshot attached I did a new Vaadin Project, pressed finish, and got the structure in the second. This project should work when you do a ‘Export as WAR’. Add-on jars can be drag&dropped into WEB-INF/lib, and the whole thing should still work.

Best Regards,
Marc
[b]

NOTE: everything under “Libraries” is added automatically - no need to manually include servlet jars etc.
[/b]
11394.png
11395.png