如何将GWT应用程序部署到tomcat [英] how to deploy GWT app to tomcat

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

问题描述

我搜索了这个网站来回答这个问题,但找不到解决方案。
我所做的只是在eclipse GWT应用程序项目中压缩war目录,然后将其重命名为.war,然后将其放到tomcat webapps文件夹中。
当我运行web应用程序时,第一个屏幕成功显示,但是当我在我的src代码中调用一个servlet时,它给我的资源找不到tomcat服务器。
我确定我已经在web.xml文件中添加了servlet的条目,当我在eclipse gwt dev模式下运行它时,该应用运行良好。有些东西阻止我的servlet(标准servlet而不是GWT RPC servlet)被tomcat找到并执行。可能是什么原因?




UPDATE



web。 xml

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE web-app
PUBLIC - // Sun Microsystems,Inc. //DTD Web Application 2.3 // EN
http://java.sun.com/ DTD /网络app_2_3.dtd>

< web-app>

<! - Servlets - >

< servlet>
< servlet-name> OAuth< / servlet-name>
< servlet-class> org.goauth.server.OAuthServlet< / servlet-class>

< / servlet>
< servlet-mapping>
< servlet-name> OAuth< / servlet-name>
< url-pattern> / goauth / oauth< / url-pattern>
< / servlet-mapping>
< servlet>
< servlet-name> OAuthCallback< / servlet-name>

< servlet-class> org.goauth.server.OAuthCallbackServlet< / servlet-class>

< / servlet>
< servlet-mapping>
< servlet-name> OAuthCallback< / servlet-name>
< url-pattern> / goauth / callback< / url-pattern>
< / servlet-mapping>
< servlet>
< servlet-name>服务< / servlet-name>

< servlet-class> org.goauth.server.OAuthServiceImpl< / servlet-class>

< / servlet>
< servlet-mapping>
< servlet-name>服务< / servlet-name>
< url-pattern> / goauth / service< / url-pattern>
< / servlet-mapping>
< servlet>
< servlet-name> OAuthConfirm< / servlet-name>
< servlet-class> org.goauth.server.OAuthConfirmServlet< / servlet-class>

< / servlet>
< servlet-mapping>
< servlet-name> OAuthConfirm< / servlet-name>
< url-pattern> / goauth / confirm< / url-pattern>
< / servlet-mapping>
<! - 要投放的默认页面 - >
< welcome-file-list>
< welcome-file> GOAuth.html< / welcome-file>
< / welcome-file-list>
< / web-app>






错误



在tomcate日志文件中没有任何内容
浏览器中唯一的错误是:

  HTTP状态404  - / goauth / oauth 

类型状态报告

消息/ goauth / oauth

描述请求的资源(/ goauth / oauth)不可用。
Apache Tomcat / 6.0.20


解决方案

I发现问题:
用于调用我的servlet我调用了格式的url:/ goauth / OAuth
这与eclipse gwt插件在开发模式,但不是当我部署战争的Tomcat服务器。
解决方案是指向我的servlet的url应该是这样的形式:

  String href = GWT.getHostPageBaseURL ()+ goauth / OAuth的; 

所以我们需要通过在GWT.getHostPageBaseURL()前加上servlet url来告诉tomcat完整的url。


I searched this site for answer to this question and couldn't find a solution. what i did is that i simply compress the war directory in my eclipse GWT app project then rename it to .war then drop it to tomcat webapps folder. when i run the web app, the first screen is successfully shown but when i call a servlet within my src code it gives me resource not found by tomcat server. i'm sure i have added entry for servlet in web.xml file and the app worked well when i run it in eclipse gwt dev mode. something prevent my servlets (standard servlets not GWT RPC servlets) to be found and executed by tomcat. what could be the reason?


UPDATE

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <!-- Servlets -->

  <servlet>
        <servlet-name>OAuth</servlet-name>
        <servlet-class>org.goauth.server.OAuthServlet</servlet-class>

    </servlet>
    <servlet-mapping>
        <servlet-name>OAuth</servlet-name>
        <url-pattern>/goauth/oauth</url-pattern>
    </servlet-mapping>
     <servlet>
        <servlet-name>OAuthCallback</servlet-name>

        <servlet-class>org.goauth.server.OAuthCallbackServlet</servlet-class>

    </servlet>
    <servlet-mapping>
        <servlet-name>OAuthCallback</servlet-name>
        <url-pattern>/goauth/callback</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>service</servlet-name>

        <servlet-class>org.goauth.server.OAuthServiceImpl</servlet-class>

    </servlet>
    <servlet-mapping>
        <servlet-name>service</servlet-name>
        <url-pattern>/goauth/service</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>OAuthConfirm</servlet-name>
        <servlet-class>org.goauth.server.OAuthConfirmServlet</servlet-class>

    </servlet>
    <servlet-mapping>
        <servlet-name>OAuthConfirm</servlet-name>
        <url-pattern>/goauth/confirm</url-pattern>
    </servlet-mapping>
  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>GOAuth.html</welcome-file>
  </welcome-file-list>    
</web-app>


Error

nothing in tomcate logs files the only error in browser is :

HTTP Status 404 - /goauth/oauth

type Status report

message /goauth/oauth

description The requested resource (/goauth/oauth) is not available.
Apache Tomcat/6.0.20

解决方案

I found the problem : for invoking my servlet i was calling a url of the format : "/goauth/OAuth" this worked with eclipse gwt plugin in dev mode but not when i deploy war to tomcat server. the solution is that my url pointing to my servlet should be of the form :

String href = GWT.getHostPageBaseURL()+"goauth/OAuth";

so we need to tell tomcat the full url by prefixing servlet url with GWT.getHostPageBaseURL().

这篇关于如何将GWT应用程序部署到tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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