Topic
3 replies Latest Post - ‏2013-04-04T14:47:49Z by SystemAdmin
yusufe
yusufe
5 Posts
ACCEPTED ANSWER

Pinned topic Unable import packages from core bundles to feature bundles

‏2013-03-26T10:41:27Z |
I have feature called: simple

wlp\usr\extension\lib\feature\simple.mf

Subsystem-ManifestVersion: 3 Subsystem-SymbolicName: simple; visibility:=

public Subsystem-Version: 3 Subsystem-Type: osgi.subsystem.feature Subsystem-Content: org.simple IBM-Feature-Version: 2

wlp\usr\extension\lib\simple.jar\META-INF\MANIFEST.MF

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: org.simple Bundle-SymbolicName: org.simple Bundle-Version: 8.0.0 Import-Package: org.eclipse.osgi.framework.log; version=
"1.1" Bundle-RequiredExecutionEnvironment: J2SE-1.5


inside server.xml I try to use it:

<feature>usr:simple</feature>


But I got this:

C:\IBM\WebSphere\wlp_beta_git\2\wlp\bin>server run --clean Launching defaultServer (wlp-1.0.1.20130309-1525/websphere-kernel_1.0.1) on IBM J9 VM, version jvmwi3260sr9-20110218_76011 (en_US) [AUDIT   ] CWWKE0001I: The server defaultServer has been launched. [ERROR   ] CWWKE0702E: The bundle 
"org.simple_8.0.0 [69]" could not be resolved. Reason: Missing Constraint: Import-Package: org.eclipse.osgi.framework.log; version=
"1.1.0" [AUDIT   ] CWWKZ0058I: Monitoring dropins 

for applications. [AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.


And this is a section I extracted from the trace.log:

[3/26/13 18:20:34:058 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < getProductPackagesForBundle Exit [com.ibm.ws.kernel.feature.internal.FeatureManager$ProductPackages@0] [3/26/13 18:20:34:058 SGT] 00000016 id=6bcf6bcf bm.ws.kernel.feature.internal.FeatureManager$ProductPackages > isAPI Entry org.eclipse.osgi.framework.log [3/26/13 18:20:34:058 SGT] 00000016 id=6bcf6bcf bm.ws.kernel.feature.internal.FeatureManager$ProductPackages < isAPI Exit 

false [3/26/13 18:20:34:058 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < isPackageExported Exit 

false [3/26/13 18:20:34:058 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < isPackageExportedAsAPI Exit 

false [3/26/13 18:20:34:058 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            > isPackageExportedAsSPI Entry org.eclipse.osgi.framework.log org.eclipse.osgi_3.8.2.v20130124-134944 org.simple_8.0.0 [3/26/13 18:20:34:058 SGT] 00000016 id=10191019 com.ibm.ws.kernel.feature.internal.KernelBundles             > isRootBundle Entry org.simple_8.0.0 [69] [3/26/13 18:20:34:059 SGT] 00000016 id=10191019 com.ibm.ws.kernel.feature.internal.KernelBundles             < isRootBundle Exit 

true [3/26/13 18:20:34:059 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            > isPackageExported Entry 

true org.eclipse.osgi.framework.log org.eclipse.osgi_3.8.2.v20130124-134944 [3/26/13 18:20:34:059 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            > getProductPackagesForBundle Entry org.eclipse.osgi_3.8.2.v20130124-134944 [0] [3/26/13 18:20:34:059 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < getProductPackagesForBundle Exit [com.ibm.ws.kernel.feature.internal.FeatureManager$ProductPackages@0] [3/26/13 18:20:34:059 SGT] 00000016 id=6bcf6bcf bm.ws.kernel.feature.internal.FeatureManager$ProductPackages > isSPI Entry org.eclipse.osgi.framework.log [3/26/13 18:20:34:059 SGT] 00000016 id=6bcf6bcf bm.ws.kernel.feature.internal.FeatureManager$ProductPackages < isSPI Exit 

false [3/26/13 18:20:34:059 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < isPackageExported Exit 

false [3/26/13 18:20:34:059 SGT] 00000016 id=11421142 com.ibm.ws.kernel.feature.internal.FeatureManager            < isPackageExportedAsSPI Exit 

false [3/26/13 18:20:34:059 SGT] 00000016 id=193a193a com.ibm.ws.kernel.feature.internal.FeatureResolverHook       3 DENIED: Bundle org.simple 8.0.0 requested org.eclipse.osgi.framework.log((&(osgi.wiring.package=org.eclipse.osgi.framework.log)(version>=1.1.0))) was offered at versions (org.eclipse.osgi@3.8.2.v20130124-134944)


Obviously WAS Libery has made a major change from beta 1 to beta 2 about feature package resolutions. This exact same resolution succeeds with beta 1 but fails with beta 2.

What I can do to make things work the same way as beta 1? (interestingly this exact package is not exported as IBM-API-Package in neither versions, and I suspect beta 1 was allowing this as a bug)
  • SystemAdmin
    SystemAdmin
    590 Posts
    ACCEPTED ANSWER

    Re: Unable import packages from core bundles to feature bundles

    ‏2013-03-26T14:17:08Z  in response to yusufe
    Hi,

    You are correct that the org.eclipse.osgi.framework.log package is not exposed as API or SPI in liberty, and the beta 2 driver is applying the correct visibility limitations. The purpose of this is to limit exposure to a known set of classes that we can focus our backward compatibility efforts on in future updates. We do expose the org.osgi.service.log package as SPI, as well as WebSphere-specific logging and tracing packages. Would any of those meet your needs?

    Regards, Alex.
    • yusufe
      yusufe
      5 Posts
      ACCEPTED ANSWER

      Re: Unable import packages from core bundles to feature bundles

      ‏2013-03-27T06:55:38Z  in response to SystemAdmin
      Hi Alex, thanks for the reply,
      What you say makes sense but this and some of our other imports are not from our own bundles. Our bundles depend some of other bundles like; eclipse.equinox (i.e. eclipse.equinox.common)and eclipse.emf bundles. And they do these kind of imports that are not exposed by core features. I guess Beta 1 didn't have the check and we were able to import whatever available in OSGi engine, but with Beta 2 if a package is not explicitly exported by IBM-API-Package, user features can not import them.
      My workaround is so far adding a core feature (a new mf file in wlp/lib/features) and exposing these packages with IBM-API-Package in it.
      Is there any other solution comes to your mind?
      • SystemAdmin
        SystemAdmin
        590 Posts
        ACCEPTED ANSWER

        Re: Unable import packages from core bundles to feature bundles

        ‏2013-04-04T14:47:49Z  in response to yusufe
        Hi Yusuf,
        If we don't expose a package from our framework then it's not available for use outside our code - as I said, this is to protect user apps and feature from future incompatible changes. If you take the risk and expose it with your own feature, that is not a supported use and your feature may break when you apply service/upgrade to a new release. The safe option is to package the code you need inside your own feature, or another feature in your product extension.
        Regards, Alex.