You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2013/08/09 13:58:48 UTC
[jira] [Commented] (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=13734698#comment-13734698 ]
Andy Seaborne commented on JENA-505:
------------------------------------
When I run:
{noformat}
public static void main( String[] args ) {
Model model = FileManager.get().loadModel("http://example.org","http://example.org","RDF/XML");
System.out.println("DONE") ;
}
{noformat}
I get a RIOT exception (correct - http://example.org isn't RDF/XML), not NPE from class OWL.
To get that sort of error in OWL, then it needs to happen as part of complex class initialization.
Do you have a complete, standalone example?
What is your classpath? What is the stacktrace?
> 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
>
> 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