You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Allistair C <al...@gmail.com> on 2014/09/19 21:43:57 UTC

Error Instantiating UpdateRequestProcessorFactory

Hi all,

I’m in a bit of a cul de sac with an issue, hope you can help.

I am creating a custom UpdateRequestProcessor. The Solr documentation details that I need to write a factory class subclassing UpdateRequestProcessorFactory and this should return an instance of my class that subclasses UpdateRequestProcessor.

I have done this, and I have created a JAR.

I have deployed the JAR into Tomcat’s lib folder where Solr is running.

I have modified the solrconfig to include my class correctly.

On startup Solr finds my class but does not believe it conforms to being a UpdateRequestProcessorFactory.

SEVERE: org.apache.solr.common.SolrException: Error Instantiating UpdateRequestProcessorFactory, com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory is not a org.apache.solr.update.processor.UpdateRequestProcessorFactory
	at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:421)

Things I have tried:

- Ensured that I am compiling my JAR with the exact JDK that is running Solr.
- Downloaded Solr 3.6.2 and copied one of the Solr built-in processors, renamed it, compiled it and tried to use it - SAME issue.
- Created a test that uses the same code as the Solr code that is failing (namely, isAssignableFrom):

            Class clazz = Class.forName("com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory");
            boolean isA = UpdateRequestProcessorFactory.class.isAssignableFrom(clazz);
            System.out.println(isA);

Print’s “true” - i.e. it’s perfectly OK!

I include my simple processor here:

package com.acme.solr.update.processor;

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

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

    @Override
    public void processAdd(AddUpdateCommand cmd) throws IOException
    {
        SolrInputDocument doc = cmd.getSolrInputDocument();
        doc.setField("foo", "bar");

        super.processAdd(cmd);
    }
}

At this point I am at a loss and would appreciate any assistance or ideas to try.

Cheers

Re: Error Instantiating UpdateRequestProcessorFactory

Posted by Allistair C <al...@gmail.com>.
I’ve found the issue.

- First, my IDE was putting all the Solr JAR dependencies into my custom JAR. I noticed the JAR was 14MB when it should have been a few Kb. I changed this to get a JAR with only my classes in.

- I then ran into CNFEs of the Solr UpdateRequestProcessorFactory and UpdateRequestProcessor classes. This was because I was adding my JAR to Tomcat’s lib folder where they are loaded before the solr web app’s libs, so it was not finding the dependencies. By moving my JAR into the solr web app WEB-INF/lib this issue is resolved.

Cheers

On 20 Sep 2014, at 05:30, Shalin Shekhar Mangar <sh...@gmail.com> wrote:

> Sounds like a class loader issue. Try adding your jar to $SOLR_HOME/lib
> instead of tomcat lib.
> 
> Also, upgrade to Solr 4.x, 3.6 is ancient! :)
> 
> On Sat, Sep 20, 2014 at 1:13 AM, Allistair C <al...@gmail.com> wrote:
> 
>> Hi all,
>> 
>> I’m in a bit of a cul de sac with an issue, hope you can help.
>> 
>> I am creating a custom UpdateRequestProcessor. The Solr documentation
>> details that I need to write a factory class subclassing
>> UpdateRequestProcessorFactory and this should return an instance of my
>> class that subclasses UpdateRequestProcessor.
>> 
>> I have done this, and I have created a JAR.
>> 
>> I have deployed the JAR into Tomcat’s lib folder where Solr is running.
>> 
>> I have modified the solrconfig to include my class correctly.
>> 
>> On startup Solr finds my class but does not believe it conforms to being a
>> UpdateRequestProcessorFactory.
>> 
>> SEVERE: org.apache.solr.common.SolrException: Error Instantiating
>> UpdateRequestProcessorFactory,
>> com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory is
>> not a org.apache.solr.update.processor.UpdateRequestProcessorFactory
>>        at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:421)
>> 
>> Things I have tried:
>> 
>> - Ensured that I am compiling my JAR with the exact JDK that is running
>> Solr.
>> - Downloaded Solr 3.6.2 and copied one of the Solr built-in processors,
>> renamed it, compiled it and tried to use it - SAME issue.
>> - Created a test that uses the same code as the Solr code that is failing
>> (namely, isAssignableFrom):
>> 
>>            Class clazz =
>> Class.forName("com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory");
>>            boolean isA =
>> UpdateRequestProcessorFactory.class.isAssignableFrom(clazz);
>>            System.out.println(isA);
>> 
>> Print’s “true” - i.e. it’s perfectly OK!
>> 
>> I include my simple processor here:
>> 
>> package com.acme.solr.update.processor;
>> 
>> public class URLRewriteUpdateRequestProcessorFactory extends
>> UpdateRequestProcessorFactory
>> {
>>    @Override
>>    public UpdateRequestProcessor getInstance(SolrQueryRequest req,
>> SolrQueryResponse rsp, UpdateRequestProcessor next) {
>>        return new URLRewriteProcessor(next);
>>    }
>> }
>> 
>> class URLRewriteProcessor extends UpdateRequestProcessor
>> {
>>    public URLRewriteProcessor(UpdateRequestProcessor next)
>>    {
>>        super(next);
>>    }
>> 
>>    @Override
>>    public void processAdd(AddUpdateCommand cmd) throws IOException
>>    {
>>        SolrInputDocument doc = cmd.getSolrInputDocument();
>>        doc.setField("foo", "bar");
>> 
>>        super.processAdd(cmd);
>>    }
>> }
>> 
>> At this point I am at a loss and would appreciate any assistance or ideas
>> to try.
>> 
>> Cheers
> 
> 
> 
> 
> -- 
> Regards,
> Shalin Shekhar Mangar.


