Problems deploying GWT app in Tomcat

768 views
Skip to first unread message

Jostein

unread,
Jan 23, 2013, 5:52:30 AM1/23/13
to google-we...@googlegroups.com
Hi
I have developed an application in dev mode in Eclipe for some time and everything workes fine. Yesterday I tried to deploy to Tomcat, but the application did not launch in the browser. 
Then I tried the same with a basic Web Application Starter Project, generated automatically when creating a new GWT project i Eclipse. The new project consists of some basic functionality, RPC included.

The deploying process goes like this (this is my understandig of how to do it)
1. Perform "GWT Compile Project" from the blue "g" dropdown in the toolbar in Eclipse
2. Use default settings in the "GWT compile" dialog. Press "Compile".
3. After comiling I select the .war folder in the TestTomcat project in Eclipse.
4. Then rightclick ->  Export -> Archive file -> Next
5. Change the "To archive file" to "D:\apache-tomcat-7.0.34\webapps\TestTomcat.war.zip" -> Finish
6. Opens the D:\apache-tomcat-7.0.34\webapps folder and renames the "TestTomcat.war.zip" to "TestTomcat.war"
7. Then I restart Tomcat and now a new folder "TestTomcat" has been created in the webapps folder

I run my app in a browser with this url:

The application starts as expected, but when I press the "Send" button that is sending a name to the server I get an error message
"An error occurred while attempting to contact the server. Please check your network connection and try again."

My JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09

a) Why doesn't RPC work?
b) Is this the correct way to deploy GWT application in Tomcat?

Any help is appreciated.

Thanks
Jostein

Thomas Broyer

unread,
Jan 23, 2013, 6:09:16 AM1/23/13
to google-we...@googlegroups.com
The fact your host page is at "TestTomcat/TestTomcat/war/TestTomcat.html" should ring a bell. It should probably be at "TestTomcat/TestTomcat.html" instead, which means your *.war isn't packaged correctly. The WEB-INF/ folder should be at the root of the WAR, alongside the TestTomcat.html.
 
b) Is this the correct way to deploy GWT application in Tomcat?

Probably not. Any "correct" way in my book would involve a build script (Ant, Maven, Gradle, or even Make or a shell/batch script) to package the app.
Dropping the WAR into Tomcat's webapps dir and restarting Tomcat is OK though; see http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html#Deployment_With_Tomcat (read through the whole tutorial, a GWT is no different, just that the javascript is generated from Java code by an additional build step)

Lukasz Plotnicki

unread,
Jan 23, 2013, 9:23:11 AM1/23/13
to google-we...@googlegroups.com
As Thomas already stated, the best way would be to use a proper build system. I use maven and maven-gwt-plugin which works just perfectly. 

But if you don't have any spare time to switch to maven right now, you will get your app running performing your step 1 & 2 and then putting everything in the war directory of your project into an war archive which can be easly deployed on tomcat.

HTH,
Lukasz

Jostein

unread,
Jan 23, 2013, 10:45:27 AM1/23/13
to google-we...@googlegroups.com
Hi
Thank you for quick answers. I have been searching a bit more today and I found a link to a plugin for Eclipse that solves this issue in one operation.
After installing the plugin I got a new menu item in the gogle menu "GWT Web app export..." that compiles to a war file in a selected destination folder. I selected Tomcat webapp folder as destination for my TestTomcat app and this time the war structure is correct. The url http://locahost/TestTomcat/TestTomcat.html starts the applicatiuon and this tome the server replies as expected.
So, I am a step futher now.

Hovewer, I have an issue with my other application. It compiles correctly in Eclipse (Compilation secceeded..), but it fails to be installed in Tomcat. Error mesage, cut from the log:

SEVERE: Error deploying web application archive D:\apache-tomcat-7.0.34\webapps\Betelo2.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Betelo2]]

I guess this is a tomcat issue and should be addressed in an other forum (??) but if any of you can shed light on this issue I am very grateful.

Regards,
Jostein

Jens

unread,
Jan 23, 2013, 11:12:06 AM1/23/13
to google-we...@googlegroups.com

Hovewer, I have an issue with my other application. It compiles correctly in Eclipse (Compilation secceeded..), but it fails to be installed in Tomcat. Error mesage, cut from the log:

SEVERE: Error deploying web application archive D:\apache-tomcat-7.0.34\webapps\Betelo2.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Betelo2]]

No additional information available? The log above does not give any hints about what could be wrong. Maybe you have two webapps with the same context path /Betelo2 in your tomcat folder?

-- J.

Adolfo Rodriguez

unread,
Jan 23, 2013, 9:39:45 AM1/23/13
to google-we...@googlegroups.com
do not make a war file, just copy your war directory and paste it as an app in Tomcat's webapps folder




De: Lukasz Plotnicki <l.plo...@gmail.com>
Para: google-we...@googlegroups.com
Enviado: Miércoles 23 de enero de 2013 15:23
Asunto: Re: Problems deploying GWT app in Tomcat

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/5jhFazA2H_4J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Jostein

unread,
Jan 24, 2013, 2:40:52 AM1/24/13
to google-we...@googlegroups.com
Here is an snippet from the Tomcat log that probably explains the problem.

Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> betelo2/commondata in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3217)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3192)
at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1304)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1352)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
...
As a said. Everething works fine in dev mode, but I get this error when deploying to Tomcat
and here is a snippet from my web.xml

 <!-- Servlets -->
  <servlet>
    <servlet-name>loginServlet</servlet-name>
    <servlet-class>com.fdv.betelo2.server.LoginServiceImpl</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>commonDataServlet</servlet-name>
    <servlet-class>com.fdv.betelo2.server.CommonDataServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>loginServlet</servlet-name>
    <url-pattern>betelo2/login</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>commonDataServlet</servlet-name>
    <url-pattern>betelo2/commondata</url-pattern>
  </servlet-mapping>

I cannot see what is wrong here. I am grateful for any help.

Regards, 
Jostein

kl. 11:52:30 UTC+1 onsdag 23. januar 2013 skrev Jostein følgende:

Lukasz Plotnicki

unread,
Jan 24, 2013, 4:26:12 AM1/24/13
to google-we...@googlegroups.com
Should it not be: 

 <servlet-mapping>
    <servlet-name>loginServlet</servlet-name>
    <url-pattern>/betelo2/login</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>commonDataServlet</servlet-name>
    <url-pattern>/betelo2/commondata</url-pattern>
  </servlet-mapping>

HTH,
Lukasz
Reply all
Reply to author
Forward
0 new messages