Re: Debugging custom RequestHander: spinning up a core for debugging

2017-12-22 Thread Tod Olson
Thanks, that pointed me in the right direction! The problem was an ancient ICU 
library in the distributed code.

-Tod

On Dec 15, 2017, at 5:15 PM, Erick Erickson 
<erickerick...@gmail.com<mailto:erickerick...@gmail.com>> wrote:

My guess is this isn't a Solr issue at all; you are somehow using an old Java.

RBBIDataWrapper is from

com.ibm.icu.text;

I saw on a quick Google that this was cured by re-installing Eclipse,
but that was from 5 years ago.

You say your Java and IDE skills are a bit rusty, maybe you haven't
updated your Java JDK or Eclipse in a while? I don't know if Eclipse
somehow has its own Java (I haven't used Eclipse for quite a while).

I take it this runs outside Eclipse OK? (well, with problems otherwise
you wouldn't be stepping through it.)

Best,
Erick

On Fri, Dec 15, 2017 at 1:16 PM, Tod Olson 
<t...@uchicago.edu<mailto:t...@uchicago.edu>> wrote:
Hi everyone,

I need to do some step-wise debugging on a custom RequestHandler. I'm trying to 
spin up a core in a Junit test, with the idea of running it inside of Eclipse 
for debugging. (If there's an easier way, I'd like to see a walk through!) 
Problem is the core fails to spin up with:

java.io.IOException: Break Iterator Rule Data Magic Number Incorrect, or 
unsupported data version

Here's the code, just trying to load (cribbed and adapted from 
https://stackoverflow.com/questions/45506381/how-to-debug-solr-plugin):

public class BrowseHandlerTest
{
   private static CoreContainer container;
   private static SolrCore core;

   private static final Logger logger = Logger.getGlobal();



   @BeforeClass
   public static void prepareClass() throws Exception
   {
   String solrHomeProp = "solr.solr.home";
   System.out.println(solrHomeProp + "= " + 
System.getProperty(solrHomeProp));
   // create the core container from the solr.solr.home system property
   container = new CoreContainer();
   container.load();
   core = container.getCore("biblio");
   
logger.info<http://logger.info/><http://logger.info<http://logger.info/>>("Solr 
core loaded!");
   }

   @AfterClass
   public static void cleanUpClass()
   {
   core.close();
   container.shutdown();
   
logger.info<http://logger.info/><http://logger.info<http://logger.info/>>("Solr 
core shut down!");
   }
}

The test, run through ant, fails as follows:

   [junit] solr.solr.home= /Users/tod/src/vufind/solr/vufind
   [junit] SLF4J: Defaulting to no-operation (NOP) logger implementation
   [junit] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for 
further details.
   [junit] SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
   [junit] SLF4J: Defaulting to no-operation MDCAdapter implementation.
   [junit] SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for 
further details.
   [junit] Tests run: 0, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 
1.299 sec
   [junit]
   [junit] - Standard Error -
   [junit] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
   [junit] SLF4J: Defaulting to no-operation (NOP) logger implementation
   [junit] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for 
further details.
   [junit] SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
   [junit] SLF4J: Defaulting to no-operation MDCAdapter implementation.
   [junit] SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for 
further details.
   [junit] -  ---
   [junit] Testcase: org.vufind.solr.handler.tests.BrowseHandlerTest: Caused an 
ERROR
   [junit] SolrCore 'biblio' is not available due to init failure: JVM Error 
creating core [biblio]: null
   [junit] org.apache.solr.common.SolrException: SolrCore 'biblio' is not 
available due to init failure: JVM Error creating core [biblio]: null
   [junit]  at 
org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1066)
   [junit]  at 
org.vufind.solr.handler.tests.BrowseHandlerTest.prepareClass(BrowseHandlerTest.java:45)
   [junit] Caused by: org.apache.solr.common.SolrException: JVM Error creating 
core [biblio]: null
   [junit]  at org.apache.solr.core.CoreContainer.create(CoreContainer.java:833)
   [junit]  at 
org.apache.solr.core.CoreContainer.access$000(CoreContainer.java:87)
   [junit]  at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:467)
   [junit]  at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:458)
   [junit]  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   [junit]  at 
org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:231)
   [junit]  at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   [junit]  at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolE

