Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:47:01+00:00 2026-06-12T19:47:01+00:00

I am using Gson library to convert objects to Json and vice versa. I

  • 0

I am using Gson library to convert objects to Json and vice versa. I have copied the jars of that library into a new folder lib and added it to the build path for the project in my Eclipse IDE.

I have one main class where I convert an object into Json using toJson() shown below and send it to a servlet using Apache HttpClient's HttpPost().

Gson gson= new Gson();
String json = gson.toJson(names);

But in the servlet I am not able to convert the Json into Object using fromJson() when I execute the following code.

Gson gson = new Gson();
Names names = gson.fromJson(s, Names.class);

It is throwing the following exception:

java.lang.NoClassDefFoundError: com/google/gson/Gson

Any idea why that could be happening? Should I have copied the jars into the WebContent/WEB-INF/lib folder instead of a new folder called lib?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:47:02+00:00Added an answer on June 12, 2026 at 7:47 pm

    Okay, I figured out the answer using this post. Please read the comments in the first answer.

    I am getting "java.lang.ClassNotFoundException: com.google.gson.Gson" error even though it is defined in my classpath

    I just had to place the external jars into my WebContent/WEB-INF/lib folder and Eclipse would take care of the build path itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert an object into JSON using the GSON library on
I'm using Google's GSON Library to convert JSON data to Java objects. The issue
Suppose I am using Google's Gson library to parse JSON into Java data structures.
I have some JSON that I am deserializing using Gson. { resp: { posts:
I'm using the Gson library in Java to serialize java objects to jSon and
Using the Gson library, how do I convert a JSON string to an ArrayList
I've recently started using GSON library for deserializing JSON that comes from web service
I am using GSON library. I have a programm which returns JSON. JSON constructs
I am using the Gson library to make Json objects. I made a serializer
I am using google gson-2.2.1 library for parsing large response of JSON. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.