Re: Error Instantiating UpdateRequestProcessorFactory

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
Sounds like a class loader issue. Try adding your jar to $SOLR_HOME/lib
instead of tomcat lib.

Also, upgrade to Solr 4.x, 3.6 is ancient! :)

On Sat, Sep 20, 2014 at 1:13 AM, Allistair C <al...@gmail.com> wrote:

> Hi all,
>
> I’m in a bit of a cul de sac with an issue, hope you can help.
>
> I am creating a custom UpdateRequestProcessor. The Solr documentation
> details that I need to write a factory class subclassing
> UpdateRequestProcessorFactory and this should return an instance of my
> class that subclasses UpdateRequestProcessor.
>
> I have done this, and I have created a JAR.
>
> I have deployed the JAR into Tomcat’s lib folder where Solr is running.
>
> I have modified the solrconfig to include my class correctly.
>
> On startup Solr finds my class but does not believe it conforms to being a
> UpdateRequestProcessorFactory.
>
> SEVERE: org.apache.solr.common.SolrException: Error Instantiating
> UpdateRequestProcessorFactory,
> com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory is
> not a org.apache.solr.update.processor.UpdateRequestProcessorFactory
>         at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:421)
>
> Things I have tried:
>
> - Ensured that I am compiling my JAR with the exact JDK that is running
> Solr.
> - Downloaded Solr 3.6.2 and copied one of the Solr built-in processors,
> renamed it, compiled it and tried to use it - SAME issue.
> - Created a test that uses the same code as the Solr code that is failing
> (namely, isAssignableFrom):
>
>             Class clazz =
> Class.forName("com.acme.solr.update.processor.URLRewriteUpdateRequestProcessorFactory");
>             boolean isA =
> UpdateRequestProcessorFactory.class.isAssignableFrom(clazz);
>             System.out.println(isA);
>
> Print’s “true” - i.e. it’s perfectly OK!
>
> I include my simple processor here:
>
> package com.acme.solr.update.processor;
>
> public class URLRewriteUpdateRequestProcessorFactory extends
> UpdateRequestProcessorFactory
> {
>     @Override
>     public UpdateRequestProcessor getInstance(SolrQueryRequest req,
> SolrQueryResponse rsp, UpdateRequestProcessor next) {
>         return new URLRewriteProcessor(next);
>     }
> }
>
> class URLRewriteProcessor extends UpdateRequestProcessor
> {
>     public URLRewriteProcessor(UpdateRequestProcessor next)
>     {
>         super(next);
>     }
>
>     @Override
>     public void processAdd(AddUpdateCommand cmd) throws IOException
>     {
>         SolrInputDocument doc = cmd.getSolrInputDocument();
>         doc.setField("foo", "bar");
>
>         super.processAdd(cmd);
>     }
> }
>
> At this point I am at a loss and would appreciate any assistance or ideas
> to try.
>
> Cheers




-- 
Regards,
Shalin Shekhar Mangar.