Hi
Your code depends on certain libraries both during compile time, but also
during runtime (in this case it's the ec2 libraries).
When you run your code, make sure that you have all the required jars in your
classpath.
If you use maven, you can do something similar to the config below. It will
copy all your dependant jar files into /lib, and add them to your classpath in
the jar manifest.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>---your-main-class------</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
(Y)
On Oct 5, 2014, at 7:54 PM, George Kousiouris <[email protected]> wrote:
>
> Hi all,
>
> I have successfully run a project inside Eclipse, using a piece of code from
> Jclouds:
> ComputeServiceContext context =
> ContextBuilder.newBuilder(provider)//"aws-ec2")
> .credentials(user, apiKey)
> //.modules(ImmutableSet.<Module> of(new Log4JLoggingModule(),
> // new SshjSshClientModule()))
> .buildView(ComputeServiceContext.class);
>
> ComputeService computeService = context.getComputeService();
> //System.out.println("After cs..");
>
> context.close();
>
>
> The code is running fine within Eclipse, getting the server list and the
> metadata associated to them. However, when i try to export a running jar
> file from Eclipse Juno, i get the following error from the command line
> execution:
> java.util.NoSuchElementException: key [aws-ec2] not in the list of providers
> or
> apis: {}
> at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:174)
>
> Seems to be a classpath issue? Any hints?
>
> Thanks,
> George
>
>
>
>
>
>
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>