Menu

#17 Create OSGi bundle for Jericho HTML Parser

General
open
None
3
2013-04-16
2013-04-15
No

Hi,

We are using Jericho in an OSGi container. This requires that the manifest file for Jericho HTML jar should have additional details to convert it to an OSGi bundle.

For Eg:

Manifest-Version: 1.0
Created-By: 1.5.0_15 (Sun Microsystems Inc.)
Bundle-Version: 3.2.0
Bundle-Name: Jericho html parser
Bundle-SymbolicName: jericho
Export-Package: net.htmlparser.jericho;version="3.2.0",net.htmlparser.jericho.nodoc;version="3.2.0"

==================================================================================

In the manifest file we need to add Export-Package and Import-Package details so that Jericho HTMl can be used within any OSGi container.

This can be achieved using ANT or MAVEN. There are ANT Tasks and Maven Plugins to create bundles.

We need this feature so that we can directly use the JAR in our application server environment.

Please let me know if additional information is required.

Thanks and Regards
Brahmachaitanya

1 Attachments

Discussion

  • Martin Jericho

    Martin Jericho - 2013-04-15

    Hi Brahmachaitanya,

    Please see this previous feature request:
    http://sourceforge.net/p/jerichohtml/feature-requests/13/

    The manifest file you have attached also contains some errors, such as:
    - specifies an old version of Jericho HTML Parser (3.3 is the latest production release)
    - specifies the wrong version of slf4j and doesn't indicate it is optional
    - contains lines longer than 72 characters

    As I am unfamiliar with OSGi I would need to rely on someone to provide the exact, error free manifest file content. Unfortunately I don't have time to work it out myself.

    Could you also please explain why you can't add it to the manifest file yourself? Does OSGi use maven respositories or some equivalent respository? How are you working around the issue at the moment?

    Even if I did add this to the manifest I don't have any plans for another production release in the near future, so I'm not sure how it would solve your immediate problem.

    Cheers
    Martin

     
  • Brahmachaitanya Wajapey

    Hi Martin,

    Thanks for quick reply.

    The manifest I provided was an example for making the JAR OSGi bundle. I will use the latest version 3.3. But this version also does not have OSGi manifest.

    Yes. I can change the manifest manually and use it. That is how I am currently using it.
    But in production environment, artifacts are downloaded from central repository and that JAR will not have required manifest.

    Maven provides a plugin for creating OSGi bundles as shown below -

    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
    <instructions>
    <Bundle-Version>3.3</Bundle-Version>
    <Bundle-SymbolicName>jericho</Bundle-SymbolicName>
    <Bundle-Name>Jericho HTML Parser</Bundle-Name>
    <Import-Package> </Import-Package>
    <Export-Package> </Export-Package>
    </instructions>
    </configuration>
    </plugin>

    The Import-Package and Export-Package need to be mentioned appropriately. Once we build the code with this maven plugin, the resulting JAR will have OSGi manifest.

    On a separate note, adding OSGi compliance to JAR will not affect the normal functioning of the JAR. It can still be used like any other JAR. It is just that the JAR will have an added feature of supporting OSGi.

    Thanks and Regards
    Brahmachaitanya

     
  • Brahmachaitanya Wajapey

    Sorry Martin. In the previous post, bundle plugin is not properly displayed. So attaching a file that contains the maven plugin.

     
  • Martin Jericho

    Martin Jericho - 2013-04-15

    Hi Brahmachaitanya,

    I will once again attempt to incorporate these changes into the next official maven release, but this is likely to be several months away.

    The Import-Package I am likely to leave empty as there are no compulsory imports. The Export-Package I think only needs to contain net.htmlparser.jericho;version="3.3.0". Does that sound right?

    I would probably also make the symbolic Bundle-SymbolicName "net.htmlparser.jericho".

    Is Bundle-ManifestVersion required?

    Martin

     
  • Brahmachaitanya Wajapey

    Hi Martin,

    This is fine. Also, if we use the maven bundle plugin then it will indicate any errors we may have while creating the bundle. So once we compile with maven all the Import-Package and Export-Package will be fixed.

    Thanks and Regards
    Brahmachaitanya

     

Log in to post a comment.