How to deploy on tomcat

Hi,
Ive been working on my vaadin application for the las week and I’m ready to deploy it on my production tomcat server. Its the first time I work with servlet and I’m a bit confuse on how to do that.
I created a folder with my application name in my webapps foleder. I also uploaded the build classes and the content of the webcontent folder in that folder. I exported a .war with eclipse and uploaded it in my wabapps folder. I added that to my web.xml:

    
<servlet>
        <servlet-name>Blackberry_manager_2</servlet-name>
        <servlet-class>com.example.blackberry_manager_2.Blackberry_manager_2Application</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
           </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

But I always get a 404 error when I try to access the app.
Can someone help me and tell me what I’m doing wrong?
Thanks

The servlet-class must always be the Vaadin ApplicationServlet class and your application class is given to that as a parameter.

From
the Book
:

  <servlet>
    <servlet-name>myservlet</servlet-name>
    <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>MyApplicationClass</param-value>
    </init-param>
  </servlet>

When running under a portal or GAE the servlet class is a bit different.

Ok I just read the book and now my I changed my web.xml file to look like this:


<servlet>
    <servlet-name>Blackberry_Manager_2</servlet-name>
    <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>com.example.blackberry_manager_2.Blackberry_manager_2Application</param-value>
    </init-param>
 </servlet>

Still error 404
Any Idea what I’m doing wrong?

Well, the problem could be anything. You could check the tomcat logs if there’s some problem with deployment.

As you’re using Eclipse, did you create the Vaadin project with the Vaadin plugin for Eclipse? The Vaadin project wizard creates a working web.xml automatically. Does your application run ok if you deploy it to a server installed under Eclipse?

I hope you made the servlet-mapping in web.xml correctly as well, as described in the book.

Yes I’m using the vaadin plugin for eclipse and my project is working fine with the tomcat under eclipse but I can’t find the web.xml eclipse deployed…

Ok found the web.xml in eclipse. Now this is the error I get

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Wrapper cannot find servlet class com.vaadin.terminal.gwt.server.ApplicationServlet or a class it depends on
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	java.lang.Thread.run(Unknown Source)

root cause

java.lang.ClassNotFoundException: com.vaadin.terminal.gwt.server.ApplicationServlet
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1399)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1245)
	java.security.AccessController.doPrivileged(Native Method)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	java.lang.Thread.run(Unknown Source)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.

At least I have something to work with now… Any idea why I’m getting this?

Is Vaadin Jar included in the War?

Looking at the War export dialog in Eclipse I can’t see how it could get lost.

This could also be some deployment problem in Tomcat. Undeploy the application by removing both the .war and the deployment directory with the same basename from the webapps directory.

Yes the vaadin jar is in the war file just checked.
Ok just to be sure I’m doing this right:
I uploaded the content of the webcontent folder In the directory I want the app to run in(Blackberry_Manager_2):
3 folders: WEB-INF,VAADIN,META-INF
I uploaded the exported war file into the application folder.
Blackberry_Manager_2.war
I also uploaded the class folder from the build directory from my eclipse project directory to the WEB-INF folder.
And I copy pasted the content of the web.xml of eclipse to the web.xml file of my server:

root@Picard:/usr/share/tomcat6/webapps# cat /etc/tomcat6/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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">
        <display-name>Blackberry_Manager_2</display-name>
        <context-param>
                <description>
                Vaadin production mode</description>
                <param-name>productionMode</param-name>
                <param-value>false</param-value>
        </context-param>
        <servlet>
                <servlet-name>Blackberry_manager_2 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.blackberry_manager_2.Blackberry_manager_2Application</param-value>
                </init-param>
                <init-param>
                        <description>
                        Application widgetset</description>
                        <param-name>widgetset</param-name>
                        <param-value>com.example.blackberry_manager_2.widgetset.Blackberry_manager_2Widgetset</param-value>
                </init-param>
        </servlet>
        <servlet-mapping>
                <servlet-name>Blackberry_manager_2 Application</servlet-name>
                <url-pattern>/*</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>

I restarted tomcat … same result

Why don’t you just use Eclipse’s built-in capability to export a war ?

I did. My problem is I can’t get the war to work with my tomcat server.

Perhaps put the war on some location where people can download it and take a quick look at it. Copying files like you are describing is impossible to follow on a forum.

Also, I would suggest deploying to a completely virgin, brand new Tomcat, without any logs, and without any changes to the configuration. Then look at the various log files on your tomcat server. There is no reason that things would fail unless you have dependencies (e.g. native libraries) or System.properties that you have not made available in Tomcat. The logs likely have hints as to what is going on.

Ok Here’s what I did:
I create a new tomcat instance in my eclipse. Switch option in the server configuration from use workspace metadata to modify tomcat install. Published my application. Close eclipse started my local tomcat. This worked.
So I took the folder eclipse published uploaded on my production server (Witch I just reinstalled new config files new logs). Tried to access it: error 404.
Tomcat logs:

root@Picard:~# tail -f /var/log/tomcat6/catalina.2011-01-14.log
14-Jan-2011 7:54:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1495 ms
14-Jan-2011 7:54:13 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
14-Jan-2011 7:54:13 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
14-Jan-2011 7:54:15 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
14-Jan-2011 7:54:15 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1752 ms
root@Picard:~# cat /var/log/tomcat6/localhost.2011-01-14.log
14-Jan-2011 7:40:34 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
14-Jan-2011 7:40:34 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
14-Jan-2011 7:51:33 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
14-Jan-2011 7:51:33 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
14-Jan-2011 7:51:45 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
14-Jan-2011 7:51:45 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
14-Jan-2011 7:54:05 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
14-Jan-2011 7:54:05 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
14-Jan-2011 7:54:14 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
14-Jan-2011 7:54:14 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()

Witch tells me nothing… I’m sure I’m forgetting something very stupid here…

Please export a WAR file from Eclipse.
Please make sure that you have Tomcat fully running: please deploy your war using the administrative interface of Tomcat – after deploying your WebApp, Tomcat will give you a link you can click on.

Thanks,
Way easier this way. But still not working,but have something very clear in the logs :

SEVERE: Allocate exception for servlet Blackberry_manager_2 Application
java.security.AccessControlException: access denied (java.util.PropertyPermission com.vaadin.terminal.gwt.server.Debug read)
      ....

After reading this: http://vaadin.com/forum/-/message_boards/message/95450 I added that to /etc/tomcat6/policy.d/03catalina.policy


grant codeBase "file:/var/lib/tomcat6/webapps/Blackberry_Manager_2/WEB-INF/lib/-" {
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.Debug", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.debug", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.testingToolsActive", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.testingtoolsactive", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.ClassLoader", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.classloader", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.Resources", "read";
    permission java.util.PropertyPermission "com.vaadin.toolkit.terminal.gwt.server.resources", "read";
    permission java.util.PropertyPermission "catalina.home", "read";
    permission java.util.PropertyPermission "user.language", "write";

};

But still same problem

Ok got it added the line permission java.security.AllPermission;
Is that very insecure?

Shouldn’t this be “com.vaadin.terminal.get.server…” - remove the “toolkit.” part.
The example you copied from was probably still for the IT Mill Toolkit (the predecessor of Vaadin) with an extra level in package names.