Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] Problem in reading and writing owl file

Timothy Redmond tredmond at stanford.edu
Mon Aug 31 08:48:42 PDT 2009


You haven't included or you have the wrong xml-apis.jar and  
xercesImpl.jar on your classpath when you  run the program.  You  
should be using the one that comes with protege owl.

-Timothy

On Aug 31, 2009, at 8:35 AM, Muhammad Javed wrote:

> Hi,
>
> My code is as follows..... and error is given in the  
> bottom:          I am trying to write a simple owl file and want to  
> save it in the hard disk. I am using NetBeans. I assume file should  
> be saved in Project's directory. Do I have any probelms with adding  
> Jar files ? I collected all the Jar files which i could find in  
> installation of Protege 3.4.1 and added in the Project (Properties/ 
> Add Jar File).
>
> import com.hp.hpl.jena.util.FileUtils;
> import edu.stanford.smi.protege.exception.OntologyLoadException;
> import edu.stanford.smi.protegex.owl.ProtegeOWL;
> import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
> import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
> import java.io.File;
> import java.util.ArrayList;
> import java.util.Collection;
>
> public class NewClass{
>
>  public static void main(String args[]) throws  
> OntologyLoadException  {
>
>
>     JenaOWLModel owlModel = ProtegeOWL.createJenaOWLModel();
>     owlModel.getNamespaceManager().setDefaultNamespace("http://www.cngl.ie# 
> ");
>     OWLNamedClass destinationClass =  
> owlModel.getOWLNamedClass("Destination");
>
>     String fileName = "travel-saved.owl";
>     Collection errors = new ArrayList();
>     owlModel.save(new File(fileName).toURI(),  
> FileUtils.langXMLAbbrev, errors);
>     System.out.println("File saved with " + errors.size() + "  
> errors.");
>
>
> } }
>
>
>
> ERROR:
>
> WARNING: [Local Folder Repository] The specified file must be a  
> directory. (C:\Documents and Settings\mjaved\My Documents 
> \NetBeansProjects\Protege-OWLAPI\plugins 
> \edu.stanford.smi.protegex.owl) -- LocalFolderRepository.update()
> Exception in thread "main" java.lang.NoSuchMethodError:  
> org.apache.xerces.parsers.SAXParser.<init>(Lorg/apache/xerces/xni/ 
> parser/XMLParserConfiguration;)V
>         at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser 
> $MySAXParser.<init>(RDFXMLParser.java:55)
>         at  
> com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.create(RDFXMLParser.java:82)
>         at com.hp.hpl.jena.rdf.arp.JenaReader.<init>(JenaReader.java: 
> 77)
>         at  
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at  
> sun 
> .reflect 
> .NativeConstructorAccessorImpl 
> .newInstance(NativeConstructorAccessorImpl.java:39)
>         at  
> sun 
> .reflect 
> .DelegatingConstructorAccessorImpl 
> .newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at  
> java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at  
> com 
> .hp 
> .hpl 
> .jena.rdf.model.impl.RDFReaderFImpl.getReader(RDFReaderFImpl.java:113)
>         at  
> com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
>         at  
> com 
> .hp 
> .hpl 
> .jena 
> .ontology.OntDocumentManager.findMetadata(OntDocumentManager.java: 
> 1010)
>         at  
> com 
> .hp 
> .hpl 
> .jena 
> .ontology 
> .OntDocumentManager.initialiseMetadata(OntDocumentManager.java:968)
>         at  
> com 
> .hp 
> .hpl.jena.ontology.OntDocumentManager.<init>(OntDocumentManager.java: 
> 205)
>         at  
> com 
> .hp 
> .hpl.jena.ontology.OntDocumentManager.<init>(OntDocumentManager.java: 
> 187)
>         at  
> com 
> .hp 
> .hpl.jena.ontology.OntDocumentManager.<init>(OntDocumentManager.java: 
> 171)
>         at  
> com 
> .hp 
> .hpl 
> .jena 
> .ontology.OntDocumentManager.getInstance(OntDocumentManager.java:249)
>         at  
> com 
> .hp 
> .hpl.jena.ontology.OntModelSpec.getDocumentManager(OntModelSpec.java: 
> 330)
>         at  
> com 
> .hp 
> .hpl 
> .jena 
> .ontology.impl.OntModelImpl.getDocumentManager(OntModelImpl.java:179)
>         at  
> com.hp.hpl.jena.ontology.impl.OntModelImpl.<init>(OntModelImpl.java: 
> 150)
>         at  
> com.hp.hpl.jena.ontology.impl.OntModelImpl.<init>(OntModelImpl.java: 
> 130)
>         at  
> com 
> .hp 
> .hpl 
> .jena.rdf.model.ModelFactory.createOntologyModel(ModelFactory.java: 
> 411)
>         at  
> edu 
> .stanford 
> .smi 
> .protegex.owl.jena.protege2jena.Protege2Jena.createOntModel(Unknown  
> Source)
>         at  
> edu 
> .stanford 
> .smi 
> .protegex.owl.jena.protege2jena.Protege2Jena.createOntModel(Unknown  
> Source)
>         at  
> edu 
> .stanford 
> .smi.protegex.owl.jena.protege2jena.Protege2Jena.saveAll(Unknown  
> Source)
>         at  
> edu.stanford.smi.protegex.owl.jena.JenaOWLModel.save(Unknown Source)
>         at NewClass.main(NewClass.java:29)
> Java Result: 1
> BUILD SUCCESSFUL (total time: 2 seconds)
>
>
> ----------------------------------------------
> Muhammad Javed
> PhD Research Student
> Centre for Next Generation Localisation,
> L208, School of Computing
> Dublin City University, Dublin 09
> Ireland
> Tel: #. +353-86 207 8581
> www.computing.dcu.ie/~mjaved   
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03




More information about the protege-owl mailing list