如何使用 GWT - RPC 到 Tomcat 服务器 [英] How to use GWT - RPC to Tomcat server

查看:16
本文介绍了如何使用 GWT - RPC 到 Tomcat 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 已安装 Tomcat 6
  2. 已安装 Eclipse + GWT 插件
  3. 使用示例创建 GWT 项目生成的代码
  4. 已编译的 GWT 项目(GWT 编译)
  5. 复制的战争(编译)目录来自eclipse 的工作区到 TOMCATwebapps/ROOT 文件夹
  6. 在我的浏览器中运行 localhost:8080

来自 GWT 项目的 sample.html 页面显示正确,但是当我尝试进行服务器调用时发生错误.

The sample.html page from the GWT project displays correct but when i try to make a server call an error occurs.

  • 码头没问题(Eclipse GWT 开发模式)- rpc工作没问题
  • TOMCAT 的问题.

TOMCAT 上的 catalina.out 日志说:

The catalina.out log at TOMCAT says:

部署 Web 应用程序时出错目录 ROOTjava.lang.UnsupportedClassVersionError:.class 文件中的错误版本号(无法加载类com.tomcat.server.GreetingServiceImpl)

Error deploying web application directory ROOT java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.tomcat.server.GreetingServiceImpl)

我猜 servlet 定义的 WEB_INF/web.xml 可能有问题,这是我的 web.xml

I guess there might be a problem at WEB_INF/web.xml at servlet definition, here's my web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   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">

  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>

  <!-- Servlets -->
  <servlet>
    <servlet-name>greetServlet</servlet-name>
    <servlet-class>com.tomcat.server.GreetingServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
    <url-pattern>/tomcat/greet</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>Tomcat.html</welcome-file>
  </welcome-file-list>

</web-app>

推荐答案

当我部署到我的 Godaddy 托管服务器时,我遇到了同样的问题.它在我的本地机器上运行良好,但在我部署时却没有.我收到了完全相同的错误消息.问题是您使用 Java 版本编译代码,该版本比 Tomcat 使用的版本更新.

I had this same issue when I deployed to my Godaddy hosting server. It worked fine on my local machine but not when I deployed. I got the same exact error message. The problem is you compiled your code with a version of java that is newer then that of which Tomcat is using.

Install jdk1.5.0_22 (Or whatever your tomcat server is using)
Probably need to restart your machine
Eclipse->Window->Preferences->Java->Installed JRES->Add
Standard VM->Next
Browse to the directory of your jdk
Finish
Clean the project
Compile the project
Redeploy and cross your fingers!

这对我有用,如果它不适合你,那么......是的......它应该有效.祝你好运

This worked for me, if it doesn't for you then....ya...it should work. Good luck

这篇关于如何使用 GWT - RPC 到 Tomcat 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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