monarch-initiative / loinc2hpo

Java library to map LOINC-encoded test results to Human Phenotype Ontology
http://loinc2hpo.readthedocs.io/en/latest/
Other
29 stars 8 forks source link

jena and maven -- build error #16

Closed pnrobinson closed 6 years ago

kingmanzhang commented 6 years ago

@ielis @pnrobinson I forgot what this ticket was originally for, but I encountered a strange error to me with Jena. I can build Jar successfully, and the app works from the IDE. But Jena fails to create hpo for us. The error is in this class: https://github.com/monarch-initiative/loinc2hpo/blob/develop/loinc2hpogui/src/main/java/org/monarchinitiative/loinc2hpo/io/OntologyModelBuilderForJena.java

It starts Line 33, but fails to complete it: [Thread-8] TRACE (OntologyModelBuilderForJena.java:27) - enter function to build ontology model for Sparql query [Thread-8] DEBUG (JenaSystem.java:212) - Jena initialization [Thread-8] DEBUG (SystemTDB.java:334) - System architecture: 64 bit ---Then this thread fails and goes to JavaFx thread, triggering thread failure listener.

What do you think is happening?

kingmanzhang commented 6 years ago

Vida has helped me to pinpoint to the error line. It has nothing to do with thread, but how Jena works. I will do more research on this.

kingmanzhang commented 6 years ago

New suspicion is that Jena is working incorrectly in jar.

From Jar, calling Jena (to build HPO model) terminates here:

[Thread-6] TRACE (OntologyModelBuilderForJena.java:29) - enter function to build ontology model for Sparql query
[Thread-6] DEBUG (JenaSystem.java:212) - Jena initialization
[Thread-6] DEBUG (SystemTDB.java:334) - System architecture: 64 bit

From IDE:

[Thread-6] TRACE (OntologyModelBuilderForJena.java:29) - enter function to build ontology model for Sparql query
[Thread-6] DEBUG (JenaSystem.java:212) - Jena initialization
[Thread-6] TRACE (SystemUtils.java:37) - Using thread classloader
[Thread-6] DEBUG (FileManager.java:158) - Add location: LocatorFile
[Thread-6] DEBUG (FileManager.java:158) - Add location: ClassLoaderLocator
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:location-mapping.rdf
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:location-mapping.rdf
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:location-mapping.n3
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:location-mapping.n3
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:location-mapping.ttl
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:location-mapping.ttl
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:etc/location-mapping.rdf
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:etc/location-mapping.rdf
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:etc/location-mapping.n3
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:etc/location-mapping.n3
[Thread-6] TRACE (LocatorFile.java:112) - Not found: file:etc/location-mapping.ttl
[Thread-6] TRACE (LocatorClassLoader.java:67) - Failed to open: file:etc/location-mapping.ttl
[Thread-6] DEBUG (LocationMapper.java:152) - Failed to find configuration: file:location-mapping.rdf;file:location-mapping.n3;file:location-mapping.ttl;file:etc/location-mapping.rdf;file:etc/location-mapping.n3;file:etc/location-mapping.ttl
[Thread-6] DEBUG (FileManager.java:158) - Add location: LocatorFile
[Thread-6] DEBUG (FileManager.java:158) - Add location: LocatorURL
[Thread-6] DEBUG (FileManager.java:158) - Add location: ClassLoaderLocator
[Thread-6] TRACE (LocatorFile.java:159) - Not found: location-mapping.ttl
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: location-mapping.ttl
[Thread-6] TRACE (LocatorFile.java:159) - Not found: location-mapping.rdf
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: location-mapping.rdf
[Thread-6] TRACE (LocatorFile.java:159) - Not found: location-mapping.n3
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: location-mapping.n3
[Thread-6] TRACE (LocatorFile.java:159) - Not found: etc/location-mapping.rdf
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: etc/location-mapping.rdf
[Thread-6] TRACE (LocatorFile.java:159) - Not found: etc/location-mapping.n3
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: etc/location-mapping.n3
[Thread-6] TRACE (LocatorFile.java:159) - Not found: etc/location-mapping.ttl
[Thread-6] TRACE (LocatorClassLoader.java:65) - Failed to open: etc/location-mapping.ttl
[Thread-6] DEBUG (JenaIOEnvironment.java:180) - Failed to find configuration: location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
[Thread-6] DEBUG (SystemTDB.java:334) - System architecture: 64 bit

So It appears Jena fails to execute many codes... Let's discuss this on Monday @pnrobinson

pnrobinson commented 6 years ago

Hi Aaron -- I do not think those Jena warnings are critical, I am seeing something like them with another program that uses Jena, and the level is TRACE or DEBUG only. If you put a logger.trace right after the line in question, do you see it? Also, try the debugger, get it to go into the function. We can discuss on Monday!

kingmanzhang commented 6 years ago

@pnrobinson Okay, we finally have a fix. Here is the solution:

  1. Apparently we need to explicitly tell Jar how we want to initiate Jena. So write a class that implements Jena interface JenaSubsystemLifecycle
  2. Add a plugin to pom file

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <configuration>
        <shadedArtifactAttached>false</shadedArtifactAttached>
        <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
        </transformers>
    
    </configuration>
    </plugin>
  3. In Java resource folder, create a file under META-INF-services named "org.apache.jena.system.JenaSubsystemLifecycle", within the file put in the class created in step 1.

Now it should work, although I'm still quite confused of all the stuff!