我正在开发 GWT 应用程序。该应用程序。正在开发模式下工作。
我正在开发一个 gwt 项目并尝试将其部署到 Apache Tomcat。我以前从未使用过 Apache Tomcat,而且我对 Java 和 GWT 还比较陌生。我的 tomcat 服务器似乎已启动并正在运行,因为我在 localhost:8080/上看到“如果你看到这个,你已经成功安装了 Tomcat”
启动并运行 Tomcat 后,我使用 Eclipse GWT Compile 来编译我的应用程序。我已经将我的 .html 文件和 .css 文件 + war 文件夹复制到 C:\apache-tomcat-8.0.15\webapps\MyAPP\
打开 .html 文件 (file:///C:/apache-tomcat-8.0.15/webapps/PurchaseOrder/PurchaseOrder.html) 给了我我的用户界面(登录屏幕),但是在进行第一次 RPC 调用时 (登录)我收到错误“FailureUnable to initiate the asynchronous service invocation (PurchaseOrderService_Proxy.checkUsernameAndPassword) -- check the network connection”
我的想法是我的 web.xml 或我的服务类有问题
PurchaseOrderService.java
package com.google.gwt.sample.purchaseorder.client;
import java.util.ArrayList;
import java.util.HashMap;
import com.google.gwt.sample.purchaseorder.client.model.Brands;
import com.google.gwt.sample.purchaseorder.client.model.Item;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("exampleservice")
public interface PurchaseOrderService extends RemoteService {
boolean checkUsernameAndPassword(String value, String value2);
ArrayList<Item> getPersonalInfo();
HashMap<String, ArrayList<Item>> getListOfPurchaseOrderSortedFromBrands();
String createExcelExportFile(HashMap<String, ArrayList<Item>> exportMap);
}
web.xml:
<!-- Servlets -->
<servlet>
<servlet-name>purchaseOrderServiceImpl</servlet-name>
<servlet-class>com.google.gwt.sample.purchaseorder.server.PurchaseOrderServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>purchaseOrderServiceImpl</servlet-name>
<url-pattern>/purchaseorder/exampleservice</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>PurchaseOrder.html</welcome-file>
</welcome-file-list>
</web-app>
最佳答案
Opening the .html file (file:///C:/apache-tomcat-8.0.15/webapps/PurchaseOrder/PurchaseOrder.html) gives me my ui (login screen), but when making the first RPC call (loggin in) I am getting the error "FailureUnable to initiate the asynchronous service invocation (PurchaseOrderService_Proxy.checkUsernameAndPassword) -- check the network connection"
这不是您访问在 Tomcat 中运行的应用程序的方式。你的 tomcat 正在运行 @ localhost:8080 所以你必须使用 http://localhost:8080/<app_context_root>/filename.html
访问
关于java - 尝试在 Apache Tomcat 上部署 GWT 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26899528/