The problem of OpenStack Nova

145 views
Skip to first unread message

machi...@163.com

unread,
Dec 29, 2011, 8:52:50 PM12/29/11
to jclouds
Hi,
I use jcloud 1.3.0-rc-1 to operate my openstack nova.

I refer to the code of http://www.jclouds.org/documentation/quickstart/openstack.

The code cann't excute correctly. Below is my code:

import static
org.jclouds.openstack.nova.options.ListOptions.Builder.startAt;
import static
org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.openstack.nova.NovaClient;
import org.jclouds.openstack.nova.domain.Image;
import org.jclouds.openstack.nova.domain.Server;
import org.jclouds.openstack.nova.options.CreateServerOptions;
import org.jclouds.ssh.jsch.config.JschSshClientModule;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_ENDPOINT, "http://
xx.xx.xx.xx:8774/");
// get a context with nova that offers the portable ComputeService
api
ComputeServiceContext context=null;
Iterable<Module> modules = ImmutableSet.<Module> of(
new JschSshClientModule());
try{
context = new ComputeServiceContextFactory()
.createContext("nova", "xx", "xx", modules, overrides);
}catch(Exception ex){
System.out.print(ex);
}


In the code:
context = new ComputeServiceContextFactory()
.createContext("nova", "xx", "xx", modules, overrides);

appear the follow exceptions:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/
common/cache/LoadingCache
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at
com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:
81)
at
com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:
73)
at com.google.inject.spi.Elements
$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements
$RecordingBinder.install(Elements.java:232)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell
$Builder.build(InjectorShell.java:133)
at
com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:
103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at
org.jclouds.rest.RestContextBuilder.buildInjector(RestContextBuilder.java:
186)
at
org.jclouds.compute.ComputeServiceContextBuilder.buildInjector(ComputeServiceContextBuilder.java:
52)
at
org.jclouds.compute.ComputeServiceContextBuilder.buildComputeServiceContext(ComputeServiceContextBuilder.java:
65)
at
org.jclouds.compute.ComputeServiceContextFactory.buildContextUnwrappingExceptions(ComputeServiceContextFactory.java:
70)
at
org.jclouds.compute.ComputeServiceContextFactory.createContext(ComputeServiceContextFactory.java:
121)
at com.syncsort.NovaTest.main(NovaTest.java:39)
Caused by: java.lang.ClassNotFoundException:
com.google.common.cache.LoadingCache
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more


In my opinion, maybe I didn't import the right jar file, but I
cann't find out problems that take my two days.
Please help me find out where I was wrong.
Thank you very much.



Adrian Cole

unread,
Dec 30, 2011, 1:31:51 AM12/30/11
to jcl...@googlegroups.com

Looks like a classpath conflict.  Do you have a version of guava besides 11.0 in your classpath?

--
You received this message because you are subscribed to the Google Groups "jclouds" group.
To post to this group, send email to jcl...@googlegroups.com.
To unsubscribe from this group, send email to jclouds+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jclouds?hl=en.

machi...@163.com

unread,
Dec 30, 2011, 1:55:45 AM12/30/11
to jclouds

Thank you for your reply !

The jar of my classpath:

guava-10.0.1.jar
guice-3.0.jar
javax.inject.jar
aopaliance-alpha1.jar
jclouds-compute-1.3.0-rc-1.jar
jclouds-core-1.3.0-rc1.jar
jclouds-jsch-1.3.0-rc1.jar
jclouds-sshj-1.3.0-rc1.jar
nova-1.3.0-rc-1.jar
openstack-common-1.3.0-rc-1.jar

Can you help me find out where I was wrong?


On Dec 30, 2:31 pm, Adrian Cole <adrian.f.c...@gmail.com> wrote:
> Looks like a classpath conflict.  Do you have a version of guava besides
> 11.0 in your classpath?

machi...@163.com

unread,
Dec 30, 2011, 1:56:15 AM12/30/11
to jclouds

Thank you for your reply !

The jar of my classpath:

guava-10.0.1.jar
guice-3.0.jar
javax.inject.jar
aopaliance-alpha1.jar
jclouds-compute-1.3.0-rc-1.jar
jclouds-core-1.3.0-rc1.jar
jclouds-jsch-1.3.0-rc1.jar
jclouds-sshj-1.3.0-rc1.jar
nova-1.3.0-rc-1.jar
openstack-common-1.3.0-rc-1.jar

Can you help me find out where I was wrong?


