Topic
7 replies Latest Post - ‏2012-06-11T08:08:07Z by SystemAdmin
RChamarthy
RChamarthy
10 Posts
ACCEPTED ANSWER

Pinned topic WAR using OSGi Bundle Repositories

‏2011-04-07T13:14:32Z |
Hi,

How can a Servlet residing in a JEE WAR file access the shared libries from OSGi Internal Bundle Repository?
Upon searching I found that one needs to convert the WAR to a WAB? But there are no clear cut steps mentioned anywhere, or may I just missed them. Can someone point them please.

Thanks,
Ravi
Updated on 2012-06-11T08:08:07Z at 2012-06-11T08:08:07Z by SystemAdmin
  • Emily Jiang
    Emily Jiang
    73 Posts
    ACCEPTED ANSWER

    Re: WAR using OSGi Bundle Repositories

    ‏2011-04-07T13:33:39Z  in response to RChamarthy
    Hi Ravi,

    For converting WAR to a WAB, below are the instructions:
    1. open the WAR's manifest file (META-INF/MANIFEST.MF) and add the following headers:

    Bundle-ManifestVersion: 2
    Bundle-Name: 'a sensible name'
    Bundle-SymbolicName: com.xx.xx
    Bundle-Version: 1.0.0 (or an alternative version)
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Import-Package:
    javax.servlet,
    javax.servlet.http (list all imported packages here)
    Web-ContextPath: /something
    Bundle-ClassPath: WEB-INF/classes
    2. save the changes and rename the WAR to .jar file (a WAB)
    3. uploade the WAB to the internal bundle repository.

    Hope this helps.
    Thanks
    Emily
    • MarkN
      MarkN
      124 Posts
      ACCEPTED ANSWER

      Re: WAR using OSGi Bundle Repositories

      ‏2011-04-07T13:53:15Z  in response to Emily Jiang
      Hi Ravi,
      Just to follow on from Emily's advice, if you're looking for the WAB spec, it's in section 128 of the OSGi Enterprise 4.2 spec, downloadable from http://www.osgi.org/Download/Release4V42.See page 417 onwards.

      Regards,
      Mark
    • RChamarthy
      RChamarthy
      10 Posts
      ACCEPTED ANSWER

      Re: WAR using OSGi Bundle Repositories

      ‏2011-04-08T06:38:14Z  in response to Emily Jiang
      Hi Emily,

      >>3. uploade the WAB to the internal bundle repository.
      Do I have to upload it to internal bundle repository?? If so, how to I deploy this JAR'ed version of the WAR file?
      Or should I update the .jar to Assets? I did this, and added this Asset to a BLA and running into a NoClassDefFoundError point to a class from the shared library, which the Servlet uses.

      Thanks,
      Ravi
      • Emily Jiang
        Emily Jiang
        73 Posts
        ACCEPTED ANSWER

        Re: WAR using OSGi Bundle Repositories

        ‏2011-04-08T07:45:26Z  in response to RChamarthy
        Hi Ravi,

        You don't have to upload the WAB in the internal bundle repository. However it is preferred for better governance. In the development environment, you can include the WAB in the asset (.eba file) as you have done. In the Import-Package: entry of your WAB's manifest.mf, did you list the package name in the shared library that your servlet uses? If it is still not working, please post your WAB's manifest and the shared library's manifest if possible?

        Hope this helps.
        Thanks
        Emily
        • RChamarthy
          RChamarthy
          10 Posts
          ACCEPTED ANSWER

          Re: WAR using OSGi Bundle Repositories

          ‏2011-04-13T14:08:01Z  in response to Emily Jiang
          Okay, I got this working: having the OSGi web module to use the bundles in OSGi Bundle Repository.

          Ravi
          • SystemAdmin
            SystemAdmin
            153 Posts
            ACCEPTED ANSWER

            Re: WAR using OSGi Bundle Repositories

            ‏2012-06-11T08:08:07Z  in response to RChamarthy
            Hi RChamarthy,

            Can you post your solution steps here ?

            Thanks,
            Anson
      • MarkN
        MarkN
        124 Posts
        ACCEPTED ANSWER

        Re: WAR using OSGi Bundle Repositories

        ‏2011-04-08T09:55:57Z  in response to RChamarthy
        Hello Ravi,
        Re-reading your question:

        > How can a Servlet residing in a JEE WAR file access the shared libries
        > from OSGi Internal Bundle Repository?

        May I ask, is this Servlet packaged in a regular JEE .ear file? The internal bundle repository (Environment > OSGi bundle repositories > Internal bundle repository) is only for use by OSGi applications, which are packaged as .eba files and imported as assets via the Applications > Application types > Assets panel. If you're still having problems, please tell us how you are trying to package your application. Thank you!

        Regards,
        Mark