Subclassing custom indexing Java

8 views
Skip to first unread message

Demian Katz

unread,
May 1, 2019, 8:43:21 AM5/1/19
to solrma...@googlegroups.com

Hello,

 

I’m trying to locally subclass a custom method provided with the VuFind core, and I’m running into problems. Not sure if this is a bug in SolrMarc 3.2 (I’m on the latest release), or just something I’m doing wrong.

 

I’m working with the code in this pull request:

 

https://github.com/vufind-org/vufind/pull/1209

 

(This is an effort to share some locally customized code in a more generic way.. but I still need to subclass the generic version locally to reintroduce some institution-specific details).

 

On my test server, the core code I wish to extend is located in /opt/vufind/import/index_java/src/org/vufind/index/MultiFormatCalculator.java and my subclass is located in /opt/vufind/local/import/index_java/src/edu/villanova/index/VillanovaIndexer.java. My subclass code looks like this:

 

package edu.villanova.index;

import org.vufind.index.MultiFormatCalculator;

public class VillanovaIndexer extends MultiFormatCalculator

{

    // ... code ...

}

 

When I try to run an import, though, SolrMarc fails like this:

 

INFO [main] (ValueIndexerFactory.java:117) - Using directory: /opt/vufind/local/import/index_java as location of java sources

INFO [main] (ValueIndexerFactory.java:117) - Using directory: /opt/vufind/import/index_java as location of java sources

INFO [main] (ValueIndexerFactory.java:117) - Using directory: /opt/vufind/local/import/index_java as location of java sources

FATAL [main] (Boot.java:212) - ERROR: Error while invoking main method in specified class: org.solrmarc.driver.IndexDriver

java.lang.RuntimeException:

/opt/vufind/local/import/index_java/src/edu/villanova/index/VillanovaIndexer.java:21: error: package org.vufind.index does not exist

import org.vufind.index.MultiFormatCalculator;

                       ^

/opt/vufind/local/import/index_java/src/edu/villanova/index/VillanovaIndexer.java:29: error: cannot find symbol

public class VillanovaIndexer extends MultiFormatCalculator

                                      ^

  symbol: class MultiFormatCalculator

/opt/vufind/local/import/index_java/src/edu/villanova/index/VillanovaIndexer.java:60: error: cannot find symbol

        String result = super.getFormatFrom007(formatCode, formatCode2, formatCode5);

                        ^

  symbol:   variable super

  location: class edu.villanova.index.VillanovaIndexer

/opt/vufind/local/import/index_java/src/edu/villanova/index/VillanovaIndexer.java:83: error: cannot find symbol

        return getFormats(record);

               ^

  symbol:   method getFormats(org.marc4j.marc.Record)

  location: class edu.villanova.index.VillanovaIndexer

 

Compiling java sources failed!

        at org.solrmarc.index.extractor.impl.java.JavaValueExtractorUtils.compileSources(JavaValueExtractorUtils.java:114)

        at org.solrmarc.index.indexer.ValueIndexerFactory.<init>(ValueIndexerFactory.java:124)

        at org.solrmarc.index.indexer.ValueIndexerFactory.initialize(ValueIndexerFactory.java:76)

        at org.solrmarc.driver.IndexDriver.execute(IndexDriver.java:92)

        at org.solrmarc.driver.IndexDriver.main(IndexDriver.java:69)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at org.solrmarc.driver.Boot.invokeMain(Boot.java:201)

        at org.solrmarc.driver.ConfigDriver.main(ConfigDriver.java:114)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at org.solrmarc.driver.Boot.invokeMain(Boot.java:201)

        at org.solrmarc.driver.Boot.main(Boot.java:74)

 

At the top of the excerpted output above, you can see that SolrMarc is finding both the core and the local source directories… but then for some reason it can’t find the org.vufind.index package. Also, is it cause for concern that the code is finding the local directory twice?

 

If I copy the parent class into the same directory with the child class, then everything works… so I’m guessing it’s some kind of classpath problem… but not sure what the best resolution is.

 

Anyway, curious if this is a known issue or if it’s something I should spend some time digging into. I’m happy to delve into the code if necessary, but I’m asking first in case it saves some time. Any input would be appreciated!

 

thanks,

Demian

 

Haschart, Robert J (rh9ec)

unread,
May 1, 2019, 1:18:04 PM5/1/19
to solrma...@googlegroups.com

Demian,


Its definitely a class path issue.  More specifically a class compilation issue.   One of my first attempts at dynamic compilation for this project ran into problems of A relying on B and B referencing A (IIRC) and not being able to compile either before the other, and needing to lump all of the to-be-compiled classes that reference one another into the same invocation of the compiler.   


It seems that there may be some problem doing that when the source files are in different locations.   I will take a look at it.


-Bob


From: solrma...@googlegroups.com <solrma...@googlegroups.com> on behalf of Demian Katz <demia...@villanova.edu>
Sent: Wednesday, May 1, 2019 8:43:18 AM
To: solrma...@googlegroups.com
Subject: [solrmarc-tech] Subclassing custom indexing Java
 
--
You received this message because you are subscribed to the Google Groups "solrmarc-tech" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrmarc-tec...@googlegroups.com.
To post to this group, send email to solrma...@googlegroups.com.
Visit this group at https://groups.google.com/group/solrmarc-tech.
For more options, visit https://groups.google.com/d/optout.

Demian Katz

unread,
May 1, 2019, 1:19:20 PM5/1/19
to solrma...@googlegroups.com

Thanks, Bob, please let me know if I can help! If you have trouble reproducing the problem, I can send all the offending files, and if you need me to test anything, I’m more than happy to do so.

 

- Demian

Reply all
Reply to author
Forward
0 new messages