Saturday, January 2, 2010

Setting up Apache Solr in Eclipse

Apache's Solr is a powerful software package that allows you to develop your own search engine in no time. It's purely written in Java using Lucene at its core and can run inside any servlet container such as Tomcat (or Jetty). Eclipse is an IDE that makes developing Java applications incredibly easy because of its wealth of features such as code completion and refactoring capabilities not to mention the number of free plugins available to further make development easier. I find it much easier to keep everything contained in one place and being able to code, debug, and test inside of Eclipse makes developing my search engine much easier. This simple tutorial will show you how to setup Apache Solr to run inside Eclipse using a free third-party plugin that runs Jetty inside Eclipse.

You will need:
Step One: Basic Setup

Download and extract both Eclipse and Apache Solr tar files somewhere on your disk. Since Solr has some XML configuration files, I would also suggest installing the Eclipse WTP (Web Toolkit Platform) that gives you some good built-in XML editors.



Follow the Getting Started guide in the RunJettyRun wiki to install the plugin. It should be pretty fast and easy.

Step Two: Create your Java project

Create a standard Java project in Eclipse (File..New..Java Project). Call it what you wish (I called it "TestSolr"). The default options should be fine and click through the wizard to see all the options or click Finish at your first chance to get done faster.



Here you should see your TestProject in your workspace with a blank src folder.

Step Three: Setup the Solr webapp in your Eclipse project.

This is where the RunJettyRun plugin installed earlier gets used. This plugin allows you to develop, run and debug web applications inside Eclipse allowing you to take advantage of Eclipse's powerful code editing and debugging capabilities. It's also one of the simpler web application development plugins available. Eclipse supports full blown web development but for the purposes of this tutorial and developing needs, this plugin is more than enough.
  • Inside the TestSolr directory, create a folder called "webapp". Do this by right clicking on the "TestSolr" in the workspace, select "New" and then "Folder".
  • At a command prompt, unjar the apache-solr-1.4.0.war in this webapp folder. In Windows, this would be done by the following command:
    jar -xvf c:\applications\apache-solr-1.4.0\dist\apache-solr-1.4.0.war
    The contents of the war file should be in the webapp folder. To confirm, right click on the "TestSolr" folder in the Eclipse workspace and select "Refresh."
  • Add all the jar files in the webapp/WEB-INF/lib to the Build Path. This is done by selecting all the jars and right click on any of the jars (while all are selected), select the "Build Path" sub-menu and select "Add to Build Path"
  • Setup a solr home folder inside your project. For purposes of this tutorial, copy the "solr" folder from the "example/" folder in the directory containing solr into the "TestSolr" folder in your Eclipse workspace. By now, your "TestSolr" project layout should look something like this.

Step Four: Let's run this thing!

Now that you have setup your project, it's time to create a run configuration for Jetty and run this!
  • In Eclipse, go to the Run menu and select "Run Configurations...".
  • On the left rail, you should see "Jetty Webapp" as one of the run configuration types. Right click on this and select "New". The project should be "TestSolr" (if not, type in TestSolr in the text box labeled with "Project"). The name of the run configuration is populated with "TestSolr" and can be whatever you wish.
  • The default HTTP port is 8080 and can be left alone if you wish. To conform to Solr tutorials (making copying/pasting links easier, change this to 8983). Delete the HTTPs port 8443 since we aren't doing any SSL access. This will disable the SSL specific fields such as the keystore/password fields.
  • Change the "context" to "/solr" from "/". This is more for conformity with the solr tutorials in that all links in the wiki you to something like http://localhost:8983/solr/.
  • Type in "webapp" in the "WebApp dir" text box. This is the root of the web application and is the directory above the WEB-INF folder. This is where the solr war file was extracted and hence is the equivalent of deploying the solr war in your servlet container.
Your launch configuration should look like the following:


Now click the "Run" button which will save the changes and the console will hopefully start spewing out logs produced by both Jetty and Solr. Open a browser to http://localhost:8080/solr/admin/ and voila! you should see the Solr admin page. In scrolling through the console, you shouldn't see any exceptions thrown.

This simple tutorial just shows the basics of setting up a simple solr installation inside Eclipse using Jetty and running inside Eclipse. Notice that we don't have any of our own code running that may do some extra things (say custom analyisis, tokenizing etc). If we did have such code, then it would naturally lie in the "src/" folder; however, we need to instruct Eclipse to compile the code so that it goes in the WEB-INF/classes folder so it will run inside Jetty. To do this:
  • Right click on the TestSolr project and select "Properties".
  • Click on the "Java Build Path" on the left rail
  • Click on the "Source" tab and towards the bottom, change the default output folder to be "TestSolr/webapp/WEB-INF/classes".


Now you can develop your custom solr plugins directly in Eclipse and debug them immediately. Instead of running the TestSolr jetty instance, you can launch it in debug mode by going to the Run Menu and opening the "Debug Configurations.." sub-menu, selecting the Jetty configuration created earlier and click the "Debug" button. I would encourage familiarizing yourself with Eclipse's debugging capabilities for they are vast and amazing.

If you have any questions or comments, please post them and I'll do my best to answer them as quickly as possible.

43 comments:

  1. Hi..,
    it sounds good.
    But i have problem while setup solr in Eclipse IDE.

    Whiling building the solr project, i got following errors. how to fix it?

    The method getTextContent() is undefined for the type Node TestConfig.java solr/src/test/org/apache/solr/core line 88 Java Problem

    The method getTextContent() is undefined for the type Node TestConfig.java solr/src/test/org/apache/solr/core line 91 Java Problem

    The method setXIncludeAware(boolean) is undefined for the type DocumentBuilderFactory Config.java solr/src/java/org/apache/solr/core line 105 Java Problem

    The method setXIncludeAware(boolean) is undefined for the type DocumentBuilderFactory DataImporter.java solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport line 173 Java Problem

    The method setXIncludeAware(boolean) is undefined for the type DocumentBuilderFactory TestXIncludeConfig.java solr/src/test/org/apache/solr/core line 32 Java Problem


    I follow your tutorial to setup it. but no luck.
    Please help me out?

    ReplyDelete
  2. What version of the JVM are you using in Eclipse? Also make sure that you use the JDK and not the JRE when developing.

    ReplyDelete
  3. Thanks for quick reply.

    I am using java version 1.6.0_17 and also i confirmed that i am using JDK for developing.

    Actually above 5 errors states that some methods missing. But i can verified that exceptional methods are defined in the packages.
    But i don't know why eclipse showing those errors?
    Is any problem with eclipse IDE that I setup it?

    ReplyDelete
  4. Hi,
    Actually i have fixed those errors i early mentioned to you. Now, Jetty runs successfully. But while move on to http://localhost:8983/solr/admin/ on i am getting nothing in browser(blank white screen). I seen some errors in eclipse IDE console while move on to that url.
    Errors are,
    2010-01-29 15:37:10.442:org.apache.jasper.runtime.JspFactoryImpl:WARN: Exception initializing page context
    java.lang.VerifyError: (class: org/apache/jasper/runtime/PageContextImpl, method: getELResolver signature: ()Ljavax/el/ELResolver;) Incompatible argument to function
    at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:128)
    at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:81)
    at org.apache.jsp.admin.index_jsp._jspService(org.apache.jsp.admin.index_jsp:71)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:80)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    ..........
    ..........

    Please help me out

    ReplyDelete
  5. Hmm.. do you have multiple jars in the classpath that might be conflicting with each other? Can you post the .classpath file?

    ReplyDelete
  6. Hi.,
    i got a clue from your multiple jars and fix that issue. Now its working fine. Thank you.
    If i have any further queries, i will ask you.

    ReplyDelete
  7. Hi,

    Thanks for this wonderful tutorial. I was able to successfully modify the code (enabled wildcard search by modifying queryparser.java file) and it works fine in Eclipse. Now I am not sure how to bundle the changes and deploy it.. can you please provide the pointers for that?

    Thanks,
    Barani

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
  8. Hi Barani,
    Sorry for the late response. I don't get email notifications on comments and am not sure how (if at all) to set that up. Depending on your build configuration, you could simply do an export to jar in eclipse and drop that jar on your WEB-INF/lib path so long as it doesn't collide with a jar with the same classes.

    ReplyDelete
  9. Amit,

    Saw you presentation last night at Hacker Dojo. was hoping to talk to you but the queue was too long :)
    Anyways, did you try the above with the latest source of solr(merged under lucene). I have all types of issues with that, will look into it today and post my findings.
    Would love to meet up for lunch one of these days(my treat) if possible? Don't want to wait for another Lucene/SOLR meetup :)
    feel free to ping me at aboxfortheotherstuff[at]gmail[dot]com

    thanks
    Vish

    ReplyDelete
  10. Amit,

    Thanks for great article. I would like know if you can share information on how to set up solr and lucene source in new projects. And then use those project into TestSolr(webapp, as in this article). Therefore TestSolr application depends on other solr project instead of the distributed jar library as explained in the article above. I need to modify solr filters and and new custom dictionaries during analysis phase. What do you think should be best way to produce?

    ReplyDelete
  11. Hi,
    I am new to Apache Solr. I have problem in installing and configuring it. I read your article. But I have problems in doing it. I am using maven with eclipse.So, I dont have to install jetty separately.
    So when I opened run configuration I did not get jetty server option.
    As suggested by you I made a webapp folder inside my project folder and unzipped that solr.jar file. But I did bot get any idea what to do after that. Can you please tell also what change I have to make in files Schema.xml and Solarconfig.xml

    ReplyDelete
  12. Hello,

    thank you for your very valuable article!

    Thanks to this article, I could setup solr in eclipse and begin writing a simple response writer plugin.

    However, I cannot figure how to debug. When lauching the debug configuration, eclipse doesn't stop on any breakpoint.

    Any hint?

    ReplyDelete
  13. @Priya, did you install the RunJettyRun plugin I mentioned? That is where you get the run option for jetty. If you are using maven and eclipse without jetty then I am not sure.

    @Ben, Can you launch Solr in Eclipse using the run configuration? When you say the breakpoints aren't being hit, are these the ones in your code? If you can send screenshots or configuration files, do so to ANithian-at-gmail.com

    ReplyDelete
  14. Hi,

    Thanks for such a great article.
    But i have a requirement of debugging the SOLR code itself, not the plugins.
    When i post a document to Solr, i want to debug the solr server.
    I have put breakpoints at the solr code whose jars i have used in web-inf/lib... but still they wont stop at these breakpoints.
    can u let me know what i am missing?

    Thanks,
    Geeta

    ReplyDelete
  15. Hi Geeta,

    Is your solr source code in Eclipse or elsewhere on the file system. In either case it won't matter but it's important that you attach the source to the jar file. The way you know this is in your project, select the appropriate jar file, expand and double click a concrete class. You should see the actual java source. Of course you can't edit it but you should be able to scroll through it and set breakpoints. When you debug the application, that breakpoint should get hit.

    Is this not the case? Perhaps I'll try and write a follow up since you aren't the first to have this requirement!

    - Amit

    ReplyDelete
  16. Amit,
    Thanks for tutorial. I followed and built the project successfully. I also want to know how to debug the source code so I can better understand the algorithms. Do you know how to attach all source code to the classes instead of doing it one by one?
    E.g. I am interested in the DataImportHandler class, but I don't know what java file to attach to it.
    Any suggestion on how to pursue that?

    - Elaine

    ReplyDelete
  17. Hi Elaine,

    I'm glad that this tutorial was helpful! Regarding attaching source the classes, this can get a bit tricky because Solr/Lucene has a bunch of source folders that comprise the various jars. Many times I have to use "find" to find the java source file and it's location within the source tree.

    I believe DataImportHandler is in the contrib folder last I recall but I haven't been working in Solr for a bit now.

    Sorry for the rather lame suggestion but I think 'find' may be your friend here.

    Cheers!
    Amit

    ReplyDelete
  18. Amit, thank you very much for the pointer. I got it attached.

    Elaine

    ReplyDelete
  19. When i try to run I get "Could not find the main class program will exit." wat did i miss?

    ReplyDelete
  20. Did you create a Jetty application or are you trying to run some main routine? Also perhaps ensure that everything built properly and that there are no project errors (missing libraries) that could cause your project to not build hence possibly throw this error.

    ReplyDelete
  21. Amit,
    I tried to run the solr application trhough eclipse but when i try http://localhost:8080/solr/admin/
    am getting the below error.What did u give in the web.xml file?
    HTTP ERROR: 503
    Problem accessing /solr. Reason:

    SERVICE_UNAVAILABLE
    Please help me with this issue.
    Thanks,
    Priyanka

    ReplyDelete
  22. 26-set-2011 11.50.27 org.apache.solr.common.SolrException log
    GRAVE: java.lang.RuntimeException: Can't find resource 'solrconfig.xml' in classpath or 'solr\.\conf/', cwd=C:\progetti_eclipse\TestSolr
    at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:268)
    at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:234)
    at org.apache.solr.core.Config.(Config.java:141)
    at org.apache.solr.core.SolrConfig.(SolrConfig.java:131)
    at org.apache.solr.core.CoreContainer.create(CoreContainer.java:435)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:133)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:82)

    ReplyDelete
  23. Hi smau: did you follow the last bullet item of step 3, setting up a solr folder?

    Thanks
    Amit

    ReplyDelete
    Replies
    1. Thanks Amit...I had also missed this step...it works now...thanks for this tutorial!

      Delete
  24. Priyanka, I don't think I changed the web.xml at all.. do you have your jetty plugin setup as described above?

    ReplyDelete
  25. Amit,

    I was trying to use it with zk server and get some weird logger errors


    java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.(QuorumPeerConfig.java:43)
    at org.apache.solr.cloud.SolrZkServer.parseConfig(SolrZkServer.java:74)
    at org.apache.solr.core.CoreContainer.initZooKeeper(CoreContainer.java:146)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:335)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:292)
    at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:241)
    at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:93)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:97)

    ReplyDelete
    Replies
    1. Hello... unfortunately I haven't tried this in a while (moved away from Solr work for the moment) but is log4j on your eclipse classpath?

      Delete
    2. If i ran it without the zk params it works fine. Here is the list of the jar in my webapp/lib. I also tried adding the log4j.jar didnt help.

      ant.jar
      pache-solr-core-4.0-SNAPSHOT.jar
      apache-solr-noggit-r1099557.jar
      apache-solr-solrj-4.0-SNAPSHOT.jar
      commons-beanutils-1.7.0.jar
      commons-codec-1.4.jar
      commons-collections-3.2.1.jar
      commons-csv-1.0-SNAPSHOT-r966014.jar
      commons-fileupload-1.2.1.jar
      commons-httpclient-3.1.jar
      commons-io-1.4.jar
      commons-lang-2.4.jar
      guava-r05.jar
      jcl-over-slf4j-1.6.1.jar
      log4j-over-slf4j-1.6.1.jar
      lucene-analyzers-common-4.0-SNAPSHOT.jar
      lucene-analyzers-phonetic-4.0-SNAPSHOT.jar
      lucene-core-4.0-SNAPSHOT.jar
      lucene-grouping-4.0-SNAPSHOT.jar
      lucene-highlighter-4.0-SNAPSHOT.jar
      lucene-memory-4.0-SNAPSHOT.jar
      lucene-misc-4.0-SNAPSHOT.jar
      lucene-queries-4.0-SNAPSHOT.jar
      lucene-queryparser-4.0-SNAPSHOT.jar
      lucene-spatial-4.0-SNAPSHOT.jar
      lucene-suggest-4.0-SNAPSHOT.jar
      slf4j-api-1.6.1.jar
      slf4j-jdk14-1.6.1.jar
      uuid-3.2.jar
      velocity-1.6.4.jar
      velocity-tools-2.0.jar
      wstx-asl-3.2.7.jar
      zgsolrplugins.jar
      zookeeper-3.3.3.jar

      Delete
    3. So even adding the log4j-1.2.xx (or whatever it's up to now) didn't help when running with the ZK params? I thought with SLF4J there was a log4j impl jar that you have to add? Can you post what parameters you tried so either me or someone else may be able to try? Thanks!

      Delete
    4. This comment has been removed by the author.

      Delete
    5. Reporting back: Works now, it wasn't anything to do with solr jars. My solr plugin was looking for the jars in the source directory, have to figure out why that was the case. But adding the logger jar to plugin project fixed it.

      Delete
    6. Great to hear! If you find any more information, please post back for others to see!

      Delete
  26. connecting to an external zk server with the following param
    -DzkHost=127.0.0.1:10983 -Dsolr.solr.home=C:\Users\Administrator\Solr\solr

    ReplyDelete
  27. Hi Amit!!
    Great Blog!!
    I am very much new to using solr,,,,I have set up apache solr using eclipse with the help of your tutorial,,,now i wish to use the search feature of solr in order to search data in xml files present in the exampledocs folder in apache solr,,,however i am not able to understand how to go about doing this with solr integrated in eclipse,,,could you help me out??

    ReplyDelete
  28. Hi Amit,

    I need your help man!

    When I run Run Jetty , Am getting this in the console,

    2013-09-18 17:41:18.186:INFO:oejs.Server:jetty-7.6.2.v20120308
    2013-09-18 17:41:18.263:WARN:oejx.XmlParser:FATAL@file:/home/bal/workspace/TestSolr/webapp/WEB-INF/web.xml line:1 col:1 : org.xml.sax.SAXParseException; systemId: file:/home/bal/workspace/TestSolr/webapp/WEB-INF/web.xml; lineNumber: 1; columnNumber: 1; Premature end of file.
    2013-09-18 17:41:18.264:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/solr,[file:/home/bal/workspace/TestSolr/webapp/]}
    org.xml.sax.SAXParseException; systemId: file:/home/bal/workspace/TestSolr/webapp/WEB-INF/web.xml; lineNumber: 1; columnNumber: 1; Premature end of file.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1404)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1034)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
    at org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:199)
    at org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:215)
    at org.eclipse.jetty.webapp.Descriptor.parse(Descriptor.java:60)
    at org.eclipse.jetty.webapp.WebDescriptor.parse(WebDescriptor.java:143)
    at org.eclipse.jetty.webapp.MetaData.setWebXml(MetaData.java:163)
    at org.eclipse.jetty.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:55)
    at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:418)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:261)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at runjettyrun.Bootstrap.main(Bootstrap.java:82)
    2013-09-18 17:41:18.276:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080

    ReplyDelete
  29. Hey dude thanks for the tutorial
    i have some trouble...

    i made exaclty what you describe and i get this error:

    Starting scanner at interval of 5 seconds.
    2013-11-26 15:48:37.422:INFO::jetty-6.1.26
    2013-11-26 15:48:37.885:WARN::failed SolrRequestFilter: org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
    2013-11-26 15:48:37.885:WARN::Failed startup of context org.mortbay.jetty.webapp.WebAppContext@753ac592{/solr,C:\eclipse\work\MyFirstSolrPrj\webapp}
    org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
    at org.apache.solr.servlet.SolrDispatchFilter.(SolrDispatchFilter.java:111)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:92)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:97)
    2013-11-26 15:48:37.887:WARN::failed org.mortbay.jetty.webapp.WebAppContext@753ac592{/solr,C:\eclipse\work\MyFirstSolrPrj\webapp}: java.lang.NoClassDefFoundError: org/slf4j/Logger
    2013-11-26 15:48:37.887:WARN::Error starting handlers
    java.lang.NoClassDefFoundError: org/slf4j/Logger
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at org.mortbay.log.Log.unwind(Log.java:228)
    at org.mortbay.log.Log.warn(Log.java:197)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:507)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at runjettyrun.Bootstrap.main(Bootstrap.java:97)
    2013-11-26 15:48:37.910:INFO::Started SelectChannelConnector@0.0.0.0:8983



    do you know why?

    ReplyDelete
  30. Do you have SLF4j and Log4j on your classpath? Sounds like something isn't properly in place given the NoClassDefFound issue.

    ReplyDelete
  31. Very helpful post! Thanks for the help :)

    ReplyDelete
  32. Hello Amit,
    I have 1000 xml records , i need to index them and query them . So should i modify my schema.xml for the records to be indexable ?? What could be the best approach to achieve this.

    ReplyDelete
  33. very helpfull nice post .Thanks

    ReplyDelete
  34. The setup guide for Apache SOLR in Eclipse is highly appreciated. Nice Travel Apps It offers clear and concise instructions for integrating SOLR into the Eclipse IDE.

    ReplyDelete