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 Zahra Aminolroaya <z....@gmail.com> on 2018/06/24 12:07:46 UTC

Error in solr Plugin

I am using solr 6.6.1. I want to write my own analyzer for the field type
"text_general" in schema. the field type in schema is as follows:
  <fieldType name="text_general" class="solr.TextField"
positionIncrementGap="100" multiValued="true">
    <analyzer type="index">
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.StopFilterFactory" words="stopwords.txt"
ignoreCase="true"/>
      <filter class="solr.LowerCaseFilterFactory"/>
	  <filter class="normalizing.myNormalizerFilterFactory" />
    </analyzer>
When I test the filter in Java, everything is alright; However, when I start
my solr I get the following error:

Caused by: java.lang.ClassCastException: class
normalizing.myNormalizerFilterFactory
	at java.lang.Class.asSubclass(Unknown Source)
	at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:539)
	at
org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:624)
	at
org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:397)
	at
org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:390)
	at
org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:152)
	... 20 more

I used the jar files in my lib as follows: solr-core-4.1.0, 
slf4j-api-1.6.6, lucene-core-7.4.0, apache-solr-core-1.4.0, apache-lucene.

Why do I get this error? Is it becuase of the wrong jar file versions
especially the lucene-core-7.4.0 as my lucene version is 6.6.1?



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: Error in solr Plugin

Posted by Zahra Aminolroaya <z....@gmail.com>.
Thanks Andrea and Erick



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: Error in solr Plugin

Posted by Erick Erickson <er...@gmail.com>.
bq.  The lucene-core7 had some useful functions like  incrementToken which I
could not find in previous versions because of that I used this version.

Do not do this. You simply cannot mix jar versions because there was a
function in the old
version that you want to use. The support for that function has been
removed, which is why
you can't find it.

Worse, there's no guarantee that everything necessary to support that
function is
in a single jar file.

You must work with a single version of Solr jars and figure out how
you can get the same or
equivalent functionality with the new code.

Best,
Erick

On Sun, Jun 24, 2018 at 6:33 AM, Andrea Gazzarini <a....@sease.io> wrote:
> Hi,
> I mean you should use Maven which would pickup, starting from a number (e.g.
> 6.6.1), all the correct dependencies you need for developing the plugin.
> Yes, the "top" libraries (e.g. Solr and Lucene) should have the same version
> but on top of that, the plugin could require some other direct or indirect
> dependency, and here there's no a magic rule for determining which version
> of such dependency you would need. So again: please use Maven (or Gradle).
>
> About the second point: generally speaking, if you're targeting Solr 6.6.1
> your plugin will live in that context, with all the beauties coming with the
> 6.6.1 version. And here, you can imagine why you cannot use something that
> is not yet there, something that will be implemented in a later version.
>
> On top of that, if you meant the TokenStream.incrementToken method please
> check better: this is part of the core Lucene API and unless I didn't get
> you, you will find it also in past versions.
>
> Best,
> Andrea
>
>
> On 24/06/18 14:35, Zahra Aminolroaya wrote:
>>
>> Thanks Andrea. Do you mean all of my jar file versions should be 6.6.1?
>>
>> The lucene-core7 had some useful functions like  incrementToken which I
>> could not find in previous versions because of that I used this version.
>>
>>
>>
>> --
>> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>
>

Re: Error in solr Plugin

Posted by Andrea Gazzarini <a....@sease.io>.
Hi,
I mean you should use Maven which would pickup, starting from a number 
(e.g. 6.6.1), all the correct dependencies you need for developing the 
plugin.
Yes, the "top" libraries (e.g. Solr and Lucene) should have the same 
version but on top of that, the plugin could require some other direct 
or indirect dependency, and here there's no a magic rule for determining 
which version of such dependency you would need. So again: please use 
Maven (or Gradle).

About the second point: generally speaking, if you're targeting Solr 
6.6.1 your plugin will live in that context, with all the beauties 
coming with the 6.6.1 version. And here, you can imagine why you cannot 
use something that is not yet there, something that will be implemented 
in a later version.

On top of that, if you meant the TokenStream.incrementToken method 
please check better: this is part of the core Lucene API and unless I 
didn't get you, you will find it also in past versions.

Best,
Andrea

On 24/06/18 14:35, Zahra Aminolroaya wrote:
> Thanks Andrea. Do you mean all of my jar file versions should be 6.6.1?
>
> The lucene-core7 had some useful functions like  incrementToken which I
> could not find in previous versions because of that I used this version.
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html


Re: Error in solr Plugin

Posted by Zahra Aminolroaya <z....@gmail.com>.
Thanks Andrea. Do you mean all of my jar file versions should be 6.6.1? 

The lucene-core7 had some useful functions like  incrementToken which I
could not find in previous versions because of that I used this version.



--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html

Re: Error in solr Plugin

Posted by Andrea Gazzarini <a....@sease.io>.
Hi Zahra,
I think your guessing it's right: I see some mess in libraries versions. 
If I got you

  * the target platform is Solr 6.6.1
  * the compile classpath includes solr-core-4.1.0, 1.4.0 (!) and lucene
    7.4.0?

If that is correct, with a ClassCastException you're just scraping the 
surface of all errors you can get :) As a rule of thumb you should 
always work with the same version of the target Solr (because that 
version will be the runtime container of your plugin).

I suggest you to avoid putting libraries manually in the classpath; you 
should use a dependency management tool like Maven or Gradle, set the 
target Solr version once and have the required dependencies 
automatically set up.

Let me know if you need some help with the last point.

Best,
Andrea

On 24/06/18 14:07, Zahra Aminolroaya wrote:
> I am using solr 6.6.1. I want to write my own analyzer for the field type
> "text_general" in schema. the field type in schema is as follows:
>    <fieldType name="text_general" class="solr.TextField"
> positionIncrementGap="100" multiValued="true">
>      <analyzer type="index">
>        <tokenizer class="solr.StandardTokenizerFactory"/>
>        <filter class="solr.StopFilterFactory" words="stopwords.txt"
> ignoreCase="true"/>
>        <filter class="solr.LowerCaseFilterFactory"/>
> 	  <filter class="normalizing.myNormalizerFilterFactory" />
>      </analyzer>
> When I test the filter in Java, everything is alright; However, when I start
> my solr I get the following error:
>
> Caused by: java.lang.ClassCastException: class
> normalizing.myNormalizerFilterFactory
> 	at java.lang.Class.asSubclass(Unknown Source)
> 	at
> org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:539)
> 	at
> org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:624)
> 	at
> org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:397)
> 	at
> org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:390)
> 	at
> org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:152)
> 	... 20 more
>
> I used the jar files in my lib as follows: solr-core-4.1.0,
> slf4j-api-1.6.6, lucene-core-7.4.0, apache-solr-core-1.4.0, apache-lucene.
>
> Why do I get this error? Is it becuase of the wrong jar file versions
> especially the lucene-core-7.4.0 as my lucene version is 6.6.1?
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html