I am trying to add all the jar files in the directory below but I get
Exception in thread "main" java.lang.NoClassDefFoundError: twitter4j/TwitterException error.
I am sure there is TwitterException class inside the .jar file. Is there any error in my classpath syntax ?
mahmut#ubuntu:~/Desktop/Java/TwitterDeneme/bin$ java -classpath "~/twitter4j-2.2.6/lib/*.jar:." GetHashtag
Exception in thread "main" java.lang.NoClassDefFoundError: twitter4j/TwitterException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Caused by: java.lang.ClassNotFoundException: twitter4j.TwitterException
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)
... 6 more
I am using ubuntu and jdk 1.7. I tried the same command in windows and it works flawlessly. Is there anything special to do related to Ubuntu OS?
The * syntax for classpaths is rather limited. Try:
java -classpath "~/twitter4j-2.2.6/lib/*:." GetHashtag
Related
I built Oozie and was creating share lib in hdfs but it is giving the following error.
I followed all the steps but this is the only one that went wrong.
setting CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/filefilter/IOFileFilter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.filefilter.IOFileFilter
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)
... 6 more
thank you for the help.
copy hadoop libs in extlib directory and prepare war then try it.
cp $HADOOP_HOME/share/hadoop/*/hadoop-*.jar./libext/
cp $HADOOP_HOME /share/hadoop/*/lib/*.jar./libext/
cp mysql-connector-java-5.1.29-bin.jarlibext/
bin/oozie-setup.sh prepare-war
run this after copy and prepare.
./bin/oozie-setup.sh sharelib create -fs hdfs://IP(HOSTNAME):9000
I am getting the following error running a hadoop jar file
Exception in thread "main" java.lang.ClassNotFoundException: hdfs:
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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.util.RunJar.main(RunJar.java:205)
The jar file that you want to run must be the actual path in your OS.
Add the hdfs jar file in your build path or pom.xml file
I have a simple java file packaged as a Jar on a server called by a PHP script. I have the "json-simple-1.1.1" library included in my java program. However, when I run it gives me the below error. I've added the json-simple jar to my project and import the correct classes. From what I've read it doesn't seem to be adding the json-simple library to my manifest file. Any ideas on how to fix this. I'm using eclipse if that helps.
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
at java.lang.Class.getMethod0(Class.java:2813)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
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)
Your library is probably not been loaded by classloader, so, if it is not in WEB-INF/lib, right click it and Add to build Path.
When I tried to build my first hibernate application the following error occurs NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/standard/StandardAnalyzer
at org.hibernate.search.impl.ConfigContext.initAnalyzer(ConfigContext.java:168)
at org.hibernate.search.impl.ConfigContext.<init>(ConfigContext.java:104)
at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:312)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:218)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:143)
at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:74)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:52)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:587)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at com.TestHibrnt.main(TestHibrnt.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.standard.StandardAnalyzer
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)
... 11 more
Required jar containing org/apache/lucene/analysis/standard/StandardAnalyzer is missing so you have to download jar(lucene-1.2.jar) and then set your classpath
I had the same problem today. When I check the error, I found org.hibernate.search on several lines, even though I'm just using the Hibernate ORM. Then I removed the build path of Hibernate Search and no more error. Check if you have the same path and if you don't need it, just remove it.
I am following this tutorial:
https://code.google.com/p/quickserver/wiki/QuickStartTutor
but when I execute java -jar QuickServer.jar -load HelloWorld.xml
I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/PoolableObjectFactory at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2531) at
java.lang.Class.getMethod0(Class.java:2774) at
java.lang.Class.getMethod(Class.java:1663) at
sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at
sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.pool.PoolableObjectFactory 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) ... 6 more
How can I solve that?
The exception exactly says your problem: that class cannot be found on the application classpath, hence the ClassNotFoundException.
You need to put all the dependent jars onto the application classpath. In this exact exception, the commons-pool.jar Apache library is missing.
The developers guide states, that the Digester and Pool Jakarta Commons Components are dependencies of QuickServer.
It sounds like you are executing this from a folder that does not also have the supporting jars. Ie, the following files must be in the same folder as QuickServer.jar as well:
commons-digester.jar
commons-collections.jar
commons-beanutils.jar
commons-logging.jar
commons-pool.jar