NoClassDefFoundError and ClassNotFoundException - java

I am using Eclipse and I have configured all the jars required for Spring Framework, it don't show any compilation error. But, when I run my main function(Test Class) it populates me this error. Am I missing something here? Please help me, could not find the actual solution to solve this problem.
Feb 27, 2017 1:15:20 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/expression/PropertyAccessor
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:481)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:398)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.javatpoint.Test.main(Test.java:14)
Caused by: java.lang.ClassNotFoundException: org.springframework.expression.PropertyAccessor
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more

Some dependencies are not required at compile time but just at runtime.
The missing class is contained in the spring-expression jar. You can download it and add it to Eclipse too.

Related

ClassNotFoundException: org.infinispan.remoting.transport.jgroups.JGroupsTransport

this issue drives me crazy
recently i configured hibernate to work with infinispan 8.1
and just worked fine in debug mode with eclipse
the problem when tried to deploy my application war on apache tomcat6
i get this exception
Caused by: org.hibernate.cache.CacheException: Unable to start region factory
at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:415)
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:49)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:46)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
... 86 more
Caused by: org.infinispan.commons.CacheConfigurationException: Unable to instantiate class org.infinispan.remoting.transport.jgroups.JGroupsTransport
at org.infinispan.commons.util.Util.loadClass(Util.java:103)
at org.infinispan.commons.util.Util.getInstance(Util.java:258)
at org.infinispan.configuration.global.TransportConfigurationBuilder.defaultTransport(TransportConfigurationBuilder.java:207)
at org.infinispan.configuration.parsing.Parser72.parseJGroups(Parser72.java:405)
at org.infinispan.configuration.parsing.Parser72.readElement(Parser72.java:93)
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:151)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:131)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:118)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:105)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.parseWithOverridenClassLoader(InfinispanRegionFactory.java:518)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.access$000(InfinispanRegionFactory.java:81)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:484)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:470)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.workWithClassLoader(ClassLoaderServiceImpl.java:342)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:469)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:380)
... 91 more
Caused by: java.lang.ClassNotFoundException: org.infinispan.remoting.transport.jgroups.JGroupsTransport
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.infinispan.commons.util.Util.loadClassStrict(Util.java:158)
at org.infinispan.commons.util.Util.loadClass(Util.java:101)
... 106 more
This exception clearly shows that jar is not present on class path. For web project see if that jar is present inside lib folder of your war.

Missing slf4j in tess4j

I want to test tess4j to do OCR. I used the following tutorial for a first example: http://tess4j.sourceforge.net/codesample.html
I included the required libraries, but I am getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at net.sourceforge.tess4j.Tesseract.<clinit>(Unknown Source)
at tess4jexample.TesseractExample.main(TesseractExample.java:10)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Does anyone knows a solution for this?
Tess4J has several dependencies. You'll need to include them in the classpath.
There has where still some dependencies missing, which have not been mentioned on the mavenrepository:
logback-core-1.1.6.jar
slf4j-api-1.7.21.jar
I think now it is working :-) Thank you nguyenq for this hint, to check the dependencies.

Exception in thread "main" java.lang.ExceptionInInitializerError caused by java.lang.RuntimeException: Unable to instance KieServices

I am trying to get started with Drools 6x, and in eclipse, I have created a Drools project, which creates the boilerplate code to run a simple drl.
I have the drools runtime installed via Eclipse.
I have drools libraries, drools-core-5.0.1.jar,kie-api-6.0.0.beta4.jar,kie-internal-6.0.0.beta2.jar as External jars in my project.
Yet, when I try to run the following, I get the following error:
java.lang.ExceptionInInitializerError
at com.sample.PetStoreExample.init(PetStoreExample.java:78)
at com.sample.PetStoreExample.main(PetStoreExample.java:67) Caused by: java.lang.RuntimeException: Unable to instance KieServices
at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:137)
... 1 more Caused by: java.lang.ClassNotFoundException:org.drools.compiler.kie.builder.impl.KieServicesImpl at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:165)
... 1 more
If you downloaded the zip of Jars from http://www.drools.org/, you're going to want to include every jar from /binaries in your project. Even the ones that seem like you won't use.
I had this same problem too because I assumed I only needed to use a few Jars, but it turns out they all depend on classes from the other jars in that zip folder.
I had this problem because I had both kie-api and kie-ci as dependencies in my pom file. I removed the kie-ci dependency and I'm not getting this issue any more.

Getting the c3p0 "ClassNotFound" Exception on MCServer start

iam trying to use MySQL Connection Pooling using c3p0.
I want to use c3p0 for a bukkit plugin.
The MANIFEST.MF looks as follow and is placed at Pooling.jar/META-INF/MANIFEST.MF
Manifest-Version: 1.0
class-path: ./Pooling/lib/c3p0.jar ./Pooling/lib/mchange.jar
I've placed the 2 files at
plugins/Pooling/lib/
However, it keeps printing this error:
2013-09-13 16:35:19 [SEVERE] Error occurred while enabling Pooling
v1.0.0 (Is it up to date?) java.lang.NoClassDefFoundError:
com/mchange/v2/c3p0/ComboPooledDataSource at
com.frostforce.Pooling.Database.setup(Database.java:11) at
com.frostforce.Pooling.Main.onEnable(Main.java:16) at
org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) at
org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
at
org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
at
org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:282)
at
org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:264)
at
net.minecraft.server.v1_6_R2.MinecraftServer.l(MinecraftServer.java:313)
at
net.minecraft.server.v1_6_R2.MinecraftServer.f(MinecraftServer.java:290)
at
net.minecraft.server.v1_6_R2.MinecraftServer.a(MinecraftServer.java:250)
at
net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:151)
at
net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:391)
at
net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
Caused by: java.lang.ClassNotFoundException:
com.mchange.v2.c3p0.ComboPooledDataSource at
java.net.URLClassLoader$1.run(Unknown Source) at
java.net.URLClassLoader$1.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(Unknown Source) at
org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
at
org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
at java.lang.ClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) ... 13 more
I have no idea at all what Iam doing wrong at the moment.
Thanks in advance!

org.hibernate.HibernateException error

I'm getting this error continuously...Eclips IDE with appach tomcat
root cause
java.lang.ClassNotFoundException: org.hibernate.HibernateException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
com.rmi.servlet.ProvinceServlet.doPost(ProvinceServlet.java:59)
javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
You need to add Hibernate dependency to your project.
Basically, you need to add one of these jars:
http://www.jarfinder.com/index.php/java/info/org.hibernate.HibernateException
Here is how to do it from Eclipse:
http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)

Categories

Resources