On Dec 30, 2:31 pm, Adrian Cole <adrian.f.c...@gmail.com> wrote:
> Looks like a classpath conflict.  Do you have a version of guava besides
> 11.0 in your classpath?

machi...@163.com

unread,
Dec 30, 2011, 1:56:27 AM12/30/11
to jclouds

Thank you for your reply !

The jar of my classpath:

guava-10.0.1.jar
guice-3.0.jar
javax.inject.jar
aopaliance-alpha1.jar
jclouds-compute-1.3.0-rc-1.jar
jclouds-core-1.3.0-rc1.jar
jclouds-jsch-1.3.0-rc1.jar
jclouds-sshj-1.3.0-rc1.jar
nova-1.3.0-rc-1.jar
openstack-common-1.3.0-rc-1.jar

Can you help me find out where I was wrong?


On Dec 30, 2:31 pm, Adrian Cole <adrian.f.c...@gmail.com> wrote:
> Looks like a classpath conflict.  Do you have a version of guava besides
> 11.0 in your classpath?

Andrew Phillips

unread,
Dec 30, 2011, 6:06:34 AM12/30/11
to jcl...@googlegroups.com
Thanks for reporting this problem. It looks like you have run into
something related to

http://code.google.com/p/jclouds/issues/detail?id=781

which is about supporting a new Guava release that uses the
LoadingCache class (which you can't seem to find) instead of Cache.

Could you look at your project dependencies and see which version(s)
of com.google.guava:guava you have (the JAR will be called
'guava-...jar')?

Here's the output of me running 'mvn dependency:list' from
jclouds/apis/nova. Version 11 is what you are looking for...

[INFO] --- maven-dependency-plugin:2.1:list (default-cli) @ nova ---
[INFO]
[INFO] The following files have been resolved:
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] cglib:cglib-nodep:jar:2.1_3:test
[INFO] com.beust:jcommander:jar:1.12:test
[INFO] com.github.technomancy:swank-clojure:jar:1.2.1:test
[INFO] com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] com.google.code.gson:gson:jar:1.7.2:compile
[INFO] com.google.guava:guava:jar:11.0:compile
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
[INFO] org.yaml:snakeyaml:jar:1.6:test

Thanks!

ap

Andrew Phillips

unread,
Dec 30, 2011, 7:52:23 AM12/30/11
to jcl...@googlegroups.com
As we suspected: you have an old version of Guava (10.0.1). Good to
know we've found the cause at least! ;-)

> The jar of my classpath:
>
> guava-10.0.1.jar
> guice-3.0.jar
> javax.inject.jar
> aopaliance-alpha1.jar
> jclouds-compute-1.3.0-rc-1.jar
> jclouds-core-1.3.0-rc1.jar
> jclouds-jsch-1.3.0-rc1.jar
> jclouds-sshj-1.3.0-rc1.jar
> nova-1.3.0-rc-1.jar
> openstack-common-1.3.0-rc-1.jar
>
> Can you help me find out where I was wrong?

How did you set up your project? Are you using Maven, or did you
create a project in Eclipse, or..?

Thanks!

ap

Adrian Cole

unread,
Dec 30, 2011, 12:19:02 PM12/30/11
to jcl...@googlegroups.com

Like Andrew mentioned, would be great to know if there's a issue, but in case you may just be picking jars... http://search.maven.org/#artifactdetails%7Ccom.google.guava%7Cguava%7C11.0%7Cjar

On Dec 30, 2011 4:52 AM, "Andrew Phillips" <aphi...@qrmedia.com> wrote:

machi...@163.com

unread,
Dec 30, 2011, 9:51:24 PM12/30/11
to jclouds
Thanks for your response!

Yes, you are right.

I use guava11.0.jar, resolve the problem.

Thanks.




On Dec 31, 1:19 am, Adrian Cole <adrian.f.c...@gmail.com> wrote:
> Like Andrew mentioned, would be great to know if there's a issue, but in
> case you may just be picking jars...http://search.maven.org/#artifactdetails%7Ccom.google.guava%7Cguava%7...
> On Dec 30, 2011 4:52 AM, "Andrew Phillips" <aphill...@qrmedia.com> wrote:

machi...@163.com

unread,
Dec 30, 2011, 9:54:57 PM12/30/11
to jclouds


I create project in eclipse, and i didn't use Maven!

I encounter new question:
http://groups.google.com/group/jclouds/browse_thread/thread/fa524c9207319bc6
Reply all
Reply to author
Forward
0 new messages