I have been working with Jena fine for the first few weeks. However, today tomcat has started spitting out errors.
I think I've narrowed it down to:
Caused by: com.hp.hpl.jena.shared.JenaException: Invalid properties file
at com.hp.hpl.jena.util.Metadata.read(Metadata.java:71)
at com.hp.hpl.jena.util.Metadata.addMetadata(Metadata.java:41)
at com.hp.hpl.jena.util.Metadata.<init>(Metadata.java:35)
at com.hp.hpl.jena.JenaRuntime.<clinit>(JenaRuntime.java:25)
Although, I can't figure out which properties file it means. I've never configured a property file for jena. The only other thing I can think of that requires parsing is my web.xml which doesn't look wrong.
The code that causes the error is:
开发者_C百科public void getOntModel()
{
try
{
ssn = ModelFactory.createOntologyModel();
ssn.read(NS);
}
catch(Exception ex)
{
ex.printStackTrace();
System.out.println("[ONTOLOGY] Failed to read ontology file");
}
System.out.println("[ONTOLOGY] Ontology successfully read");
}
Specifically:
ssn = ModelFactory.createOntologyModel();
Looking at the source:
- http://grepcode.com/file/repo1.maven.org/maven2/com.hp.hpl.jena/jena/2.6.3/com/hp/hpl/jena/JenaRuntime.java#JenaRuntime
This is what is happening:
private static String metadataLocation = "com/hp/hpl/jena/jena-properties.xml" ;
private static Metadata metadata = new Metadata(metadataLocation) ;
It seems that it's trying to load the resource specified by metadataLocation. Can you check that your classpath is correct? Especially, check that there are no mixed versions of Jena libraries - if there are, reorder them so the newest are in front of your classpath.
If on some Unix-like system, you can use:
find /path/to/lib -name "*.jar"|while read fn; do
echo ---- $fn
jar tf $fn|grep jena-properties.xml
done
to find the jar that contains that property file - just change /path/to/lib
to the path where your Jena libraries are located.
精彩评论