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.
Related
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
at com.hibernate.sample.Test.main(Test.java:12)
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ReflectionManager
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)
... 1 more
I suggest that you use an IDE if you do not already, as the error indicates that the class file is missing, misplaced or cannot be found. Errors like this are generally human errors. I recommend the eclipse IDE for java.
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.
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
I am trying to make an applet for uploading files to openstack swift using jclouds.
And I am facing the NoClassDefFoundError, following is the stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
at org.nnsoft.guice.rocoto.configuration.ConfigurationModule.configure(ConfigurationModule.java:64)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:52)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:47)
at org.jclouds.config.BindPropertiesToExpandedValues.configure(BindPropertiesToExpandedValues.java:47)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
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 com.google.inject.Guice.createInjector(Guice.java:62)
at org.jclouds.ContextBuilder.expandProperties(ContextBuilder.java:385)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:320)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:620)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:600)
at com.cdac.appletclass.Test.main(Test.java:56)
Caused by: java.lang.ClassNotFoundException: com.google.inject.internal.util.$Preconditions
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)
... 21 more
I googled for com/google/inject/internal/util/$Preconditions, and came to know that it is part of guice-3.0.jar.
But guice-3.0.jar is already there in my project.
How to debug then? any help..???
I suggest printing out what's on your classpath from within your app (see this answer). That way you'll know exactly what classpath your app is using, if there's anything missing or any collisions.
Problem is solved now.
It was a mistake between guice 3.0 and guice-3.0.0, because both are having the same maven artifact-id but group-id was different.
Open the property of your project and add a dependency library.
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