Search code examples
apache-karafaries

ClassNotFoundException error in apache karaf


I added contect-param tab in the web.xml file

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

also listner class in the web.xml file

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

after loading to karaf, I am getting the error below:

java.lang.ClassNotFoundException: org.apache.aries.blueprint.web.BlueprintContextListener not found by com.test.test.core.jsonstore-http-api

How to resolve this issue?


Solution

  • The error indicates that your bundle is probably not importing the package org.apache.aries.blueprint.web at his MANIFEST.MF file.

    There are several ways to fix that, if you are using maven-bundle-plugin, you can add the package manually to the Import-Package directive, just like this:

    <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>
    

    If you are using another tool to generate your manifest, it should be similar to that.