1

I am stumped by this problem. I have written a custom UpdateRequestProcessorFactory. The code is:

package mira;
import java.io.IOException;

 import org.apache.solr.common.SolrInputDocument;
  import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.processor.UpdateRequestProcessor;
    import org.apache.solr.update.processor.UpdateRequestProcessorFactory;

   public class MaProcessorFactory extends UpdateRequestProcessorFactory
  {
    @Override
    public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse  rsp,      UpdateRequestProcessor next)
   {
     return new MaProcessor(next);
    }
  }

 class MaProcessor extends UpdateRequestProcessor
  {
    public MaProcessor( UpdateRequestProcessor next) {
      super( next );
    }

  @Override
  public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument doc = cmd.getSolrInputDocument();

    Object vid = doc.getFieldValue( "id" );
    Object vcontent = doc.getFieldValue( "content" );

    doc.setField( "fileurl", vid );

    // pass it up the chain
    super.processAdd(cmd);
  }
}

I have compiled it by setting the classpath as CLASS-PATH: ../../dist/solr-solrj-4.10.1 ../../dist/solr-core-4.10.1.jar
and compiling as

jar cfmv mira.jar Manifest.txt MaProcessor.class MaProcessorFactory.class

The Manifest.txt is

CLASS-PATH: ../../solr-solrj-4.10.1 ../../solr-core-4.10.1.jar

My Solrconfig.xml has

<lib dir="../../" regex="mira.jar" />

as the last directive and

  <requestHandler name="/update" class="solr.UpdateRequestHandler"> 
   <lst name="defaults">
   <str name="update.chain">concatfld</str>
   </lst>      
   </requestHandler>

  <updateRequestProcessorChain name="concatfld">
      <processor class="mira.MaProcessorFactory" />
      <processor class="solr.LogUpdateProcessorFactory" />
     <processor class="solr.RunUpdateProcessorFactory" />
   </updateRequestProcessorChain>`

when I run

   java -jar start.jar

I get an error

  Error creating core [divine-c]: Error loading class 'mira.MaProcessorFactory'
    org.apache.solr.common.SolrException: Error loading class 'mira.MaProcessorFactory'

Any help will be greatly appreciated.

Mike
  • 11
  • 3
  • solr-solrj-4.10.1 was a typo. I do have solr-solrj-4.10.1.jar in the Manifest.txt file. – Mike Dec 23 '14 at 01:24

4 Answers4

1

When you start solr, do you see log message that says mira.jar loaded? It is easy to verify verify whether jar loaded or not by looking logs.

Also, I use maven to generate jar, I am not familiar with jar cfmv command. I would try to generate final jar with an automation tool like ant or maven.

Thats my two cents.

  • Yes mira.jar is loaded. I can see that in the command line during processing. I am not familiar with maven. Perhaps I can try that. The jar cfmv command is create-file-manifest-verify. Do you have the command to generate jar using maven? Thanks. – Mike Dec 25 '14 at 16:52
  • So the problem is with jar. Maven is super easy, mvm package generates a jar and you can use it immediately. Many IDEs have support for maven too. Here is an example template solr-plugin project : https://issues.apache.org/jira/secure/attachment/12634690/ComplexPhrase-4.7.zip – Ahmet Arslan Dec 26 '14 at 14:54
0

Try putting mira.jar into a lib directory at the same level as solr.xml Please see Shawn's response : http://find.searchhub.org/document/a280909a7286e1c8#73b177718d3e9959

  • Thanks Ahmet but that did not work. I tried all sorts of things. Created a lib under he solr folder and put mira.jar therein and put lib folder in solrconfig.xml. Also tried not putting it in solrconfig.xml None of it worked. There is something else going on. Cant put a finger on it. – Mike Dec 24 '14 at 23:24
0

I don't know if this is finally solved, but have you tried to put your library inside core folder?

{core_folder}/lib/mira.jar

Kerruba
  • 1,779
  • 1
  • 17
  • 25
0

You don't have to mention jar name in Solrconfig , rather it is auto-loaded by solr if, it is in solr.home.home/lib or any solr path that is aut-loaded by solr.

Now being jar loaded automatically you need to mention class name with full package like class="com.augmentsys.HelloWorld" and if you want you can also use name tag for further use.

so something like this

class="com.augmentsys.HelloWorld" name="mytest" 

Give it a try.

Vidalia
  • 36
  • 1
  • 5