2

I only beginning to learn, how to use java with Goole App Engine Standard. I use Eclipse 4.6.3 for that. I created web project and coded some junk, then I decided to try list files at Google Cloud Storage. Here is my code:

public static ArrayList<String> getFilesInBucket(String bucket_name) { /*Line 235*/GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance()); ListResult result = null; try { result = gcsService.list(bucket_name, ListOptions.DEFAULT); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ArrayList<String> files = new ArrayList<String>(); while (result.hasNext()) { ListItem l = result.next(); if (!l.isDirectory()) files.add(l.getName()); } return files; } 

This junk works locally, but after I deploy this it stops. I see errors in Google Console:

java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer at MyJunk.getFilesInBucket (ADServlet.java:235) 

Every jar that is added to lib directory in src is also added into web-inf/lib. enter image description here

I also added this jars here: enter image description here

I even opened problems tab and quick fixed every "Eclipse warning: XXXXXXXXXXX.jar will not be exported or published." junk by this: enter image description here

(This is not my screen).

And yet my code fails at runtime on GAE Standard... What else I can do to solve this?

1 Answer 1

2

The Google Cloud libraries have a lot of dependencies. Rather than try to chase them down by hand, let your machine do it for you. Two suggestions:

  1. Use the Google Cloud Tools for Eclipse. Use Properties > Configure > Convert to App Engine Standard Project, and then Properties > Java Build Path > Libraries and select Add Library… > Google API Libraries and select Google Cloud Storage.
  2. Convert your project to Maven or Gradle and then add the documented dependencies.
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Me helped Properties > Java Build Path > Libraries and select Add Library… > Google API Libraries and select Google Cloud Storage this step.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.