3

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
Narayana Nagireddi
  • 729
  • 1
  • 13
  • 33

2 Answers2

2

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.

Herms
  • 37,540
  • 12
  • 78
  • 101
  • 2
    This question helped me http://stackoverflow.com/questions/15956156/websphere-classnotfoundexception-with-deployed-dynamic-web-project?rq=1 – Narayana Nagireddi Sep 24 '13 at 22:30
  • I had to add the jar to web module's classpath, i.e, WEB-INF/lib. I did this by selecting the jar from Web Libraries in Java EE Module dependencies, and so it overrides the MANIFEST classpath which is not cooperative with json – Narayana Nagireddi Sep 24 '13 at 22:33
1

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

szedjani
  • 550
  • 2
  • 6
  • 21