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 7859473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:55:00+00:00 2026-06-02T21:55:00+00:00

This is my Servlet code which i am using to query a solr index

  • 0

This is my Servlet code which i am using to query a solr index

import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

//Solr Imports
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;

/*
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
*/

public class HelloWorldExample extends HttpServlet {

    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
    {
        PrintWriter out = response.getWriter();
        String inputStr=request.getParameter("input");
        out.println("<html><h1>" + inputStr + "</h1></body></html>");
        //try {
        SolrServer server = new CommonsHttpSolrServer("http://localhost:8080/solr/");
        SolrQuery solrQuery = new SolrQuery(); 
        //solrQuery.setQuery("fileName:"+input);
        solrQuery.setQuery("Latitude:"+32.55668);
        QueryResponse rsp = server.query(solrQuery);
        //SolrDocumentList x = rsp.getResults();
        System.out.println(rsp);
        }
        catch (SolrServerException e) {
            e.printStackTrace();
        }       
    }
}

I am compiling this code using

D:\xampp\tomcat\webapps\examples\WEB-INF\classes>javac -classpath .;D:\JAR\servl
et-api.jar;D:\JAR\1solr-core-1.3.0.jar;D:\JAR\1solr-solrj-1.3.0.jar;D:\JAR\1solr
-common-1.3.0.jar;D:\JAR\apache-solr-solrj-1.4.0.jar HelloWorldExample.java

This code compiles without problem. However when i run this servlwt it gives me an error:

type Exception report
message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception
root cause

java.lang.NoClassDefFoundError:
org/apache/solr/client/solrj/impl/CommonsHttpSolrServer
HelloWorldExample.doGet(HelloWorldExample.java:35)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

  • 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-02T21:55:01+00:00Added an answer on June 2, 2026 at 9:55 pm

    When you are compiling you are properly including all dependant libraries into the classpath.

    The classpath used for execution is a totally different beast. You need to make sure the Servlet has access to the jars when it is being executed. How to do that depends on the container you are using. Since it is tomcat it should be easy to find out (search the web) how to add thirdparty libraries (pretty sure you can just dump the jar into common/lib directory).

    Best would be to have a build process different from manual compiling of the servlet class. For example and IDE or maven – that would produce a war / web-application and deploy it to the servlet container (tomcat in your case). I do really really recommend doing this instead of manual compiling and deploying (once you get IDE-way to work and become more masterful at deployment you could go back to manual deployment)

    Maybe search the internet for a tutorial on servlets and tomcat?

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

Sidebar

Related Questions

In the java servlet, how to do mapping with this url : http://localhost8080/myproject/client/1234 the
I have this java servlet that grabs information from a form, I need to
I have a servlet which takes us to an existing jsp, say home.jsp. This
I have a web application code which uses jsp, servlet and ejb. I created
I have a RESTful service which injects an EJB(3.0) using the @EJB annotation. This
Unix gurus! I have a Java program which passes some parameters to a Servlet
This is my js file in which I am using jquery to verify login
I am developing an j2me application which is communicating with the database using servlet.
I am building my first Java application using GWT which must read in data
I am using this link to study Spring MVC. As described dispatcher-servlet is at

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.