ClassNotFoundException: org.json.JSONException - java

I get the below exception even after having json.jar and commons-collections.jar in classpath. It fails exactly at the import statement for JSONException
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:509)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 30 more

That looks like a runtime error, not a compile error, so the build path probably doesn't help you. Do you have those jars in your classpath? That's what's used at runtime to find classes.

Put your JAR libraries into the WEB-INF/lib folder.

Related

Javaagent throwing java.lang.NoClassDefFoundError: java/sql/PreparedStatement with java 15

Java agent is throwing this error when running with a java 15 app, if anybody can shed a light on why this might be coming, it will be very helpful.
java.lang.NoClassDefFoundError: java/sql/PreparedStatement
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3325)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2466)
.
.
.
.
.
Caused by: java.lang.ClassNotFoundException: java.sql.PreparedStatement
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 19 more
Class not found Exception happens when JVM Doesn't find the class files on the classpath. Either the auto deployment feature(auto-deployment="true") is erroneous or you don't have class file(sql jar) on the classpath. If you are using Maven, Just check if sql jar(prepared statement class file and sql jar file) is on the classpath. If class file not on classpath, Just add the class file manually on classpath. It should resolve the error.
It means java.sql.PreparedStatement is available at compile time but not available at Runtime.
To solve the issue add the sql jar to classpath, if you are using maven add dependency in pom.xml.

java.lang.NoClassDefFoundError after build Success in maven

Application Build got successful but getting the following error :
Exception in thread "Thread-29" java.lang.NoClassDefFoundError: org/apache/hadoop/util/ShutdownHookManager$2
at org.apache.hadoop.util.ShutdownHookManager.getShutdownHooksInOrder(ShutdownHookManager.java:124)
at org.apache.hadoop.util.ShutdownHookManager$1.run(ShutdownHookManager.java:52)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.ShutdownHookManager$2
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 2 more
I added this hadoop-common jar which has this class in pom file, classpath or any possible way i knew and could google but nothing worked.
It looks like a runtime problem. What I understand is that ClassRealm is trying to load a class at runtime and that class is not present in the jar. Just give it a look to the SelfFirstStrategy.java:50 and check if the class that is trying to be loaded actually exists.

Spring java.lang.NoClassDefFoundError

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");

How to solve com.intellij.uiDesigner.core.Spacer class not found exception in Eclipse java swing projects

I developed a Java Swing project in Intellij Idea, now have to convert that to Eclipse. I imported the project in Eclipse and then converted the form using 'Convert to JFormDesigner form'. While running the application getting the below mentioned exception.
Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.Spacer
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 31 more
I added forms_rt-6.0.5.jar and its dependencies to Lib, but still getting the same exception. Any idea how to solve this.. Thanks in Advance..
Issue got solved. Added that forms_rt.jar into the class path via manifest.mf file.

java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei

i am finding java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei.
i have already struts2-core-2.1.8.1.jar, struts2-json-plugin-2.1.8.1.jar on my classpath.
It appears you have some dependencies on struts-1. jarfinder finds this class only in struts-1 libs. Get rid of all struts-1 jars, and place only struts-2 jars in your classpath.

Categories

Resources