Debugging custom RequestHander: spinning up a core for debugging

2017-12-15 Thread Tod Olson
n: Break 
Iterator Rule Data Magic Number Incorrect, or unsupported data version.
[junit]  at 
org.apache.lucene.analysis.icu.segmentation.DefaultICUTokenizerConfig.readBreakIterator(DefaultICUTokenizerConfig.java:125)
[junit]  at 
org.apache.lucene.analysis.icu.segmentation.DefaultICUTokenizerConfig.(DefaultICUTokenizerConfig.java:66)
[junit] Caused by: java.io.IOException: Break Iterator Rule Data Magic 
Number Incorrect, or unsupported data version.
[junit]  at com.ibm.icu.text.RBBIDataWrapper.get(RBBIDataWrapper.java:193)
[junit]  at 
com.ibm.icu.text.RuleBasedBreakIterator.getInstanceFromCompiledRules(RuleBasedBreakIterator.java:57)
[junit]  at 
org.apache.lucene.analysis.icu.segmentation.DefaultICUTokenizerConfig.readBreakIterator(DefaultICUTokenizerConfig.java:120)
[junit]
[junit]
[junit] Testcase: org.vufind.solr.handler.tests.BrowseHandlerTest: Caused 
an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit]  at 
org.vufind.solr.handler.tests.BrowseHandlerTest.cleanUpClass(BrowseHandlerTest.java:52)
[junit]
[junit]
[junit] Test org.vufind.solr.handler.tests.BrowseHandlerTest FAILED

This is the directory structure:

.../solr/vufind/
authority/
   conf/
   core.properties
biblio/
   conf/
   core.properties
   index/
solr.xml

The solr.solr.home property is set to the solr/vufind directory, and I need to 
load the biblio core. I don't get to dig into code very often, so my Java and 
IDE skills are a bit rusty.

Any advice is welcome, whether how to fix or an alternate approach.

Best,

-Tod

Tod Olson <t...@uchicago.edu<mailto:t...@uchicago.edu>>
Systems Librarian
Interim Director for Integrated Library Systems
University of Chicago Library



Re: Compile problems with anonymous SimpleCollector in custom request handler

2017-11-30 Thread Tod Olson
Shawn,

Thanks for the response! Yes, that was it, an older version unexpectedly in the 
classpath.

And for the benefit of anyone who searches the list archive with a similar 
debugging need, it's pretty easy to print out the classpath from ant's 
build.xml:

  






  
  
  
  Classpath: ${classpathProp}


-Tod

On Nov 29, 2017, at 6:00 PM, Shawn Heisey 
<apa...@elyograg.org<mailto:apa...@elyograg.org>> wrote:

On 11/29/2017 2:27 PM, Tod Olson wrote:
I'm modifying a existing custom request handler for an open source project, and 
am looking for some help with a compile error around an anonymous 
SimpleCollector. The build failure message from ant and the source of the 
specific method are below. I am compiling on a Mac with Java 1.8 and Solr 
6.4.2. There are two things I do not understand.

First:
   [javac] 
/Users/tod/src/vufind-browse-handler/browse-handler/java/org/vufind/solr/handler/BrowseRequestHandler.java:445:
 error:  is not abstract and does 
