SWRLRuleEngineAPI:错误的类格式出现在Eclipse和NetBeans ide同时做SWRL推理.<



我有一个简单的本体,并试图做SWRL推理。在Protege 3.5 (build 663)上,Jess和Drools引擎按预期工作,而使用SWRL API时出现错误。如SWRLRuleEngineAPI中所述,我使用以下代码:

SWRLRuleEngine ruleEngine = P3SWRLRuleEngineFactory.create(owlModel);
SWRLFactory factory = new SWRLFactory(owlModel);
SWRLImp imp = factory.createImp("Person(?x) ∧ hasGender(?x, male) →  Male(?x)");
ruleEngine.infer();
classes = owlModel.getUserDefinedOWLNamedClasses();
for (Iterator it = classes.iterator(); it.hasNext();) {
OWLNamedClass cls = (OWLNamedClass) it.next();
Collection instances = cls.getInstances(false);
System.out.println("Class " + cls.getBrowserText() + " (" + instances.size() + ")");
for (Iterator jt = instances.iterator(); jt.hasNext();) {
OWLIndividual individual = (OWLIndividual) jt.next();
System.out.println(" - " + individual.getBrowserText());
}
}

所有Protege API jar被正确引用,代码编译良好,模型被正确读取。但是,在激活规则引擎(SWRLRuleEngine ruleEngine = P3SWRLRuleEngineFactory.create(owlModel))时,Eclipse和NetBeans上都出现以下错误:

