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
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...
Related
I'm using a library to make Wikipedia API calls, called the Java Wiki Bot Framework. I'm also using Maven for builds, and I've added the framework to the pom.xml just as the github page says. However, when I try to instantiate any of the classes in the library, it gives me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jwbf/core/actions/HttpActionClient
at com.FactFinder.WikiParser.makeBot(WikiParser.java:21)
at com.FactFinder.WikiParser.<init>(WikiParser.java:16)
at com.FactFinder.App.main(App.java:15)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.jwbf.core.actions.HttpActionClient
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)
... 3 more
My pom.xml
Apparently this is an error that crops up when your jar can't find a class, but I've checked the classpath, and it looks fine. The jar is included in the proper folder, and I've verified that it includes the classes I tried to use. I considered contacting the library author, but I figured its probably more my problem than his.
Why are you using the Snapshot version 4.0.0-SNAPSHOT? I would strongly suggest to use a final version to avoid issues, of which 3.1.0 seems to be the latest and most popular one:
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>jwbf</artifactId>
<version>3.1.0</version>
</dependency>
[UPDATE]
Follow naming conventions; package name: com.factfinder (all lowercase). Fix in both your code, pom, and directory names.
Add the version for the maven-jar-plugin
Note that I tried using your pom - it seemed to work for me ...
Are you sure you don't get any other warnings or errors during your maven build? can you do a clean package?
Check line 53 of your POM:
<classpathPrefix>lib\</classpathPrefix>
Should be:
<classpathPrefix>lib/</classpathPrefix>
I'm trying to use Bliki to access and parse wiki pages.
I just downloaded the zip file and put the bliki-core-3.0.19.jar into my eclipse build path.
However, when I tried to connect using sample code. there was an error.
The sample code is here:
public static void test(){
String pageName = "File:Mona Lisa.jpg";
User user = new User("", "", "http://en.wikipedia.org/w/api.php");
Connector con = new Connector();
user = con.login(user);
List<Page> pages = user.queryImageinfo(new String[]{pageName});
if(pages != null)
System.out.println(pages.size());
}
And I got errors as:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
at info.bliki.api.User.<init>(User.java:98)
at info.bliki.api.User.<init>(User.java:71)
at main.wiki.WikiCall.test(WikiCall.java:23)
at main.wiki.WikiCall.main(WikiCall.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
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)
... 4 more
It seems like I'm missing the http jar for the connection, but there's no one the zip file and i thought the bliki-core.jar should contain it.
Any suggestions?
I'm not familiar with Bliki but from your stacktrace it looks like you are missing the Http Client from Apache Commons.
You should add the jar to your project and that should solve the problem.
Get the jar from here: http://hc.apache.org/
This issue is that even once you have added HttpClient you will likely get other errors as the Bliki library depends on a number of 3rd party libraries.
If you are not familiar with the Maven build tool it may be worth having a look as one feature is that it will transitively resolve dependencies.
As a quick start:
In Eclipse do:
File > New > Other > Maven Project
Select the 'Create Simple Project' checkbox.
Enter my.bliki.project as the group id and bliki-test as the Artifact id.
Replace the contents of the generated pom.xml with the below.
Right click on the project and select 'Maven > Update project.
You now have a project with Bliki and all 3rd p;arty dependencies on the buildpath (expand the Maven Dependencies folder to see what they are).
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.bliki.project</groupId>
<artifactId>bliki-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>info.bliki.wiki</groupId>
<artifactId>bliki-core</artifactId>
<version>3.0.19</version>
</dependency>
</dependencies>
</project>
I'm totally a newbie in springs so I wanted to try a helloworld program in springs. I came across this tutorial.
I downloaded the source code with library provided on this site, I have the latest Spring STS installed on my Eclipse Kepler. I got this error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.(AbstractApplicationContext.java:153)
at org.springframework.context.support.AbstractApplicationContext.(AbstractApplicationContext.java:217)
at org.springframework.context.support.AbstractRefreshableApplicationContext.(AbstractRefreshableApplicationContext.java:88)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.(AbstractRefreshableConfigApplicationContext.java:58)
at org.springframework.context.support.AbstractXmlApplicationContext.(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.vaannila.HelloWorldApp.main(HelloWorldApp.java:9)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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)
... 8 more
I also tried manually doing the entire program with a different class name and It throws the same error.
Things I have tried:
built path and included the springframework jars
also included commons-logging-1.1.1.jar
I got past this exception by adding commons-logging-1.1.1.jar to the classpath of my project. I had it in my maven repository from other projects.
Plus, to make the example work, the file name for the instantiation of ClassPathXmlApplicationContext needs to be qualified with the package path. If you are following the example exactly, you need to instantiate your context like this:
ApplicationContext context = new ClassPathXmlApplicationContext("com/vaannila/beans.xml");
Imagine I have a following project structure of folders
A
B
C
and many external jars.
Now I am trying to build two different executable-jars like this A+B, A+C.
At first, I do Eclipse -> Export -> Executable Jar and save script for Ant. So it generates Ant-script and jar-in-jar-loader. Now I modify ant script to exclude folder B
<fileset dir="C:/Users/Nikolay/bin">
<exclude name="org/B"/>
</fileset>
and keep jar-in-jar-loader.zip file unmodified.
After building the jar running gives this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/B
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)
Caused by: java.lang.ClassNotFoundException: org.B
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:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 3 more
But I am sure B class is not used in the A.
It seems like JarRscrLoader tries to load all listed classes at application startup. How can I prevent that?
Please, don't suggest me to split the code at Eclipse into 2-3 projects.
Create two different Run configurations (Run --> Run configurations...) and modify the included libraries in the classpath tab according to your requirements.
When you export the project, just select the appropriate configuration.
I got "java.lang.NoClassDefFoundError" Exception when I want to use a certain jar file.
Exception in thread "main" java.lang.NoClassDefFoundError: .
org/apache/http/client/ClientProtocolException
at ?uk.org.taverna.server.client.connection.ConnectionFactory.getConnection(ConnectionFactory.java:63)
at uk.org.taverna.server.client.Server.<init>(Server.java:99)
at uk.org.taverna.server.client.Server.<init>(Server.java:126)
at uk.org.taverna.server.client.Server.connect(Server.java:293)
at uk.org.taverna.server.usage.ServerUsage.Usage(ServerUsage.java:24)
at Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
I import this jar file to jar library, when I call the method in that jar file I got this Exception. By the way, This jar file be wrote by myself, and I can run it correctly.
I have no idea how to solve this problem, I am quite new in java.
Thanks in advance.
Sandy
You need also at least HttpClient jar-library. You can get it at Apache Commons web-site.
Jar libraries may and often refer to another jar libraries. In your case library you are using refers to HttpClient library from Apache Commons framework. You need to add this library to your project.
You should but all the jar files you use in you application in the libs folder in your application directory .
so if you use the apachecommons jar file copy and paste the jar file to the libs folder in your application .