views:

350

answers:

2

I have written a custom Transformer subclass for the Solr DataImportHandler. It is in a jar file, but I can't figure out how to get solr to find it.

java.lang.NoClassDefFoundError: org/apache/solr/handler/dataimport/Transformer

I've configured the data-config.xml file with the full path to the custom transformer:

transformer="RegexTransformer,DateFormatTransformer,com.mycompany.xform.MyTransformer"

I've tried my jar file in every /lib, /dist directory I could find, leading me to believe that it is a problem with a dependent file. It would be very nice if the logs indicated the actual class that can't be found, but they are pretty unhelpful. If I remove the MyTransformer specification, the dataimporthandler works just fine.

A: 

I would guess that it has to do with your class loader. (assuming you are using Tomcat: https://sec1.woopra.com/docs/class-loader-howto.html)

If you put your jar into "Common" Classloader directory, then all it's dependencies need to also be available to that classloader. So presumably your Solr classes are in the webapps directory (ie WEB-INF/lib), so how is tomcat supposed to know where to find the right class. For instance, consider you have two versions of the Solr in different webapp directories? which version should Tomcat use?

So i think you solution is to put your jar into the Solr webapp.

mlathe
A: 

I put my custom transformer jar file into solr/lib; the same directory as the jetty.jar file.

I also had to put build and put apache-solr-dataimporthandler-1.4.1-dev.jar in the same solr/lib directory.

tommy chheng