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 Ming Liang <up...@gmail.com> on 2015/06/27 16:59:58 UTC

Solr-5.2.1 ClassNotFound - solr.HMMChineseTokenizerFactory

I am using Solr-5.2.1
I tried to add a field type named "text_chinese"  to the schema.xml of the
given guide example "techproducts":


<fieldType name="text_chinese" class="solr.TextField"
           positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.HMMChineseTokenizerFactory"/>
        <filter class="solr.StopFilterFactory"
                words="org/apache/lucene/analysis/cn/smart/stopwords.txt"/>
        <filter class="solr.PorterStemFilterFactory"/>
    </analyzer>
</fieldType>

when I start "techproducts" with command "bin/solr -e techproducts"

I got error:

Waiting to see Solr listening on port 8983 [/]

Started Solr server on port 8983 (pid=7232). Happy searching!

Setup new core instance directory:

........./solr-5.2.1/example/techproducts/solr/techproducts

Creating new core 'techproducts' using command:

http://localhost:8983/solr/admin/cores?action=CREATE&name=techproducts&instanceDir=techproducts

*Failed to create core 'techproducts' due to: Error CREATEing SolrCore
'techproducts': Unable to create core [techproducts] Caused by:
solr.HMMChineseTokenizerFactory*

and I found the following logs in log file:
solr-5.2.1/example/techproducts/logs/solr.log

Caused by: java.lang.ClassNotFoundException: solr.HMMChineseTokenizerFactory

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:348)

at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)

... 44 more
I have tried to change

<tokenizer class="solr.HMMChineseTokenizerFactory"/>

to

<tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>

because I found a class named HMMChineseTokenizerFactory in package
org.apache.lucene.analysis.cn.smart
but I the class is still not found:

Caused by: java.lang.ClassNotFoundException:
org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at
org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
... 44 more

thanks

Re: Solr-5.2.1 ClassNotFound - solr.HMMChineseTokenizerFactory

Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/27/2015 6:05 PM, Ming Liang wrote:
> Sorry,
>    I have solved the problem by coping the necessary libs from
> "solr/contrib/analysis-extras"
> to"solr/server/solr-webapp/webapp/WEB-INF/lib" .
> I didn't realise that solr-webapp is the true "solr-home"

That's not the solr home.

solr-webapp is where the WAR file is extracted by Jetty.  This location
is subject to removal and/or change at any time, it is not a good place
to drop additional jars.  It does WORK, but it's not a good place.

If you are using the downloaded artifacts and the bin/solr script in a
non-cloud way, then the solr home will be server/solr.  You should
create server/solr/lib and put extra jars there.

If you're running a cloud example, then the solr home will be different
for each node in the cloud.  The following page has info about how to
start the individual solr nodes once the cloud example has created them:

https://cwiki.apache.org/confluence/display/solr/Getting+Started+with+SolrCloud

Here is one of those commands that you can find on that page:

solr start -cloud -s example/cloud/node1/solr -p 8983

As you can see, the -s option (which sets the solr home) is used.

Thanks,
Shawn


Re: Solr-5.2.1 ClassNotFound - solr.HMMChineseTokenizerFactory

Posted by Ming Liang <up...@gmail.com>.
Sorry,
   I have solved the problem by coping the necessary libs from
"solr/contrib/analysis-extras"
to"solr/server/solr-webapp/webapp/WEB-INF/lib" .
I didn't realise that solr-webapp is the true "solr-home"

thanks


2015-06-27 22:59 GMT+08:00 Ming Liang <up...@gmail.com>:

> I am using Solr-5.2.1
> I tried to add a field type named "text_chinese"  to the schema.xml of the
> given guide example "techproducts":
>
>
> <fieldType name="text_chinese" class="solr.TextField"
>            positionIncrementGap="100">
>     <analyzer>
>         <tokenizer class="solr.HMMChineseTokenizerFactory"/>
>         <filter class="solr.StopFilterFactory"
>                 words="org/apache/lucene/analysis/cn/smart/stopwords.txt"/>
>         <filter class="solr.PorterStemFilterFactory"/>
>     </analyzer>
> </fieldType>
>
> when I start "techproducts" with command "bin/solr -e techproducts"
>
> I got error:
>
> Waiting to see Solr listening on port 8983 [/]
>
> Started Solr server on port 8983 (pid=7232). Happy searching!
>
> Setup new core instance directory:
>
> ........./solr-5.2.1/example/techproducts/solr/techproducts
>
> Creating new core 'techproducts' using command:
>
>
> http://localhost:8983/solr/admin/cores?action=CREATE&name=techproducts&instanceDir=techproducts
>
> *Failed to create core 'techproducts' due to: Error CREATEing SolrCore
> 'techproducts': Unable to create core [techproducts] Caused by:
> solr.HMMChineseTokenizerFactory*
>
> and I found the following logs in log file:
> solr-5.2.1/example/techproducts/logs/solr.log
>
> Caused by: java.lang.ClassNotFoundException:
> solr.HMMChineseTokenizerFactory
>
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>
> at java.lang.Class.forName0(Native Method)
>
> at java.lang.Class.forName(Class.java:348)
>
> at
> org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
>
> ... 44 more
> I have tried to change
>
> <tokenizer class="solr.HMMChineseTokenizerFactory"/>
>
> to
>
> <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
>
> because I found a class named HMMChineseTokenizerFactory in package
> org.apache.lucene.analysis.cn.smart
> but I the class is still not found:
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:348)
> at
> org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
> ... 44 more
>
> thanks
>
>


-- 
生活如此美好

Re: Solr-5.2.1 ClassNotFound - solr.HMMChineseTokenizerFactory

Posted by Erick Erickson <er...@gmail.com>.
Packaging is always "interesting":

It's in ./contrib/analysis-extras/lucene-libs/lucene-analyzers-smartcn-5.2.0.jar

and you'll have to either move it to a place "known" by Solr or set up
a <lib....
directive in solrconfig.xml.

I used this:
 <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>

Best,
Erick


On Sat, Jun 27, 2015 at 10:59 AM, Ming Liang <up...@gmail.com> wrote:
> I am using Solr-5.2.1
> I tried to add a field type named "text_chinese"  to the schema.xml of the
> given guide example "techproducts":
>
>
> <fieldType name="text_chinese" class="solr.TextField"
>            positionIncrementGap="100">
>     <analyzer>
>         <tokenizer class="solr.HMMChineseTokenizerFactory"/>
>         <filter class="solr.StopFilterFactory"
>                 words="org/apache/lucene/analysis/cn/smart/stopwords.txt"/>
>         <filter class="solr.PorterStemFilterFactory"/>
>     </analyzer>
> </fieldType>
>
> when I start "techproducts" with command "bin/solr -e techproducts"
>
> I got error:
>
> Waiting to see Solr listening on port 8983 [/]
>
> Started Solr server on port 8983 (pid=7232). Happy searching!
>
> Setup new core instance directory:
>
> ........./solr-5.2.1/example/techproducts/solr/techproducts
>
> Creating new core 'techproducts' using command:
>
> http://localhost:8983/solr/admin/cores?action=CREATE&name=techproducts&instanceDir=techproducts
>
> *Failed to create core 'techproducts' due to: Error CREATEing SolrCore
> 'techproducts': Unable to create core [techproducts] Caused by:
> solr.HMMChineseTokenizerFactory*
>
> and I found the following logs in log file:
> solr-5.2.1/example/techproducts/logs/solr.log
>
> Caused by: java.lang.ClassNotFoundException: solr.HMMChineseTokenizerFactory
>
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>
> at java.lang.Class.forName0(Native Method)
>
> at java.lang.Class.forName(Class.java:348)
>
> at
> org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
>
> ... 44 more
> I have tried to change
>
> <tokenizer class="solr.HMMChineseTokenizerFactory"/>
>
> to
>
> <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
>
> because I found a class named HMMChineseTokenizerFactory in package
> org.apache.lucene.analysis.cn.smart
> but I the class is still not found:
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:810)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:348)
> at
> org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:475)
> ... 44 more
>
> thanks