Remote API JAVA url does not work GAE

2019-02-26 05:51发布

I have deployed application into GAE. When i try the url as http://aabbbaaacccc.appspot.com/_ah/remote_api. I am getting 404 Error page. I have added in web.xml file. I have given correct app id. It deploys. After deployment successful, An dialog box appears and displays file not found along with notepad.

<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>

I need to deploy my app into server and start a Remote api with an other application and share the entites from an other app.

I am struggling with this issue for past 2 days. Please help me.

U can look at the error dialog box in the following link.

http://i40.tinypic.com/bfgzki.png

Thanks.

1条回答
\"骚年 ilove
2楼-- · 2019-02-26 06:49

Appengine should works fine.. i've listed the all details for basic project setup. please look and find what you missed.

The Servlet Class

App Engine Java applications use the Java Servlet API to interact with the web server. In the directory src/guestbook/, make a file named GuestbookServlet.java with the following contents:

package guestbook;

import java.io.IOException;
import javax.servlet.http.*;

public class GuestbookServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        resp.setContentType("text/plain");
        resp.getWriter().println("Hello, world");
    }
}

The web.xml File

When the web server receives a request, it determines which servlet class to call using a configuration file known as the "web application deployment descriptor." This file is named web.xml, and resides in the war/WEB-INF/ directory in the WAR. WEB-INF/ and web.xml are part of the servlet specification.

In the directory war/WEB-INF/, a file named web.xml has the following contents:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC
 "-//Oracle Corporation//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
    <servlet>
        <servlet-name>guestbook</servlet-name>
        <servlet-class>guestbook.GuestbookServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>guestbook</servlet-name>
        <url-pattern>/guestbook</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

This web.xml file declares a servlet named guestbook, and maps it to the URL path /guestbook.

The appengine-web.xml File

App Engine needs one additional configuration file to figure out how to deploy and run the application. This file is named appengine-web.xml, and resides in WEB-INF/ alongside web.xml.

In the directory war/WEB-INF/, a file named appengine-web.xml has the following contents:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application></application>
    <version>1</version>
    <threadsafe>true</threadsafe>
</appengine-web-app>

appengine-web.xml is specific to App Engine, and is not part of the servlet standard. You can find XML schema files describing the format of this file in the SDK, in the appengine-java-sdk/docs/ directory. See Configuring an App for more information about this file.

Running the Project

The App Engine SDK includes a web server application you can use to test your application.

select Debug As > Web Application.

Testing the Application

Start the server, then visit the server's URL in your browser. If you're using Eclipse and the Google Eclipse plugin, the server runs using port 8888 by default:

http://localhost:8888/guestbook

If you're using the dev_appserver command to start the server, the default port is 8080: For details please see following tutorials:

Tutorial 1:

Tutorial 2:

Tutorial 3:

查看更多
登录 后发表回答