-- 作者:yuwengong_720
-- 发布时间:8/30/2008 11:36:00 AM
-- Eclipse下解析owl-s文件
学习一个例子。我导入了owl-s包还不够吗?是不是还需要什么?请大家指教! 代码如下: import org.mindswap.owl.OWLFactory; import org.mindswap.owl.OWLIndividual; import org.mindswap.owl.OWLKnowledgeBase; import org.mindswap.owls.OWLSFactory; import org.mindswap.owls.process.AtomicProcess; import org.mindswap.owls.process.Process; import org.mindswap.owls.process.execution.ProcessExecutionEngine; import org.mindswap.owls.process.execution.ProcessExecutionListener; import org.mindswap.owls.profile.Profile; import org.mindswap.owls.service.Service; import org.mindswap.query.ValueMap; import org.mindswap.utils.Utils; import org.mindswap.wsdl.WSDLOperation; import org.mindswap.wsdl.WSDLService; public class RunService { /** * @param args */ Service service; Profile profile; Process process; WSDLService s; WSDLOperation op; String inValue; String outValue; ValueMap values; ProcessExecutionEngine exec; public RunService() { // create an execution engine exec = OWLSFactory.createExecutionEngine(); // Attach a listener to the execution engine exec.addExecutionListener(new ProcessExecutionListener() { public void setCurrentExecuteService(Process p) { System.out.println("Start executing process " + p); } public void printMessage(String message) { } public void finishExecution(int retCode) { System.out.println("Finished execution " + ((retCode == ProcessExecutionListener.EXEC_ERROR) ? "with errors" : "successfully")); } }); } public void runZipCode() throws Exception { OWLKnowledgeBase kb = OWLFactory.createKB(); service = kb.readService("file:G:/Downloads/ZipCodeFinder.owl"); process = service.getProcess(); // initialize the input values to be empty values = new ValueMap(); values.setDataValue(process.getInput("City"), "College Park"); values.setDataValue(process.getInput("State"), "MD"); values = exec.execute(process, values); // get the result OWLIndividual out = values.getIndividualValue(process.getOutput()); // display the results System.out.println("Executed service '" + service + "'"); System.out.println("Grounding WSDL: " + ((AtomicProcess) process).getGrounding().getDescriptionURL()); System.out.println("City = " + "College Park"); System.out.println("State = " + "MD"); System.out.println("Output = "); System.out.println(Utils.formatRDF(out.toRDF())); System.out.println(); } public static void main(String[] args) throws Exception { RunService test = new RunService(); try { test.runZipCode(); } catch(Exception e) { e.printStackTrace(); } } } 出现下面的问题: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at com.hp.hpl.jena.rdf.model.impl.PropertyImpl.<clinit>(PropertyImpl.java:58) at com.hp.hpl.jena.rdf.model.ResourceFactory$Impl.createProperty(ResourceFactory.java:188) at com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty(ResourceFactory.java:96) at com.hp.hpl.jena.vocabulary.RDF.property(RDF.java:32) at com.hp.hpl.jena.vocabulary.RDF.<clinit>(RDF.java:45) at com.hp.hpl.jena.reasoner.rulesys.impl.RDFSCMPPreprocessHook.<clinit>(RDFSCMPPreprocessHook.java:29) at com.hp.hpl.jena.reasoner.rulesys.RDFSRuleReasoner.<clinit>(RDFSRuleReasoner.java:56) at com.hp.hpl.jena.reasoner.rulesys.RDFSRuleReasonerFactory.create(RDFSRuleReasonerFactory.java:46) at com.hp.hpl.jena.reasoner.ReasonerRegistry.getRDFSReasoner(ReasonerRegistry.java:181) at impl.jena.JenaOWLFactory.<init>(JenaOWLFactory.java:42) 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:274) at java.lang.Class.newInstance0(Class.java:308) at java.lang.Class.newInstance(Class.java:261) at org.mindswap.owl.OWLFactory.createFactory(OWLFactory.java:72) at org.mindswap.owl.OWLFactory.<clinit>(OWLFactory.java:66) at RunService.runZipCode(RunService.java:64) at RunService.main(RunService.java:98) Exception in thread "main"
|