not override abstract method setNextReader(AtomicReaderContext) in Collector
   [javac] db.search(q, new SimpleCollector() {

Based on the javadoc, neither SimpleCollector nor Collector define a 
setNextReader(AtomicReaderContext) method. Grepping through the Lucene 6.4.2 
source reveals neither a setNextReader method (though maybe a couple archaic 
comments), nor an AtomicReaderContext class or interface.



Second:
   [javac] method IndexSearcher.search(Query,Collector) is not applicable
   [javac]   (argument mismatch;  cannot be 
converted to Collector)

How is it that SimpleCollector cannot be converted to Collector? Perhaps this 
is just a consequence of the first error.

For the first error:  What version of Solr/Lucene are you compiling
against?  I have found that Collector *did* have a setNextReader method
up through Lucene 4.10.4, but in 5.0, that method was gone.  I suspect
that what's causing your first problem is that you have older Lucene
jars (4.x or earlier) on your classpath, in addition to a newer version
that you actually want to use for the compile.

I think that can also explain the second problem.  It looks like
SimpleCollector didn't exist in Lucene 4.10, which is the last version
where Collector had setNextReader.  SimpleCollector is mentioned in the
javadoc for Collector as of 5.0, though.

Thanks,
Shawn





Compile problems with anonymous SimpleCollector in custom request handler

2017-11-29 Thread Tod Olson
Hi everyone,

I'm modifying a existing custom request handler for an open source project, and 
am looking for some help with a compile error around an anonymous 
SimpleCollector. The build failure message from ant and the source of the 
specific method are below. I am compiling on a Mac with Java 1.8 and Solr 
6.4.2. There are two things I do not understand.

First:
[javac] 
/Users/tod/src/vufind-browse-handler/browse-handler/java/org/vufind/solr/handler/BrowseRequestHandler.java:445:
 error:  is not abstract and does 
not override abstract method setNextReader(AtomicReaderContext) in Collector
[javac] db.search(q, new SimpleCollector() {

Based on the javadoc, neither SimpleCollector nor Collector define a 
setNextReader(AtomicReaderContext) method. Grepping through the Lucene 6.4.2 
source reveals neither a setNextReader method (though maybe a couple archaic 
comments), nor an AtomicReaderContext class or interface.

Second:
[javac] method IndexSearcher.search(Query,Collector) is not applicable
[javac]   (argument mismatch;  cannot be 
converted to Collector)

How is it that SimpleCollector cannot be converted to Collector? Perhaps this 
is just a consequence of the first error.

Any help getting past this compile problem would be most welcome!

-Tod




Build failure message:

build-handler:
[mkdir] Created dir: 
/Users/tod/src/vufind-browse-handler/build/browse-handler
[javac] Compiling 1 source file to 
/Users/tod/src/vufind-browse-handler/build/browse-handler
[javac] 
/Users/tod/src/vufind-browse-handler/browse-handler/java/org/vufind/solr/handler/BrowseRequestHandler.java:445:
 error:  is not abstract and does 
not override abstract method setNextReader(AtomicReaderContext) in Collector
[javac] db.search(q, new SimpleCollector() {
[javac]^
[javac] 
/Users/tod/src/vufind-browse-handler/browse-handler/java/org/vufind/solr/handler/BrowseRequestHandler.java:445:
 error: no suitable method found for search(TermQuery,)
[javac] db.search(q, new SimpleCollector() {
[javac]   ^
[javac] method IndexSearcher.search(Query,int) is not applicable
[javac]   (argument mismatch;  cannot be 
converted to int)
[javac] method IndexSearcher.search(Query,Filter,int) is not applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method IndexSearcher.search(Query,Filter,Collector) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method IndexSearcher.search(Query,Collector) is not applicable
[javac]   (argument mismatch;  cannot be 
converted to Collector)
[javac] method IndexSearcher.search(Query,Filter,int,Sort) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method 
IndexSearcher.search(Query,Filter,int,Sort,boolean,boolean) is not applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method IndexSearcher.search(Query,int,Sort) is not applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method IndexSearcher.search(Weight,ScoreDoc,int) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method 
IndexSearcher.search(List,Weight,ScoreDoc,int) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method IndexSearcher.search(Weight,int,Sort,boolean,boolean) is 
not applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method 
IndexSearcher.search(Weight,FieldDoc,int,Sort,boolean,boolean,boolean) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method 
IndexSearcher.search(List,Weight,FieldDoc,int,Sort,boolean,boolean,boolean)
 is not applicable
[javac]   (actual and formal argument lists differ in length)
[javac] method 
IndexSearcher.search(List,Weight,Collector) is not 
applicable
[javac]   (actual and formal argument lists differ in length)
[javac] 2 errors


Problem method:

/**
 *
 * Function to retrieve the doc ids when there is a building limit
 * This retrieves the doc ids for an individual heading
 *
 * Need to add a filter query to limit the results from Solr
 *
 * Includes functionality to retrieve additional info
 * like titles for call numbers, possibly ISBNs
 *
 * @param headingstring of the heading to use for finding matching
 * @param fields docs colon-separated string of Solr fields
 *   to return for use in the browse display
 * @param maxBibListSize maximum numbers of records to check for fields
 * @return return a map of Solr ids and extra bib info
 */
public