API URL上的Google Cloud Endpoints异常

时间:2022-08-22 11:16:02

I'm getting an StringIndexOutOfBoundsException when trying to access http://localhost:8080/_ah/api:

我在尝试访问http:// localhost:8080 / _ah / api时遇到StringIndexOutOfBoundsException:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0

java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:0

at java.lang.String.charAt(String.java:658) at com.google.api.server.spi.tools.devserver.DevApiUtil.stripLeadingSlash(DevApiUtil.java:17) at com.google.api.server.spi.tools.devserver.RestApiServlet.service(RestApiServlet.java:120) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:368) at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:351) at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:485) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

在java.lang.String.charAt(String.java:658)的com.google.api.toi.tool.devserver.DevApiUtil.stripLeadingSlash(DevApiUtil.java:17)com.google.api.server.spi .tools.devserver.RestApiServlet.service(RestApiServlet.java:120)在javax.servlet.http.HttpServlet.service(HttpServlet.java:717)在org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511 )在org.mortbay的com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)的org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1166)。 jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)在com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)在org.mortbay.jetty.servlet.ServletHandler $ CachedChain。 doFilter(ServletHandler.java:1157)位于org.mortbay.jetty.servlet.ServletHandler的com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)$ CachedCh ain.doFilter(ServletHandler.java:1157)在com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler。 Java的:1157)在com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)在com.google .appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)在com.google.appengine.tools.development.DevAppServerModulesFilter .doDirectRequest(DevAppServerModulesFilter.java:368)位于com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:351)的com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116) )在org.mortbay.jetty.servlet.Servle tHandler $ CachedChain.doFilter(ServletHandler.java:1157)atg.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) org.mortbay.jetty.servle.SessionHandler.handle(SessionHandler.java:182)org.mortbay.jetty.handle.ContextHandler.handle(ContextHandler.java:765)org.mortbay.jetty.webapp.WebAppContext.handle (WebAppContext.java:418)com的com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)位于com的org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)。 google.appengine.tools.development.JettyContainerService $ ApiProxyHandler.handle(JettyContainerService.java:485)org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)org.mortbay.jetty.Server.handle( Server.java:326)org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)org.mortbay.jetty.HttpConnection $ RequestHandler.heade rComplete(HttpConnection.java:923)在org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)在org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)在org.mortbay.jetty.HttpConnection .handle(HttpConnection.java:404)org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:582)

I'm trying to use Endpoints, so I created an Entity as follows:

我正在尝试使用端点,所以我创建了一个实体,如下所示:

@Entity
@Table(name="Users")
@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    private String password;

    private String username;

    public User() {
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

}

}

Then, I right clicked on the class Google appEngine WTP --> generate Cloud Endpoint Class....

然后,我右键点击Google appEngine WTP类 - >生成Cloud Endpoint Class ....

I'm following the getting started tutorial https://developers.google.com/eclipse/docs/endpoints-js

我正在按照入门教程https://developers.google.com/eclipse/docs/endpoints-js

My Index.html is as follows:

我的Index.html如下:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Hello App Engine</title>
    <script src="https://apis.google.com/js/client.js?onload=init">
    </script>
  </head>
  <body>
    <h1>Hello App Engine!</h1>
      <script>
        function init(){
         var ROOT = 'http://localhost:8080/_ah/api';
            gapi.client.load('libuserendpoint', 'v1', function() {
              alert("hello");
            }, ROOT);
        }
    </script>
  </body>
</html>

2 个解决方案

#1


1  

The correct URL for Google APIs Explorer in your local environment is localhost:8080/_ah/api/explorer

本地环境中Google API Explorer的正确URL是localhost:8080 / _ah / api / explorer

#2


0  

I'm guessing you may need a slash to start the URL, so maybe the URL needs to look like:

我猜你可能需要一个斜杠来启动URL,所以URL可能需要如下所示:

_ah/api

Instead of:

代替:

http://localhost:8080/_ah/api

I saw the following question which made me think of this:

我看到以下问题让我想起了这个问题:

google cloud enpoint callback after update

更新后google cloud enpoint回调

#1


1  

The correct URL for Google APIs Explorer in your local environment is localhost:8080/_ah/api/explorer

本地环境中Google API Explorer的正确URL是localhost:8080 / _ah / api / explorer

#2


0  

I'm guessing you may need a slash to start the URL, so maybe the URL needs to look like:

我猜你可能需要一个斜杠来启动URL,所以URL可能需要如下所示:

_ah/api

Instead of:

代替:

http://localhost:8080/_ah/api

I saw the following question which made me think of this:

我看到以下问题让我想起了这个问题:

google cloud enpoint callback after update

更新后google cloud enpoint回调