0

So I am trying to download files on a rackspace server to my local server. It is laid out here. For some odd reason, I am trying to make the initial call to the cloud and it is giving me some serious feedback. No idea where to go from here. I've tried all sorts of different Maven dependencies to fix the problem, but none have come close. Am I overlooking something? TIA!

My code:

public static void main (String[] args){

    CloudFilesApi cloudFilesApi = ContextBuilder.newBuilder(PROVIDER)
            .credentials(USERNAME, KEY)
            .buildApi(CloudFilesApi.class);


}

And here are my errors (without Guice):

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/Stage
at org.jclouds.ContextBuilder.<clinit>(ContextBuilder.java:151)
at com.unidev.download.Main.main(Main.java:10)
Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more

Here are my dependencies (now):

<dependencies>
<!-- Rackspace US dependencies -->
<dependency>
  <groupId>org.apache.jclouds.provider</groupId>
  <artifactId>rackspace-cloudfiles-us</artifactId>
  <version>${jclouds.version}</version>
</dependency>

Code snippet for dependency tree(updated): https://codeshare.io/bfbKg

drawnitsud
  • 55
  • 11
  • This looks like a classpath problem. Your application is missing the Guice dependency, required by jclouds. Can you please share which jars do you have in your application's classpath? – Ignasi Barrera Jul 13 '16 at 14:35
  • Edited to show my pom dependencies... Or do you want me to copy all of the jars straight from my build path (there are a lot)? – drawnitsud Jul 13 '16 at 14:41
  • Ok, so off of your comment (and others you have answered on the net... you rock...) I added the `Google Guice Core Library » 4.1.0` but now it throws other errors `Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions` `Caused by: java.lang.ClassNotFoundException: com.google.inject.internal.util.$Preconditions` – drawnitsud Jul 13 '16 at 14:44
  • There is a mix of dependencies in the project: org.jclouds and org.apache.jclouds, and that could be an issue of duplicated classes, etc. Also, what is the value of the `jclouds.version` property? To get the exact picture of dependencies being used by your app, could you also include the output of the `mvn dependency:tree` command run in your app's folder? – Ignasi Barrera Jul 13 '16 at 14:44
  • ok, edited to add dependency tree... jclouds version is 1.9.2... Thank you for your help! – drawnitsud Jul 13 '16 at 14:53
  • The problem is that you are mixing jclouds 1.9.2 and 1.6.0 dependencies. You should remove all 1.6.0 dependencies from your pom.xml (you can also remove the jclouds-all if you just want to use Rackspace and leave just the rackspace-cloudfiles-us one. That should already bring the dependencies it needs as transitive dependencies. – Ignasi Barrera Jul 13 '16 at 14:57
  • @IgnasiBarrera Ok, so I was still getting errors, so I scrapped the small project (just trying to connect at this point) and it still is giving me problems. It is a clean build and I updated everything in my original comments. Any ideas? – drawnitsud Jul 13 '16 at 15:55
  • Dependencies look good, and Guice 3.0 is there. How are you running the app? Can you check that the classpath is properly set when running it? – Ignasi Barrera Jul 13 '16 at 16:08
  • I am running it through eclipse neon and another person was able to run it cleanly on his device. His jclouds version was 1.9.1 but when I try and change it, it says `The type org.jclouds.openstack.swift.v1.SwiftApi cannot be resolved. It is indirectly referenced from required .class files` not sure if that gives any clue... but I've tried changing java versions (1.8 to 1.7, etc) and nothing is working. I even tried a clean install of eclipse... hmm – drawnitsud Jul 13 '16 at 16:59
  • Try build your app with Java 7 and do a clean build every time you change the versions – Ignasi Barrera Jul 13 '16 at 17:13
  • You can also configure the pom.xml to create an executable jar and test running it, just to make sure it is an IDE specific issue. – Ignasi Barrera Jul 13 '16 at 17:24
  • @IgnasiBarrera same code with jre7... not sure how to make an executable jar... At a loss here, unfortunately. Everything I am doing says either `type org.jclouds.openstack.swift.v1.SwiftApi cannot be resolved` when the jcloud.version is 1.9.1 or `Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage` when the version is 1.9.2 – drawnitsud Jul 13 '16 at 19:00
  • The SwiftApi was refactored in 1.9.2. In 1.9.1 you should use: https://github.com/jclouds/jclouds/blob/jclouds-1.9.1/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftClient.java – Ignasi Barrera Jul 13 '16 at 19:14
  • Ok, so if I simply want to build a maven project that uses `CloudFilesApi cloudFilesApi = ContextBuilder.newBuilder("rackspace-cloudfiles-us") .credentials("{username}", "{apiKey}") .buildApi(CloudFilesApi.class);` what dependencies would I use? – drawnitsud Jul 13 '16 at 19:24
  • SOOO, I guess it is a Maven issue... When I was building the Maven project and using the dependencies via the pom file, it was somehow building incorrectly. Instead, I started a Java file and built a lib folder, pulled all the jars I needed and then just tied them in via the build path... and it is working well, now... – drawnitsud Jul 13 '16 at 19:44
  • Thank you @IgnasiBarrera for all your help! – drawnitsud Jul 13 '16 at 19:45
  • Eclipse comes with an embedded Maven. Have you tried configuring it to use the system one? Glad to see it is working! – Ignasi Barrera Jul 13 '16 at 19:47
  • I have not, how would I go about that as it sounds like it could save me some trouble in the future? – drawnitsud Jul 13 '16 at 19:54
  • n/m a simple search showed me how :) thanks! http://stackoverflow.com/questions/16127739/using-maven-outside-of-eclipse – drawnitsud Jul 13 '16 at 19:56

1 Answers1

0

I guess it is a Maven issue... When I was building the Maven project and using the dependencies via the pom file, it was somehow building incorrectly. Instead, I started a Java file and built a lib folder, pulled all the jars I needed and then just tied them in via the build path... and it is working well now...

drawnitsud
  • 55
  • 11