javawso2osgiwso2-api-manager

OSGI Bundling issue while upgrading WSO2 APIM 3.2 to 4.3


I am doing an upgrade of my custom mediator from wso2 apim 3.2 to 4.3 and i am using OSGI bundling. Given below is the osgi bundling code and the exception i got.

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>${maven-bundle-plugin.version}</version>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
        <Bundle-Name>${project.name}</Bundle-Name>
        <Bundle-Version>${project.version}</Bundle-Version>
        <Bundle-Activator>com.trafficcollector.wso2.PluginActivator</Bundle-Activator>
        <Export-Package>com.trafficcollector.wso2.mediator.*</Export-Package>
        <Import-Package>*</Import-Package>
        <Import-Package>com.fasterxml.jackson.dataformat.xml;version="2.9.10"</Import-Package>
        <Embed-Dependency>jackson-dataformat-xml;scope=compile|runtime</Embed-Dependency>
        <Embed-Transitive>true</Embed-Transitive>
        <Private-Package>
          com.trafficcollector.wso2.config,
          com.trafficcollector.wso2.dto*,
          com.trafficcollector.wso2.osgi,
          com.trafficcollector.wso2.publish*,
          com.trafficcollector.wso2.transform*,
          com.trafficcollector.wso2.exception,
          com.trafficcollector.wso2.filter,
          com.trafficcollector.wso2.service,
          com.trafficcollector.wso2.misc;
        </Private-Package>
        <Import-Package>
          org.apache.commons.lang3.*,
          com.fasterxml.jackson.dataformat.xml.*,
          org.wso2.carbon.apimgt.*,
          org.apache.synapse.*,
          org.apache.axis2.*,
          *
        </Import-Package>
      </instructions>
    </configuration>
  </plugin>

this is the exception

[2024-08-07 15:29:38,665] ERROR - Framework FrameworkEvent ERROR
2024-08-07 08:29:38 org.osgi.framework.BundleException: Could not resolve module: sample-wso2-traffic-collector [672]
2024-08-07 08:29:38   Unresolved requirement: Import-Package: org.apache.synapse; version="[2.1.0,3.0.0)"
2024-08-07 08:29:38 
2024-08-07 08:29:38     at org.eclipse.osgi.container.Module.start(Module.java:457) ~[org.eclipse.osgi_3.14.0.v20190517-1309.jar:?]
2024-08-07 08:29:38     at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$1.run(ModuleContainer.java:1820) ~[org.eclipse.osgi_3.14.0.v20190517-1309.jar:?]

what change i need to do?


Solution

  • This is what worked for me.

    <Import-Package>
       *; resolution:=optional
    </Import-Package>
    

    Also i have add a few <Embed-Dependency> to make this working.