26

I am using Solr 3.3.0 with Tomcat 6.0.26. I was able to successfully install Solr and i was even able to access its web interface using http:/localhost:8084/solr/admin.

Now i want to use its dataimporthandler to index data from my database.I have added following to my solrconfig:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImport
 Handler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler> 

I have also created a data-config.xml in same directory.

My solrconfig file has following location for dataimport

  <lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" /> 

And i have checked that dataimporthandler.jar file exist in the dist folder at following path C:\web\solr\example\lib\apache-solr-3.3.0\dist

But whenever I type http:/localhost:8084/solr/dataimport or http:/localhost:8084/solr/admin/dataimport it says resource unavailable. I thought it was dur to some problem with Tomcat setting so i stopped tomcat and tried to start Solr from cmd using java -jar start.jar. And i get the following error

HTTP ERROR 500
Problem accessing /solr/. Reason:
Severe errors in solr configuration.
Check your log files for more detailed information on what may be wrong.
If you want solr to continue after configuration errors, change: 

<abortOnConfigurationError>false</abortOnConfigurationError>

in solr.xml

-------------------------------------------------------------
org.apache.solr.common.SolrException: Error loading class    
    'org.apache.solr.handler.dataimport.DataImportHandler'
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:389)
at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:423)
at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:459)
at  
  org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:157)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:563)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:463)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:207)
at 
   org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:130)
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.HandlerCollection.doStart(HandlerCollection.java:152)
at 
 org.mortbay.jetty.handler.ContextHandlerCollection.doStart
 (ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
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 org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mortbay.start.Main.invokeMain(Main.java:194)
at org.mortbay.start.Main.start(Main.java:534)
at org.mortbay.start.Main.start(Main.java:441)
at org.mortbay.start.Main.main(Main.java:119)
  Caused by: java.lang.ClassNotFoundException:   
  org.apache.solr.handler.dataimport.DataImportHandler
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.net.FactoryURLClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:373)
... 34 more

11 Answers 11

19

I've been looking at this problem for a bit on my own, using solr 4.1 and tomcat. I wasn't able to include the library I needed with <lib dir="../../dist/" regex="solr-dataimporthandler-.*\.jar" /> -->, which I figured had to be correct because from the directory that I had the solrconfig.xml in, it was two directories up and one down to dist. It wasn't until I temporarily subbed in the direct path (for me, /opt/solr/dist) that I realized that the problem was that I was starting from the wrong directory. It turns out that what I needed was:

<lib dir="../dist/" regex="solr-dataimporthandler-.*\.jar" /> -->

So, if you're having trouble with including this, check that you're starting from the directory that contains your conf directory, and not the conf directory itself.

3
  • I am using Solr 4.2.1. I have both the mysql connector and data import jars under project-dir/solr/lib and added to the project build path. solrconfig.xml is under project-dir/solr/app-cores/SimilarList/conf/solrconfig.xml. I tried <lib dir="../../lib" /> which does not work. ../lib, ../../../lib and even the complete path C:/Users/Arun/workspace/project-dir/solr/lib don't work! I am getting the same class not found exception!
    – arun
    Apr 25, 2013 at 4:43
  • When Solr starts it says ProjectClassLoader loaded these jars along with the ones found under webapp/WEB-INF/lib.
    – arun
    Apr 25, 2013 at 4:49
  • Also the start-up log says: SolrResourceLoader replaceClassLoader loaded these jars!
    – arun
    Apr 25, 2013 at 5:23
6

It seems that for several versions of Solr including 4.3, the dataimport handler jar is not included in the final war file when you build from source.

There is a very simple fix to this by modifying the file /solr/webapp/build.xml.

  1. Open that file and find the "dist" target.
  2. Find this section of the "dist" target:

    <lib dir="${dist}" excludes="${exclude.from.war},${common.classpath.excludes}">

  3. Add this item to the list of includes in that section:

    <include name="apache-solr-dataimporthandler-${version}.jar" />

Save and exit.

Now, when you build, do the following:

  • ant dist-contrib
  • ant dist

To verify that the dataimporthandler jars are in your WAR file, unpack it, and look for it among the jars in the WEB-INF/lib directory.

Some variation of this will probably work for earlier versions too.

4

The jar you are looking for (at least in 3.5) is under the ./dists folder

3

As far as you are telling us, your jar file name does not match the supplied regexp:

With the given configuration:

<lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" /> 

The file:

dataimporthandler.jar

Does not match the regexp, while it has to, as shown in the sample configuration file for Solr

Probably start by just specifying:

<lib dir="../../dist/"/>
1
  • I wrote it in short, my jar file name is "apache-solr-dataimporthandler-3.3.0.jar"
    – Prim
    Aug 4, 2011 at 8:37
2

i put solr jars under WEB-INF/lib

2

Make sure you have following three required fields correct.

1) A entry for dataimport handler in solr-conf.xml

</requestHandler>
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>

2) Your Solr war file is aware of solr-home folder , and hence the libraries included in solr-home. If solr-home is added explicitly.

To make your solr.war aware of solr-home folder deploy the solr.war at server.

Go to apache-tomcat-6.0.36/webapps/solr/WEB-INF and open web.xml in any text editor.

Now search for the entry showing below

<!-- <env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value> /Path/To/My/solr/Home/solr/</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry> -->

replace value to the solr-home folder in your case. This will make solr, point solr-home folder hence lib folder inside it.

3) Add your new libraries location to /home/javaguys/solr-home/collection1/conf/solr-config.xml. just under tag like .

This will solve your problem i hope, for more information please check out this solution here.

1

I solved this problem by building dataimporthandler jar from the solr source. For 3.1, dataimporthandler is not included in apache-solr-core-3.1.0.jar . I couldn't find the jar file for dataimporthandler, so I built it from the source and put it in my solr lib directory

1

I am using Solr 4.0 with a Glassfish 3.1.2 container and I solved the problem by opening the solr war itself, manually just adding the jar files inside, and redeploying glassfish.

0

Had this problem twice, on Windows Tomcat, and Ubuntu Tomcat.
SOLR 4.3, and Tomcat 7

Make sure that the file below is in the SOLR_Home /lib folder
solr-dataimporthandler-4.3.0.jar

As mentioned above you also need the reference in the config file. Adjust the path as needed.

<lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />

I might have some paths messed up, but that is how I got it to work.

0

You need to add below code in your solrconfig.xml file under the config tag.
Note: Please change the version of jar files accordingly.

<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="mysql-connector-java-5.1.18-bin.jar" />

For more information you can refer connecting-solr-to-database .

0

The version is 4.3.1, I copied the dataimporthandler jar to /lib but it didn't work. I added this to conf/solrconfig.xml to fix this problem.

<lib dir="../../../dist/" regex="solr-dataimporthandler-.*\.jar" />

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.