0
votes

I'm trying to follow Googles docs on migrating from File API (about to become obsolete) to Google Cloud Storage.

I'm following (using eclipse) https://cloud.google.com/appengine/docs/java/googlecloudstorageclient/migrate#migration (poorly written - out of many other poorly written docs)

I downloaded the client code from https://cloud.google.com/appengine/docs/java/googlecloudstorageclient/download with git and used ant to build it.

than I copied the following jars appengine-gcs-client.jar guava-15.0.jar joda-time-2.3.jar

I removed some old guava jar from my project.

copied PortOfFilesAPIGuestbookServlet to my project

add to web.xml

<servlet>
    <servlet-name>PortOfFilesAPIGuestbookServlet</servlet-name>
    <servlet-class>com.google.appengine.demos.PortOfFilesAPIGuestbookServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>PortOfFilesAPIGuestbookServlet</servlet-name>
    <url-pattern>/tst1</url-pattern>
</servlet-mapping>

and run the example

result:

Error for /tst1 java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.createUnstarted()Lcom/google/common/base/Stopwatch; at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156) at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:70) at com.google.appengine.demos.PortOfFilesAPIGuestbookServlet.doGet(PortOfFilesAPIGuestbookServlet.java:41) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

Please help me to solve it, or supply a link to a proper migration docs.

Thanks

1
Google Guava is up to version 18. Maybe the version 15 does not contains the required method - Deviling Master

1 Answers

0
votes

First, in eclipse, it's not enough to remove a jar from the Build path - you must delete it from the war/WEB-INF/lib.

otherwise it will still be used in run time (the build path is for compile time only)

in my case i had to delete the old guava jar from my lib.

After that I still had some missing stuff issues - I used http://grepcode.com/ to find the relevant jars.

I ended up removing google-collect-1.0-rc1.jar, guava-11.0.2.jar, servlet-api-2.3.jar from my lib

NOTE: In order for the code to work on the google server as well I had to copy all jars from appengine-gcs-client-read-only/java/dist to the project lib