以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 Web Services & Semantic Web Services 』  (http://bbs.xml.org.cn/list.asp?boardid=10)
----  Eclipse下解析owl-s文件  (http://bbs.xml.org.cn/dispbbs.asp?boardid=10&rootid=&id=66582)


--  作者: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"


--  作者:xufeng5264
--  发布时间:11/2/2011 10:17:00 AM

--  
我跟你遇到同样的问题了
service = kb.readService("file:G:/Downloads/ZipCodeFinder.owl");获取的service为空,以至于process = service.getProcess();出错
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms