You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Saurabh Kumar Singh (JIRA)" <ji...@apache.org> on 2011/09/01 13:00:10 UTC

[jira] [Created] (SOLR-2737) I get ClassCastException when staring tomcat server (Solr configured with Suggester option enabled)

I get ClassCastException when staring tomcat server (Solr configured with Suggester option enabled)
---------------------------------------------------------------------------------------------------

                 Key: SOLR-2737
                 URL: https://issues.apache.org/jira/browse/SOLR-2737
             Project: Solr
          Issue Type: Bug
          Components: spellchecker
    Affects Versions: 3.3
         Environment: Windows 7/Apache Tomcat 7/Solr 3.3/JDK 1.6
            Reporter: Saurabh Kumar Singh


I get the following stack trace on server startup:

Aug 30, 2011 6:37:44 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Float
	at org.apache.solr.spelling.suggest.Suggester.init(Suggester.java:84)
	at org.apache.solr.handler.component.SpellCheckComponent.inform(SpellCheckComponent.java:597)
	at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:522)
	at org.apache.solr.core.SolrCore.<init>(SolrCore.java:594)
	at org.apache.solr.core.CoreContainer.create(CoreContainer.java:463)
	at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
	at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:133)
	at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
	at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
	at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)


Below is the patch for the fix (I did it locally. Please let me know the criteria of how could I check-in the fix :) )

 ### Eclipse Workspace Patch 1.0
#P lucene_solr_3_3
Index: solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
===================================================================
--- solr/src/java/org/apache/solr/spelling/suggest/Suggester.java	(revision 1163940)
+++ solr/src/java/org/apache/solr/spelling/suggest/Suggester.java	(working copy)
@@ -81,8 +81,22 @@
   public String init(NamedList config, SolrCore core) {
     LOG.info("init: " + config);
     String name = super.init(config, core);
-    threshold = config.get(THRESHOLD_TOKEN_FREQUENCY) == null ? 0.0f
-            : (Float)config.get(THRESHOLD_TOKEN_FREQUENCY);
+    Object tokenFrequency = config.get(THRESHOLD_TOKEN_FREQUENCY);  
+    if ( config.get(THRESHOLD_TOKEN_FREQUENCY) == null)
+    {
+    	threshold = 0.0f;
+    }
+    else
+    {
+    	if (tokenFrequency instanceof Number)
+    	{
+    		threshold = (Float)tokenFrequency;
+    	}
+    	else if(tokenFrequency instanceof String)
+    	{
+    		threshold = Float.valueOf((String)tokenFrequency);
+    	}
+    }
     sourceLocation = (String) config.get(LOCATION);
     field = (String)config.get(FIELD);
     lookupImpl = (String)config.get(LOOKUP_IMPL);

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: [jira] [Created] (SOLR-2737) I get ClassCastException when staring tomcat server (Solr configured with Suggester option enabled)

Posted by Erick Erickson <er...@gmail.com>.
The way this usually works is that one of the committers
needs to pick this patch up and commit it to the repository.

To facilitate that, could you please attach the patch file
to the JIRA? There should be a "more actions" and
"attach file".

And if you could, please call the file SOLR-2737.patch

Here is the web page for reference:
http://wiki.apache.org/solr/HowToContribute#Generating_a_patch

Thanks much for doing this work!

Best
Erick

On Thu, Sep 1, 2011 at 7:00 AM, Saurabh Kumar Singh (JIRA)
<ji...@apache.org> wrote:
> I get ClassCastException when staring tomcat server (Solr configured with Suggester option enabled)
> ---------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-2737
>                 URL: https://issues.apache.org/jira/browse/SOLR-2737
>             Project: Solr
>          Issue Type: Bug
>          Components: spellchecker
>    Affects Versions: 3.3
>         Environment: Windows 7/Apache Tomcat 7/Solr 3.3/JDK 1.6
>            Reporter: Saurabh Kumar Singh
>
>
> I get the following stack trace on server startup:
>
> Aug 30, 2011 6:37:44 PM org.apache.solr.common.SolrException log
> SEVERE: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Float
>        at org.apache.solr.spelling.suggest.Suggester.init(Suggester.java:84)
>        at org.apache.solr.handler.component.SpellCheckComponent.inform(SpellCheckComponent.java:597)
>        at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:522)
>        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:594)
>        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:463)
>        at org.apache.solr.core.CoreContainer.load(CoreContainer.java:316)
>        at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:133)
>        at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:94)
>        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
>        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
>        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
>        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
>        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
>        at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
>        at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
>        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:662)
>
>
> Below is the patch for the fix (I did it locally. Please let me know the criteria of how could I check-in the fix :) )
>
>  ### Eclipse Workspace Patch 1.0
> #P lucene_solr_3_3
> Index: solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
> ===================================================================
> --- solr/src/java/org/apache/solr/spelling/suggest/Suggester.java       (revision 1163940)
> +++ solr/src/java/org/apache/solr/spelling/suggest/Suggester.java       (working copy)
> @@ -81,8 +81,22 @@
>   public String init(NamedList config, SolrCore core) {
>     LOG.info("init: " + config);
>     String name = super.init(config, core);
> -    threshold = config.get(THRESHOLD_TOKEN_FREQUENCY) == null ? 0.0f
> -            : (Float)config.get(THRESHOLD_TOKEN_FREQUENCY);
> +    Object tokenFrequency = config.get(THRESHOLD_TOKEN_FREQUENCY);
> +    if ( config.get(THRESHOLD_TOKEN_FREQUENCY) == null)
> +    {
> +       threshold = 0.0f;
> +    }
> +    else
> +    {
> +       if (tokenFrequency instanceof Number)
> +       {
> +               threshold = (Float)tokenFrequency;
> +       }
> +       else if(tokenFrequency instanceof String)
> +       {
> +               threshold = Float.valueOf((String)tokenFrequency);
> +       }
> +    }
>     sourceLocation = (String) config.get(LOCATION);
>     field = (String)config.get(FIELD);
>     lookupImpl = (String)config.get(LOOKUP_IMPL);
>
> --
> This message is automatically generated by JIRA.
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org