首页 > 解决方案 > apache karaf 中的 ClassNotFoundException 错误

问题描述

我在文件中添加了contect-param选项卡web.xml

<context-param>
    <param-name>blueprintLocation</param-name>
    <param-value>OSGI-INF/blueprint/blueprint.xml</param-value>
</context-param>

也在文件listner中类web.xml

<listener>
    <listener-class>org.apache.aries.blueprint.web.BlueprintContextListener</listener-class>
</listener>

加载到 karaf 后,我收到以下错误:

java.lang.ClassNotFoundException:com.test.test.core.jsonstore-http-api 找不到 org.apache.aries.blueprint.web.BlueprintContextListener

如何解决这个问题?

标签: apache-karafaries

解决方案


该错误表明您的包可能没有在他的 MANIFEST.MF 文件中导入包org.apache.aries.blueprint.web 。

有几种方法可以解决这个问题,如果您使用的是maven-bundle-plugin,您可以手动将包添加到Import-Package指令中,就像这样:

<plugins>
  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Import-Package>
        org.apache.aries.blueprint.web,
        *
        </Import-Package>
      </instructions>
    </configuration>
  </plugin>
</plugins>

如果您使用其他工具来生成清单,它应该与此类似。


推荐阅读