0

I am working in Eclipse. I want to use JSON object in my servlets, so I attached jar file in library for JSON.

Now it shows all JSON classes in intellisense, but it giving run time exception

java.lang.NoClassDefFoundError: org/json/JSONArray

Can somebody suggest me how can I resolve this exception?

3
  • 1
    Sounds like the library isn't found at runtime. How did you add the library to the project and does this happen when running from Eclipse or after packaging the application and trying to run it? Commented Mar 19, 2011 at 10:52
  • 1
    I have added jar from build path of the project. I have added it in library....... Commented Mar 19, 2011 at 10:54
  • When you create your war-file for deployment, the library-jar should be found under WEB-INF/lib inside the war-file. I don't remember the correct settings, other than that the library should be in the build path, and maybe marked in Order and Export (Haven't built any web-applications without Maven for over three years). Commented Mar 19, 2011 at 11:14

1 Answer 1

3

Adding a jar to your build path in Eclipse isn't enough. The jar must be in the WEB-INF/lib directory for it to load at runtime, which if your project is set up as a Dynamic Web Project, automatically sets those jars on the build path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.