首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与Pellet和OWL的OSGi依赖进行斗争

与Pellet和OWL的OSGi依赖进行斗争
EN

Stack Overflow用户
提问于 2015-11-16 11:09:04
回答 1查看 640关注 0票数 0

我为owl编写了一个外观,并将其与结合在一起,以方便地访问本体。它运作得很安静。然后我尝试将它打包成一个OSGi包,并通过来自其他服务的TrackerService使用它。owl包需要番石榴和特洛伊木马才能运行。对宝物来说,没有包袱。即使在重新加载目标平台之后,在eclipse中也没有将颗粒罐识别为包(我从jpm4j中获取了它们)。所以我想把所有的罐子都拿出来,然后把它塞进包里。

我读了很多关于如何用包包装第三方罐子的文章。我使用maven-bundle-plugin,在阅读了这个插件和bndtools中的一些文档之后,我决定使用文档,因为这里描述了pom中的所有条目都被传递给bndtools。编译之后,没有用我的包打包jar :(然后我用了embed-dependencies.它无法工作,因为临时依赖项在运行时不可用。所以我使用了embed-transient标签(我已经读过这是不好的风格)。imports部分自动填充所有临时依赖项,因此我手工重写了它,以消除与未解决的导入相关的错误。这起作用了,我能够使用owl插入新的属性、个人等等(是的)。

当我尝试启动颗粒推理器时,我在运行时得到了下面的错误消息。我认为这又是关于我的项目中的依赖-混乱。我已经知道现在的方法是错误的,但我找不到一个更好的方法。请帮助我在OSGi中实现这种依赖关系管理。

干杯,斯蒂芬

错误信息:

代码语言:javascript
复制
!ENTRY org.apache.felix.configadmin 4 0 2015-11-16 11:28:45.218
!MESSAGE [org.osgi.service.cm.ManagedService, id=28, bundle=7/initial@reference:file:..vdg.iCar.service]: Unexpected problem updating configuration vdg.iCar.service
!STACK 0
java.lang.Error: javax.xml.datatype.DatatypeConfigurationException: Provider for class javax.xml.datatype.DatatypeFactory cannot be found
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:892)
at javax.xml.bind.DatatypeConverter.initConverter(DatatypeConverter.java:140)
at javax.xml.bind.DatatypeConverter.parseFloat(DatatypeConverter.java:243)
at com.clarkparsia.pellet.datatypes.types.floating.XSDFloat.getValue(XSDFloat.java:81)
at com.clarkparsia.pellet.datatypes.types.floating.XSDFloat.getCanonicalRepresentation(XSDFloat.java:58)
at com.clarkparsia.pellet.datatypes.DatatypeReasonerImpl.getCanonicalRepresentation(DatatypeReasonerImpl.java:365)
at org.mindswap.pellet.ABox.createLiteral(ABox.java:1746)
at org.mindswap.pellet.ABox.addLiteral(ABox.java:1725)
at org.mindswap.pellet.KnowledgeBase.addPropertyValue(KnowledgeBase.java:974)
at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:1103)
at uk.ac.manchester.cs.owl.owlapi.OWLDataPropertyAssertionAxiomImpl.accept(OWLDataPropertyAssertionAxiomImpl.java:119)
at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:699)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyImpl.accept(OWLOntologyImpl.java:1516)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.refresh(PelletReasoner.java:967)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:345)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:304)
at com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.createReasoner(PelletReasonerFactory.java:71)
at de.dlr.vdg.ontology.osgi.impl.util.ReasonerUtil.getInferredOntology(ReasonerUtil.java:56)
at de.dlr.vdg.ontology.osgi.impl.util.ReasonerUtil.getInferredRelations(ReasonerUtil.java:304)
at de.dlr.vdg.ontology.osgi.impl.OntologyServiceImpl.startReasoning(OntologyServiceImpl.java:106)
at de.dlr.vdg.iCar.osgi.impl.iCarServiceImpl.start(iCarServiceImpl.java:67)
at de.dlr.vdg.iCar.osgi.Activator.updated(Activator.java:65)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider for class javax.xml.datatype.DatatypeFactory cannot be found
at javax.xml.datatype.FactoryFinder.findServiceProvider(FactoryFinder.java:304)
at javax.xml.datatype.FactoryFinder.find(FactoryFinder.java:268)
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:145)
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:890)
... 28 more
Caused by: java.util.ServiceConfigurationError: javax.xml.datatype.DatatypeFactory: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at javax.xml.datatype.FactoryFinder$1.run(FactoryFinder.java:297)
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.datatype.FactoryFinder.findServiceProvider(FactoryFinder.java:292)
... 31 more

POM-档案(重要部分):

代码语言:javascript
复制
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.0.1</version>
            <extensions>true</extensions>
            <configuration>
                <manifestLocation>META-INF</manifestLocation>
                <instructions>
                    <Private-Package>${bundle.namespace}.*</Private-Package>
                    <Export-Package>${bundle.namespaceShared}</Export-Package>
                    <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                    <Bundle-Version>${project.version}</Bundle-Version>
                    <Bundle-Activator>${bundle.namespace}.Activator</Bundle-Activator>
                    <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                    <Import-Package>org.osgi.framework;version="[1.6,2)",org.osgi.se
                    rvice.cm;version="[1.4,2)",org.slf4j;version="[1.7,2)"</Import-Package>
                    <Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.7</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>4.3.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
        <version>4.3.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-distribution</artifactId>
        <version>3.5.2</version>
        <type>bundle</type>
    </dependency>
    <dependency>
        <groupId>com.github.ansell.pellet</groupId>
        <artifactId>pellet-owlapiv3</artifactId>
        <version>2.3.6-ansell</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.github.ansell.pellet</groupId>
        <artifactId>pellet-query</artifactId>
        <version>2.3.6-ansell</version>
        <type>jar</type>
    </dependency>
</dependencies>

EN

回答 1

Stack Overflow用户

发布于 2015-11-17 10:01:28

经过另外一天的研究,我在甲骨文( oracle )偶然发现了这条线

pellet引用了xerces和xml库,由于依赖项的短暂包含,这些库被包含在我的包中。但是这些库已经存在于java运行时环境中。因此,我将它们排除在Embed-Dependency部分中,一切都正常。

代码语言:javascript
复制
<Embed-Dependency>*;scope=compile|runtime;inline=false;groupId=!xml-apis|xerces</Embed-Dependency>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33733917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档