无法将Servlet示例GWT应用程序部署到Apache Tomcat 7 [英] Cannot deploy servlet sample GWT app to Apache Tomcat 7

查看:177
本文介绍了无法将Servlet示例GWT应用程序部署到Apache Tomcat 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始的,不太详细的问题在这里找到:无法弄清楚为什么我无法将GWT应用程序部署到Apache Tomcat 7上。在我写这篇文章时,我决定再次尝试一次,但这一次它仍然有效,示例应用程序中的servlet似乎不起作用。它在点击按钮时显示远程过程调用失败。这是我采取的步骤列表。



以下列出了我为了将示例应用程序部署到Apache Tomcat 7而需要做的事情。



设置环境



  1. >更新系统

  2. 从教程安装Apache Tomcat 7 https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04

  3. 启动它并转到localhost:8080以查看它正在工作。

获取示例项目
$ b


  1. 使用Eclipse向导创建一个名为SampleApp的新项目

  2. 在开发模式下运行一次确保它的工作。

  3. 编译模块。它完成整个编译6个排列组合。

  4. 编译为.war文件,如下所示 http://blog.elitecoderz.net/gwt-and-tomcat-create-war-使用-eclipse-to-deploy-war-on-tomcat / 2009/12 / (文件名为SampleApp.war)




$ b


  1. 将SampleApp.war复制到Apache Tomcat的webapps文件夹中
  2. $ b $ b
  3. .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.1304 -
127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]GET / SampleApp / SampleApp.css HTTP / 1.1304 -
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.1304 -
127.0.0.1 - - [18 / Apr / 2013:21:03:43 -0700]GET /SampleApp/sampleapp/gwt/clean/images/hborder.png HTTP / 1.1304 -
127.0.0.1 - - [18 / Apr / 2013:21:03:44 -0700]POST / SampleApp / sampleapp / greet HTTP / 1.1500 2773
127.0.0.1 - - [18 / Apr / 2013:21:03 :44 -0700]GET /SampleApp/sampleapp/gwt/clean/images/circles.png HTTP / 1.1304 -
127.0.0.1 - - [18 / Apr / 2013:21:03:44 -0700]GET /SampleApp/sampleapp/gwt/clean/images/vborder.png HTTP / 1.1304 -


localhost.2013-04-18的内容


2013年4月18日8 :02:05 PM org.apache.catalina.core.ApplicationContext
日志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 PM
org.apache.catalina.core.ApplicationContext日志信息: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()2013年4月18日8:02:16
org.apache.catalina.core.ApplicationContext日志INFO:SessionListener:
contextInitialized()2013年4月18日8 :02:16 PM
org.apache.catalina.core.ApplicationContext log INFO:ContextListener:
attributeAdded('org.apache.jasper.compiler.TldLocationsCache',
'org.apache.jasper.compiler.TldLocationsCache @ 113e9fd')2013年4月18日
8:02:16 PM org.apache.catalina.core.ApplicationContext日志信息:
SessionListener:contextDestroyed()2013年4月18日8:02:16 PM
org.apache.catalina.core.ApplicationContext log INFO:ContextListener:
contextDestroyed()2013年4月18日8:29:48 PM
org.apache.catalina.core.ApplicationContext日志信息: SessionListener:
contextDestroyed()2013年4月18日下午8:29:48
org.apache.catalina.core.ApplicationContext日志信息:ContextListener:
contextDestroyed()2013年4月18日8: 30:00 PM
org.apache.catalina.core.ApplicationContext日志INFO:ContextListener:
contextInitialized()2013年4月18日8:30:00 PM
org.apache.catalina.core .ApplicationContext日志INFO:SessionListener:
contextInitialized()4月18日,2日013 8:30:00 PM
org.apache.catalina.core.ApplicationContext log INFO:ContextListener:
attributeAdded('org.apache.jasper.compiler.TldLocationsCache',
'org。 apache.jasper.compiler.TldLocationsCache@180cb01')2013年4月18日
9:03:36 PM org.apache.catalina.core.ApplicationContext日志信息:
SessionListener:contextDestroyed()2013年4月18日下午9:03:36
org.apache.catalina.core.ApplicationContext日志INFO:ContextListener:
contextDestroyed()2013年4月18日下午9:03:41
org.apache.catalina .core.ApplicationContext日志INFO:ContextListener:
contextInitialized()2013年4月18日9:03:41 PM
org.apache.catalina.core.ApplicationContext日志信息:SessionListener:
contextInitialized )2013年4月18日9:03:41
org.apache.catalina.core.ApplicationContext log INFO:ContextListener:
attributeAdded('org.apache.jasper.compiler.TldLocationsCache',
'org.apache.jasper.compiler.TldLocationsCache@18600d6')


GreetingService.java

 包com.sample.client; 

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/ **
* RPC服务的客户端存根。
* /
@RemoteServiceRelativePath(greet)
public interface GreetingService extends RemoteService {
String greetServer(String name)throws IllegalArgumentException;
}

/WEB-INF/web.xml

 <?xml version =1.0encoding =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>

<! - 要投放的默认页面 - >
< welcome-file-list>
< welcome-file> SampleApp.html< / welcome-file>
< / welcome-file-list>

< / web-app>

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



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

解决方案

路径存在问题

  @RemoteServiceRelativePath( sampleapp /迎); 



@RemoteServiceRelativePath(../ greet);

请参阅@chris 将GWT部署到Tomcat(servlet未运行)


Original, less detailed question found here: Cannot figure out why I cannot deploy GWT application onto Apache Tomcat 7. As I was writing this, I decided to try it again and this time it worked however, the servlet in the sample Application does not seem to work. It says "Remote Procedure Call Failure" when clicking the button. Here's the list of steps i took.

Here are the list of things I tried to do in order to deploy a sample app to Apache Tomcat 7.

Setting Up Environment

  1. Install Ubuntu 12.04 on Virtual Machine
  2. Updated system
  3. Install Apache Tomcat 7 from tutorial here https://www.digitalocean.com/community/articles/how-to-install-apache-tomcat-on-ubuntu-12-04.
  4. Start it and go to localhost:8080 to see that it is working.

Getting Sample Project

  1. Have GWT installed.
  2. Using Eclipse Wizard, Create a new project called "SampleApp"
  3. Run it once in development mode to ensure it works.
  4. Compile the module. it does the whole - compiling 6 permutations etc.
  5. Compile into .war file as shown here http://blog.elitecoderz.net/gwt-and-tomcat-create-war-using-eclipse-to-deploy-war-on-tomcat/2009/12/ (file is called SampleApp.war)

Deploying

  1. Copy SampleApp.war into webapps folder in Apache Tomcat
  2. The .war unzips itself and i can now access my app on localhost:8080/SampleApp/SampleApp.html.

However, now my problem is that the server-side code does not seem to work.

The content of 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 -

The content of 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>

I've changed noting after generating the project via eclipse.

As I am still trying to figure this out, it may possible have something to do with Java 1.6 and 1.7 SDK and the way tomcat interacts with them

解决方案

Problem with the path.

@RemoteServiceRelativePath("sampleapp/greet");

or 

@RemoteServiceRelativePath("../greet");

Refer @chris Deploy GWT to Tomcat (servlet not running)

这篇关于无法将Servlet示例GWT应用程序部署到Apache Tomcat 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