无法将servlet示例GWT应用程序部署到Apache Tomcat 7

时间:2013-04-19 03:12:59

标签: gwt tomcat servlets tomcat7 gwt-rpc

此处找到原始的,不太详细的问题:Cannot figure out why I cannot deploy GWT application onto Apache Tomcat 7。在我写这篇文章的时候,我决定再试一次,但是这次它工作了,示例应用程序中的servlet似乎不起作用。它说"远程过程调用失败"单击按钮时。这是我采取的步骤列表。

以下是我尝试将示例应用程序部署到Apache Tomcat 7时所做的事情列表。

设置环境

  1. 在虚拟机上安装Ubuntu 12.04
  2. 更新了系统
  3. 从此处的教程https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04安装Apache Tomcat 7。
  4. 启动它并转到localhost:8080以查看它是否正常工作。
  5. 获取示例项目

    1. 安装了GWT。
    2. 使用Eclipse向导,创建一个名为" SampleApp"
    3. 的新项目
    4. 在开发模式下运行一次以确保其正常工作。
    5. 编译模块。它完成整个 - 编译6个排列等。
    6. 编译成.war文件,如下所示http://blog.elitecoderz.net/gwt-and-tomcat-create-war-using-eclipse-to-deploy-war-on-tomcat/2009/12/(文件称为SampleApp.war)
    7. 部署

      1. 将SampleApp.war复制到Apache Tomcat中的webapps文件夹
      2. .war解压缩自己,我现在可以在localhost:8080 / SampleApp / SampleApp.html上访问我的应用。
      3. 但是,现在我的问题是服务器端代码似乎不起作用。

        localhost_access_log的内容

          

        127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]" GET /SampleApp/SampleApp.html HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]" GET /SampleApp/SampleApp.css HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]" GET /SampleApp/sampleapp/sampleapp.nocache.js HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]" GET /SampleApp/sampleapp/gwt/clean/clean.css HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]" GET /SampleApp/sampleapp/gwt/clean/images/hborder.png HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:44 -0700]" POST / SampleApp / sampleapp / greet HTTP / 1.1" 500 2773   127.0.0.1 - - [18 / Apr / 2013:21:03:44 -0700]" GET /SampleApp/sampleapp/gwt/clean/images/circles.png HTTP / 1.1" 304 -   127.0.0.1 - - [18 / Apr / 2013:21:03:44 -0700]" GET /SampleApp/sampleapp/gwt/clean/images/vborder.png HTTP / 1.1" 304 -

        localhost.2013-04-18的内容

          

        2013年4月18日下午8:02:05 org.apache.catalina.core.ApplicationContext   log INFO:ContextListener:contextInitialized()2013年4月18日8:02:05   PM org.apache.catalina.core.ApplicationContext log INFO:   SessionListener:contextInitialized()2013年4月18日下午8:02:05   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   attributeAdded(' org.apache.jasper.compiler.TldLocationsCache&#39 ;,   ' org.apache.jasper.compiler.TldLocationsCache@dc0435')2013年4月18日   8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO:   ContextListener:contextInitialized()2013年4月18日下午8:02:16   org.apache.catalina.core.ApplicationContext log INFO:SessionListener:   contextInitialized()2013年4月18日下午8:02:16   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   attributeAdded(' org.apache.jasper.compiler.TldLocationsCache&#39 ;,   ' org.apache.jasper.compiler.TldLocationsCache@113e9fd')2013年4月18日   8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO:   SessionListener:contextDestroyed()2013年4月18日下午8:02:16   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   contextDestroyed()2013年4月18日下午8:29:48   org.apache.catalina.core.ApplicationContext log INFO:SessionListener:   contextDestroyed()2013年4月18日下午8:29:48   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   contextDestroyed()2013年4月18日晚上8:30:00   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   contextInitialized()2013年4月18日晚上8:30:00   org.apache.catalina.core.ApplicationContext log INFO:SessionListener:   contextInitialized()2013年4月18日晚上8:30:00   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   attributeAdded(' org.apache.jasper.compiler.TldLocationsCache&#39 ;,   ' org.apache.jasper.compiler.TldLocationsCache@180cb01')2013年4月18日   下午9:03:36 org.apache.catalina.core.ApplicationContext log INFO:   SessionListener:contextDestroyed()2013年4月18日下午9:03:36   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   contextDestroyed()2013年4月18日下午9:03:41   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   contextInitialized()2013年4月18日下午9:03:41   org.apache.catalina.core.ApplicationContext log INFO:SessionListener:   contextInitialized()2013年4月18日下午9:03:41   org.apache.catalina.core.ApplicationContext log INFO:ContextListener:   attributeAdded(' org.apache.jasper.compiler.TldLocationsCache&#39 ;,   ' org.apache.jasper.compiler.TldLocationsCache@18600d6')

        GreetingService.java

        package com.sample.client;
        
        import com.google.gwt.user.client.rpc.RemoteService;
        import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
        
        /**
         * The client side stub for the RPC service.
         */
        @RemoteServiceRelativePath("greet")
        public interface GreetingService extends RemoteService {
            String greetServer(String name) throws IllegalArgumentException;
        }
        

        /WEB-INF/web.xml

        <?xml version="1.0" encoding="UTF-8"?>
        <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                 version="2.5"
                 xmlns="http://java.sun.com/xml/ns/javaee">
        
          <!-- Servlets -->
          <servlet>
            <servlet-name>greetServlet</servlet-name>
            <servlet-class>com.sample.server.GreetingServiceImpl</servlet-class>
          </servlet>
        
          <servlet-mapping>
            <servlet-name>greetServlet</servlet-name>
            <url-pattern>/sampleapp/greet</url-pattern>
          </servlet-mapping>
        
          <!-- Default page to serve -->
          <welcome-file-list>
            <welcome-file>SampleApp.html</welcome-file>
          </welcome-file-list>
        
        </web-app>
        

        我在通过eclipse生成项目后改变了注意事项。

        由于我仍在尝试解决这个问题,因此可能与Java 1.6和1.7 SDK以及tomcat与它们交互的方式有关

2 个答案:

答案 0 :(得分:0)

尝试使用GWT编译您的示例应用程序 - 编译并将项目的war目录的内容复制到tomcat / webapps / sample。之后检查你在网址的应用

http://localhost:8080/example

答案 1 :(得分:0)

path的问题。

@RemoteServiceRelativePath("sampleapp/greet");

or 

@RemoteServiceRelativePath("../greet");

请参阅@chris Deploy GWT to Tomcat (servlet not running)

相关问题