gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 23:44:24 25 4
gpt4 key购买 nike

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

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

设置环境

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

获取示例项目

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

部署

  1. 将 SampleApp.war 复制到 Apache Tomcat 的 webapps 文件夹中
  2. .war 自行解压缩,我现在可以在 localhost:8080/SampleApp/SampleApp.html 上访问我的应用程序。

但是,现在我的问题是服务器端代码似乎不起作用。

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的内容

Apr 18, 2013 8:02:05 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 18, 2013 8:02:05 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() Apr 18, 2013 8:02:05 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@dc0435') Apr 18, 2013 8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 18, 2013 8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() Apr 18, 2013 8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@113e9fd') Apr 18, 2013 8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextDestroyed() Apr 18, 2013 8:02:16 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextDestroyed() Apr 18, 2013 8:29:48 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextDestroyed() Apr 18, 2013 8:29:48 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextDestroyed() Apr 18, 2013 8:30:00 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 18, 2013 8:30:00 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() Apr 18, 2013 8:30:00 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@180cb01') Apr 18, 2013 9:03:36 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextDestroyed() Apr 18, 2013 9:03:36 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextDestroyed() Apr 18, 2013 9:03:41 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 18, 2013 9:03:41 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() Apr 18, 2013 9:03:41 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', '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 与它们交互的方式有关

最佳答案

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

http://localhost:8080/example

关于gwt - 无法将 servlet 示例 GWT 应用程序部署到 Apache Tomcat 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16096617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com