Hi Andy,

Thank you so much for the help. Now problem solved!

Best,
Xingmin

On Mon, Feb 26, 2018 at 9:00 AM, Andy Seaborne <[email protected]> wrote:

>
>
> On 26/02/18 13:41, Xingmin Zhang wrote:
>
>> Sorry, I accidentally hit Send button before I finished my email...
>>
>> Here is the complete one
>> ---------- Forwarded message ----------
>> From: Xingmin Zhang <[email protected]>
>> Date: Mon, Feb 26, 2018 at 8:32 AM
>> Subject: Jena not working from Jar file
>> To: [email protected]
>>
>>
>> Hi all,
>>
>> I used Jena to load an .owl ontology to the default model for Sparql query
>> and it works well from IntelliJ IDE, however, the Jar file built from the
>> source code has a problem initiating Jena.
>>
>
> If you are repacking into a single jar, check:
>
> https://jena.apache.org/documentation/notes/jena-repack.html
>
> https://jena.apache.org/documentation/notes/system-initialization.html
>
>
>
>
>> Here is the function that has issues
>>
>> protected Model call() throws Exception {
>>
>>      logger.trace("enter function to build ontology model for Sparql
>> query");
>>
>>      org.apache.jena.rdf.model.Model model =
>> ModelFactory.createDefaultModel();
>>
>>      logger.info("default ontology model created");
>>      try {
>>          logger.trace("start reading hpo");
>>          InputStream in = FileManager.get().open(pathToOntology);
>>          model.read(in, null);
>>
>
>
> RDFDataMgr will use the global StreamManager so
>
> RDFDataMgr.read(model, pathToOntology);
>
> should work subject to the jar being packed correctly.
>
> StreamManager is better.  FileManager is legacy.
>
>      } catch (JenaException je) {
>>          logger.error("cannot open hpo.owl");
>>      }
>>      logger.trace("exit function to build ontology model for Sparql
>> query.");
>>      return model;
>>
>> }
>>
>> You can see that from my IDE, the loggers indicates that the function
>> completes running successfully.
>>
> ...
>
> <dependency>
>>      <groupId>org.apache.jena</groupId>
>>      <artifactId>apache-jena-libs</artifactId>
>>      <type>pom</type>
>>      <version>3.6.0</version>
>> </dependency>
>>
>
> Do you have assembly or shade in the POM?
>
> The shade plug-in manages service files. See the jena-fuseki-server pom
> file for an example.
>
>
>>
>> Best,
>> Xingmin Zhang
>>
>>


--

Reply via email to