API URL上的Google Cloud Endpoints异常

时间:2013-10-28 14:37:59

标签: java google-app-engine google-cloud-endpoints

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

  

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

     
    

at java.lang.String.charAt(String.java:658)         在com.google.api.server.spi.tools.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.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1166)         在com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)         在org.mortbay.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)         在com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)         在org.mortbay.jetty.servlet.ServletHandler $ CachedChain.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.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1157)         在org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)         在org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)         在org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)         在org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)         在org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)         在com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)         在org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)         在com.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)         at org.mortbay.jetty.HttpConnection $ RequestHandler.headerComplete(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)

  

我正在尝试使用端点,因此我按如下方式创建了Entity

@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;
    }

}

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

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

我的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 个答案:

答案 0 :(得分:1)

本地环境中Google API资源管理器的正确网址是localhost:8080 / _ah / api / explorer

答案 1 :(得分:0)

我猜你可能需要一个斜杠来启动URL,所以URL可能需要看起来像:

_ah/api

而不是:

http://localhost:8080/_ah/api

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

google cloud enpoint callback after update