You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Piotr Hołubowicz (JIRA)" <ji...@apache.org> on 2013/08/09 14:48:48 UTC

[jira] [Comment Edited] (JENA-505) NPE in the OWL class

    [ https://issues.apache.org/jira/browse/JENA-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13734716#comment-13734716 ] 

Piotr Hołubowicz edited comment on JENA-505 at 8/9/13 12:47 PM:
----------------------------------------------------------------

I have attached a small example that reproduces the problem. I must actually correct myself, as the NPE is not triggered by the FileManager#loadModel method, but rather by DatasetFactory#createMem. The stack trace is not printed and only a warning appears in the logs, but it is a NPE with the trace as below.

{code}
com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:67), 
com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:33), 
com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:116), 
com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:81), 
com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274), 
com.hp.hpl.jena.util.LocationMapper.initFromPath(LocationMapper.java:158), 
com.hp.hpl.jena.util.LocationMapper.get(LocationMapper.java:71), 
com.hp.hpl.jena.util.FileManager.makeGlobal(FileManager.java:122), 
com.hp.hpl.jena.util.FileManager.get(FileManager.java:88), 
org.apache.jena.riot.IO_Jena.wireIntoJena(IO_Jena.java:38), 
org.apache.jena.riot.RIOT.init(RIOT.java:72), 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), 
java.lang.reflect.Method.invoke(Method.java:601), 
com.hp.hpl.jena.rdf.model.impl.IO_Ctl.callByRefection(IO_Ctl.java:64), 
com.hp.hpl.jena.rdf.model.impl.IO_Ctl.init(IO_Ctl.java:36), 
com.hp.hpl.jena.rdf.model.impl.ModelCom.<clinit>(ModelCom.java:63), 
com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory.java:140), 
com.hp.hpl.jena.vocabulary.OWL.<clinit>(OWL.java:36), 
com.hp.hpl.jena.sparql.ARQConstants.<clinit>(ARQConstants.java:44), 
com.hp.hpl.jena.query.ARQ.<clinit>(ARQ.java:71), 
com.hp.hpl.jena.sparql.graph.GraphFactory.<clinit>(GraphFactory.java:35), 
com.hp.hpl.jena.sparql.core.DatasetGraphFactory$2.create(DatasetGraphFactory.java:86), com.hp.hpl.jena.sparql.core.DatasetGraphMaker.<init>(DatasetGraphMaker.java:34), com.hp.hpl.jena.sparql.core.DatasetGraphFactory.createMem(DatasetGraphFactory.java:94), 
com.hp.hpl.jena.query.DatasetFactory.createMem(DatasetFactory.java:42)
{code}

I thought it was the FileManager#loadModel method because this method actually throws an exception to my code. The failing DatasetFactory#createMem method on the other hand only prints:

2013.08.09 14:21:00 [main] LocationMapper WARN: Error in configuration file: null
                
      was (Author: piotrekhol):
    I have attached a small example that reproduces the problem. I must actually correct myself, as the NPE is not triggered by the FileManager#loadModel method, but rather by DatasetFactory#createMem. The stack trace is not printed but only the message (null) but it is as below.

{code}
com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:67), 
com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:33), 
com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:116), 
com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:81), 
com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274), 
com.hp.hpl.jena.util.LocationMapper.initFromPath(LocationMapper.java:158), 
com.hp.hpl.jena.util.LocationMapper.get(LocationMapper.java:71), 
com.hp.hpl.jena.util.FileManager.makeGlobal(FileManager.java:122), 
com.hp.hpl.jena.util.FileManager.get(FileManager.java:88), 
org.apache.jena.riot.IO_Jena.wireIntoJena(IO_Jena.java:38), 
org.apache.jena.riot.RIOT.init(RIOT.java:72), 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), 
java.lang.reflect.Method.invoke(Method.java:601), 
com.hp.hpl.jena.rdf.model.impl.IO_Ctl.callByRefection(IO_Ctl.java:64), 
com.hp.hpl.jena.rdf.model.impl.IO_Ctl.init(IO_Ctl.java:36), 
com.hp.hpl.jena.rdf.model.impl.ModelCom.<clinit>(ModelCom.java:63), 
com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory.java:140), 
com.hp.hpl.jena.vocabulary.OWL.<clinit>(OWL.java:36), 
com.hp.hpl.jena.sparql.ARQConstants.<clinit>(ARQConstants.java:44), 
com.hp.hpl.jena.query.ARQ.<clinit>(ARQ.java:71), 
com.hp.hpl.jena.sparql.graph.GraphFactory.<clinit>(GraphFactory.java:35), 
com.hp.hpl.jena.sparql.core.DatasetGraphFactory$2.create(DatasetGraphFactory.java:86), com.hp.hpl.jena.sparql.core.DatasetGraphMaker.<init>(DatasetGraphMaker.java:34), com.hp.hpl.jena.sparql.core.DatasetGraphFactory.createMem(DatasetGraphFactory.java:94), 
com.hp.hpl.jena.query.DatasetFactory.createMem(DatasetFactory.java:42)
{code}

I thought it was the FileManager#loadModel method because this method actually throws an exception to my code. The failing DatasetFactory#createMem method on the other hand only prints:

2013.08.09 14:21:00 [main] LocationMapper WARN: Error in configuration file: null
                  
> NPE in the OWL class
> --------------------
>
>                 Key: JENA-505
>                 URL: https://issues.apache.org/jira/browse/JENA-505
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Jena
>    Affects Versions: Jena 2.10.1
>            Reporter: Piotr Hołubowicz
>         Attachments: jena-505.zip
>
>
> The error happens when you try to load a file using the file manager in Jena 2.10.1, for example
> {code}
> model = FileManager.get().loadModel("http://example.org","http://example.org","RDF/XML");
> {code}
> The reason is incorrect initialization of variables in the OWL class. In the following code:
> {code}
>     public class OWL {
>         private static Model m_model = ModelFactory.createDefaultModel();
>         
>         public static final String NS = "http://www.w3.org/2002/07/owl#";
>         
>         public static String getURI() {return NS;}
>     
>     ...    
>         public static final Property sameAs = m_model.createProperty( "http://www.w3.org/2002/07/owl#sameAs" );
>     ...
> {code}
> a call to OWL.sameAs will result in a NPE because m_model is null. I guess that if you start with OWL.getURI(), then m_model will be evaluated first and there will be no error, which is why this never occurred before.
> I think that a solution would be to make m_model final as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira