7

Here is my web.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <servlet>
    <servlet-name>Upload</servlet-name>
    <servlet-class>Upload</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>Upload</servlet-name>
    <url-pattern>/upload</url-pattern>
  </servlet-mapping>

    <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>com.company.game.GameApi</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
    </servlet-mapping>

</web-app>

I have a Google Cloud Endpoint api, GameApi, which had been working fine except for the loading of blobs which was taking too long. So I decide to use the Upload servlet on the google website to upload my blobs from user. I basically added the xml code for the blob file to my existing xml code for the endpoint api, resulting in the xml shown above. But then the Upload servlet is never called. I am testing on localhost and I can see in the _BlobUploadSession_ table that the front-end (i.e. android app) has successfully sent the image to the blobstore with the correct callback url. I know that the servlet is not being called because I have a println statement right at the entrance.

Do I need to change my web.xml? Am I allowed to combine endpoint with servlet as I am doing in my web.xml?

learner
  • 11,490
  • 26
  • 97
  • 169
  • @DanHolevoet do you or your team have any input on how to get this to work? My preferred approach would be to just use endpoints (http://stackoverflow.com/questions/16257895/convert-servlet-schema-to-app-engine-endpoint-schema), but since I don't know how to do that, I have created a servlet class as described. But my servlet is never called. – learner Apr 29 '13 at 19:37
  • @bossylobster may I please have some help with this one? – learner Apr 29 '13 at 19:39
  • tagging @dragonx : can you help with this? – learner Apr 30 '13 at 02:28
  • Sorry, missed this previous question (SO didn't seem to notify me of your comment). See my answer here: http://stackoverflow.com/a/16309150/498860 which pertains to the general case of using blobs with Endpoints. – Dan Holevoet Apr 30 '13 at 21:40

2 Answers2

1

Check out https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial

<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>
geekdenz
  • 759
  • 1
  • 5
  • 8
0

Although my Android Studio Cloud Endpoints gradle synced successfully, when uploading to GAE, the following format (which you are using) resulted in errors and unsuccessful upload:

<servlet>
    <servlet-name>Upload</servlet-name>
    <servlet-class>Upload</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>Upload</servlet-name>
    <url-pattern>/upload</url-pattern>
  </servlet-mapping>

What I needed to do was list out the full servlet-class path. In your case:

<servlet>
    <servlet-name>Upload</servlet-name>
    <servlet-class>com.company.game.Upload</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>Upload</servlet-name>
    <url-pattern>/upload</url-pattern>
  </servlet-mapping>

Hope this helps someone.

Micro
  • 10,303
  • 14
  • 82
  • 120