jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aled Sage <aled.s...@gmail.com>
Subject Re: Error while running jclouds example code
Date Fri, 28 Feb 2014 09:23:19 GMT
Hi Avanti,

A java.lang.NoSuchMethodError usually means that you are running with a 
different version on the classpath compared to the one you compiled your 
code against (or a mix of jclouds versions, or that you've added to the 
classpath a different version of a jclouds upstream dependency from what 
jclouds was compiled against).

Could you check that please, and can you include your full exception 
stack trace so we can see which library/method it's complaining about.

Aled

p.s. If you're building with maven, also try `mvn dependency:tree` to 
see all the versions of all the dependencies that maven is pulling in. 
If something is pulled in twice with different version, that can cause 
such problems.


On 28/02/2014 07:29, Avanti Ajay wrote:
> Hi..
>
> I have installed jclouds and devstack and I am trying to run the 
> following code :
>
>
> import java.util.Set;
> import java.lang.Thread.UncaughtExceptionHandler;
>
> import org.jclouds.ContextBuilder;
> import org.jclouds.compute.ComputeService;
> import org.jclouds.compute.ComputeServiceContext;
> import org.jclouds.openstack.nova.v2_0.features.ImageApi;
> import org.jclouds.openstack.nova.v2_0.domain.Image;
> import org.jclouds.rest.RestContext;
> import org.jclouds.openstack.nova.v2_0.NovaApi;
> import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
> import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
>
> import com.google.common.collect.ImmutableSet;
> import com.google.common.collect.FluentIterable;
> import com.google.inject.Module;
>
> public class JCloudsOpenStack {
>   private ComputeService compute;
>   private RestContext<NovaApi, NovaAsyncApi> nova;
>   private Set<String> zones;
>
>   public static void main(String[] args) {
>     JCloudsOpenStack jCloudsOpenStack = new JCloudsOpenStack();
>     jCloudsOpenStack.init();
>     jCloudsOpenStack.listImages();
>     jCloudsOpenStack.close();
>   }
>
>   private void init() {
>     Thread.setDefaultUncaughtExceptionHandler(new 
> UncaughtExceptionHandler() {
>
>
>         public void uncaughtException(Thread t, Throwable e) {
>         if (compute != null) close();
>         e.printStackTrace();
>         System.exit(1);
>       }
>     });
>
>     Iterable<Module> modules = ImmutableSet.<Module> of(
>       new SLF4JLoggingModule());
>
>     String provider = "openstack-nova";
>     String identity = "admin:admin"; // tenantName:userName
>     String password = "ashwini";
>
>     ComputeServiceContext context = ContextBuilder.newBuilder(provider)
>       .credentials(identity, password)
>       .endpoint("http://172.16.32.87:5000/v2.0/")
>       .modules(modules)
>       .buildView(ComputeServiceContext.class);
>     compute = context.getComputeService();
>     nova = context.unwrap();
>     zones = nova.getApi().getConfiguredZones();
>   }
>
>   private void listImages() {
>     for (String zone: zones) {
>       ImageApi imageApi = nova.getApi().getImageApiForZone(zone);
>
>       System.out.println("Calling listImages for " + zone + ":");
>
>       FluentIterable<? extends Image> images = 
> imageApi.listInDetail().concat();
>
>       for (Image image: images) {
>         System.out.println("\t" + image);
>       }
>     }
>   }
>   private void close() {
>     compute.getContext().close();
>   }
> }
>
>
> But I am getting the following error : Exception: 
> java.lang.NoSuchMethodError thrown from the UncaughtExceptionHandler 
> in thread "main"
>
> Please help..
>
> Thank you
> Avanti


Mime
View raw message