INFO:在1毫秒内更新底层帧模型在SWRLTab规则引擎管理器中注册的规则引擎'Jess'。2015年10月14日上午8:00:10 org.protege.swrltab.p3。P3SWRLRuleEngineFactory registerRuleEngine信息:规则引擎'Jess'注册了SWRLTab规则引擎管理器。插件'SWRLJessTab'已在SWRLTab插件管理器中注册。2015年10月14日上午8:00:10 edu.stanford.smi. protegeex .owl. swl。P3SWRLTabPluginManager registerPlugin信息:插件'SWRLJessTab'在SWRLTab插件管理器中注册。在SWRLTab规则引擎管理器中注册的规则引擎'Drools'。2015年10月14日上午8:00:10 org.protege.swrltab.p3。P3SWRLRuleEngineFactory registerRuleEngine信息:在SWRLTab规则引擎管理器中注册了规则引擎'Drools'。插件'SWRLDroolsTab'已在SWRLTab插件管理器中注册。2015年10月14日上午8:00:10 edu.stanford.smi. protegeex .owl. swl。P3SWRLTabPluginManager registerPlugin信息:插件'SWRLDroolsTab'在SWRLTab插件管理器中注册。插件'SQWRLQueryTab'注册到SWRLTab插件管理器。2015年10月14日上午8:00:10 edu.stanford.smi. protegeex .owl. swl。P3SWRLTabPluginManager registerPlugin信息:插件'SQWRLQueryTab'注册到SWRLTab插件管理器。java.lang.RuntimeException:类格式错误org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 251)org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 202)org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType (LookupEnvironment.java: 109)在org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve (UnresolvedReferenceBinding.java: 49)org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType (BinaryTypeBinding.java: 122)org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superInterfaces (BinaryTypeBinding.java: 1152)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface (ReferenceBinding.java: 888)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith0 (ReferenceBinding.java: 1036)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith (ReferenceBinding.java: 987)org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel (Scope.java: 3963)org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel (Scope.java: 3951)org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod (Scope.java: 555)org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor (Scope.java: 1882)org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType (AllocationExpression.java: 359)org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve (LocalDeclaration.java: 210)org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements (AbstractMethodDeclaration.java: 463)org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements (MethodDeclaration.java: 252)org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve (AbstractMethodDeclaration.java: 422)org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java: 1148)org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java: 1258)org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java: 538)org.eclipse.jdt.internal.compiler.Compiler.process (Compiler.java: 763)org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java: 468)org.drools.commons.jci.compilers.EclipseJavaCompiler.compile (EclipseJavaCompiler.java: 358)在org.drools.commons.jci.compilers.AbstractJavaCompiler.compile (AbstractJavaCompiler.java: 49)org.drools.rule.builder.dialect.java.JavaDialect.compileAll (JavaDialect.java: 370)在org.drools.compiler.DialectCompiletimeRegistry.compileAll (DialectCompiletimeRegistry.java: 47)org.drools.compiler.PackageRegistry.compileAll (PackageRegistry.java: 101)org.drools.compiler.PackageBuilder.compileAll (PackageBuilder.java: 966)org.drools.compiler.PackageBuilder.compileAllRules (PackageBuilder.java: 802)org.drools.compiler.PackageBuilder.addPackage (PackageBuilder.java: 791)org.drools.compiler.PackageBuilder.addPackageFromDrl (PackageBuilder.java: 462)org.drools.compiler.PackageBuilder.addKnowledgeResource (PackageBuilder.java: 664)在org.drools.builder.impl.KnowledgeBuilderImpl.add (KnowledgeBuilderImpl.java: 48)org.drools.builder.impl.KnowledgeBuilderImpl.add (KnowledgeBuilderImpl.java: 35)droolsswrlruleengine . definedrlresource(来源未知)droolsswrlruleengine . definedrlrule在org.protege.swrlapi.drools.DroolsSWRLRuleEngine。resetRuleEngine(未知来源)在org.protege.swrlapi.drools.DroolsSWRLRuleEngine。(未知来源)在org.protege.swrlapi.drools.DroolsSWRLRuleEngineCreator。创建(未知源)在org.protege.swrltab.p3.P3SWRLRuleEngineFactory。创建(未知源)在org.protege.swrltab.p3.P3SWRLRuleEngineFactory。创建(未知源)com.demo.application.OWLAPIDemoApplication.main (OWLAPIDemoApplication.java: 107)由:org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException引起在org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader。(ClassFileReader.java: 372)org.drools.commons.jci.compilers.EclipseJavaCompiler createnameenvironmentanswer 2.美元(EclipseJavaCompiler.java: 275)org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 246)…42更多org.protege.swrlapi.exceptions.SWRLRuleEngineException:创建规则引擎Drools错误。例外:org.protege.owl.portability.exceptions.TargetRuleEngineException。消息:生成Drools规则的内部错误当CDA($c:c) then SCA sca1=new SCA($c, $c);ECA =新的ECA($c, $c);SCA sca2=new SCA($c, "owl:Thing");SCA sc3 =new SCA("owl:Nothing", $c);推断。推断(sca1, eca, sca2, sca3);结束课程格式错误在org.protege.swrltab.p3.P3SWRLRuleEngineFactory。创建(未知源)在org.protege.swrltab.p3.P3SWRLRuleEngineFactory。创建(未知源)com.demo.application.OWLAPIDemoApplication.main (OWLAPIDemoApplication.java: 107)org.protege.owl.portability.exceptions.TargetRuleEngineException:生成Drools规则的内部错误当CDA($c:c) then SCA sca1=new SCA($c, $c);ECA =新的ECA($c, $c);SCA sca2=new SCA($c, "owl:Thing");SCA sc3 =new SCA("owl:Nothing", $c);推断。推断(sca1, eca, sca2, sca3);结束课程格式错误droolsswrlruleengine . definedrlrule在org.protege.swrlapi.drools.DroolsSWRLRuleEngine。resetRuleEngine(未知来源)在org.protege.swrlapi.drools.DroolsSWRLRuleEngine。(未知来源)在org.protege.swrlapi.drools.DroolsSWRLRuleEngineCreator。创建(未知源)…三个java.lang.RuntimeException:错误的类格式org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 251)org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 202)org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType (LookupEnvironment.java: 109)在org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve (UnresolvedReferenceBinding.java: 49)org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType (BinaryTypeBinding.java: 122)org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superInterfaces (BinaryTypeBinding.java: 1152)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.implementsInterface (ReferenceBinding.java: 888)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith0 (ReferenceBinding.java: 1036)org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isCompatibleWith (ReferenceBinding.java: 987)org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel (Scope.java: 3963)org.eclipse.jdt.internal.compiler.lookup.Scope.parameterCompatibilityLevel (Scope.java: 3951)org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod (Scope.java: 555)org.eclipse.jdt.internal.compiler.lookup.Scope.getConstructor (Scope.java: 1882)org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType (AllocationExpression.java: 359)org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve (LocalDeclaration.java: 210)org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements (AbstractMethodDeclaration.java: 463)org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements (MethodDeclaration.java: 252)org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve (AbstractMethodDeclaration.java: 422)org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java: 1148)org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java: 1258)org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java: 538)org.eclipse.jdt.internal.compiler.Compiler.process (Compiler.java: 763)org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java: 468)org.drools.commons.jci.compilers.EclipseJavaCompiler.compile (EclipseJavaCompiler.java: 358)在org.drools.commons.jci.compilers.AbstractJavaCompiler.compile (AbstractJavaCompiler.java: 49)org.drools.rule.builder.dialect.java.JavaDialect.compileAll (JavaDialect.java: 370)在org.drools.compiler.DialectCompiletimeRegistry.compileAll (DialectCompiletimeRegistry.java: 47)org.drools.compiler.PackageRegistry.compileAll (PackageRegistry.java: 101)org.drools.compiler.PackageBuilder.compileAll (PackageBuilder.java: 966)org.drools.compiler.PackageBuilder.compileAllRules (PackageBuilder.java: 802)org.drools.compiler.PackageBuilder.addPackage (PackageBuilder.java: 791)org.drools.compiler.PackageBuilder.addPackageFromDrl (PackageBuilder.java: 462)org.drools.compiler.PackageBuilder.addKnowledgeResource (PackageBuilder.java: 664)在org.drools.builder.impl.KnowledgeBuilderImpl.add (KnowledgeBuilderImpl.java: 48)org.drools.builder.impl.KnowledgeBuilderImpl.add (KnowledgeBuilderImpl.java: 35)droolsswrlruleengine . definedrlresource(来源未知)…7多由:org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException引起在org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader。(ClassFileReader.java: 372)org.drools.commons.jci.compilers.EclipseJavaCompiler createnameenvironmentanswer 2.美元(EclipseJavaCompiler.java: 275)org.drools.commons.jci.compilers.EclipseJavaCompiler findtype 2.美元(EclipseJavaCompiler.java: 246)…42更多Java Result: 1

更新:降级到Java 7后出现以下问题:

线程"main"异常java.lang.NullPointerException atorg.protege.owl.portability.p3.converters.P3OWLAxiomConverter.completeBulkConversion(未知源)org.protege.swrlapi.core.impl.AbstractSWRLRuleEngine.writeInferredKnowledge2OWL(未知源)org.protege.swrlapi.core.impl.AbstractSWRLRuleEngine.infer(未知源)com.demo.application.OWLAPIDemoApplication.main (OWLAPIDemoApplication.java: 125)Java Result: 1

这是Protege版本的问题。我通过降级到3.4.8版本来解决这个问题,这是Martin O'Connor Answer建议的,这个版本已经经过了广泛的审查。谢谢大家的努力。

相关内容

  • 没有找到相关文章

最新更新