Plugins.dat file not packing with jar for OSGi bundle

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugins.dat file not packing with jar for OSGi bundle

Asma Zinneera Jabir
I want to create an osgi bundle with custom appenders in it and tried with
creating a simple maven project. The Plugins.dat file gets packed in the
jar with the simple maven pom. When I add the apache felix plugin and
change packaging to bundle  to make it an OSGI bundle the Plugins.dat does
not get packed. The pom elements I used to convert it to an OSGI
 bundle is as below.

 <packaging>bundle</packaging>  and

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>3.0.1</version>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Bundle-Name>${project.artifactId}</Bundle-Name>
            <Bundle-Version>1.0.0</Bundle-Version>
            <Fragment-Host>com.example.host.bundle</Fragment-Host>
            <Export-Package>
                com.example.log4j2.plugins.*
            </Export-Package>
            <DynamicImport-Package>
                *;resolution:=optional
            </DynamicImport-Package>
            <Import-Package>
                !com.example.log4j2.plugins.*
            </Import-Package>
        </instructions>
    </configuration>
</plugin>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins.dat file not packing with jar for OSGi bundle

Matt Sicker
Sounds like this could be a bug with the maven-bundle-plugin. Have you
tried bnd-maven-plugin? <http://bndtools.org/>

Also, chances are there could be some ClassLoader issues anyways
considering all the log4j-core imports we've added to log4j-api to fix
similar issues. If you have issues with that, a bug report would be great.

On 7 September 2017 at 13:11, Asma Zinneera Jabir <[hidden email]>
wrote:

> I want to create an osgi bundle with custom appenders in it and tried with
> creating a simple maven project. The Plugins.dat file gets packed in the
> jar with the simple maven pom. When I add the apache felix plugin and
> change packaging to bundle  to make it an OSGI bundle the Plugins.dat does
> not get packed. The pom elements I used to convert it to an OSGI
>  bundle is as below.
>
>  <packaging>bundle</packaging>  and
>
> <plugin>
>     <groupId>org.apache.felix</groupId>
>     <artifactId>maven-bundle-plugin</artifactId>
>     <version>3.0.1</version>
>     <extensions>true</extensions>
>     <configuration>
>         <instructions>
>             <Bundle-SymbolicName>${project.artifactId}</Bundle-
> SymbolicName>
>             <Bundle-Name>${project.artifactId}</Bundle-Name>
>             <Bundle-Version>1.0.0</Bundle-Version>
>             <Fragment-Host>com.example.host.bundle</Fragment-Host>
>             <Export-Package>
>                 com.example.log4j2.plugins.*
>             </Export-Package>
>             <DynamicImport-Package>
>                 *;resolution:=optional
>             </DynamicImport-Package>
>             <Import-Package>
>                 !com.example.log4j2.plugins.*
>             </Import-Package>
>         </instructions>
>     </configuration>
> </plugin>
>



--
Matt Sicker <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins.dat file not packing with jar for OSGi bundle

Asma Zinneera Jabir
Solved this.

The resources aren't packed to the bundle by default. I used
<Include-Resource> to pack the resources. You can refer Apache Felix Maven
Bundle Plugin (BND) Documentation
<http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html>
Added the following line after <Import-Package>

<Include-Resource>${project.build.directory}/classes/</Include-Resource>


On Fri, Sep 8, 2017 at 10:18 AM, Matt Sicker <[hidden email]> wrote:

> Sounds like this could be a bug with the maven-bundle-plugin. Have you
> tried bnd-maven-plugin? <http://bndtools.org/>
>
> Also, chances are there could be some ClassLoader issues anyways
> considering all the log4j-core imports we've added to log4j-api to fix
> similar issues. If you have issues with that, a bug report would be great.
>
> On 7 September 2017 at 13:11, Asma Zinneera Jabir <[hidden email]>
> wrote:
>
> > I want to create an osgi bundle with custom appenders in it and tried
> with
> > creating a simple maven project. The Plugins.dat file gets packed in the
> > jar with the simple maven pom. When I add the apache felix plugin and
> > change packaging to bundle  to make it an OSGI bundle the Plugins.dat
> does
> > not get packed. The pom elements I used to convert it to an OSGI
> >  bundle is as below.
> >
> >  <packaging>bundle</packaging>  and
> >
> > <plugin>
> >     <groupId>org.apache.felix</groupId>
> >     <artifactId>maven-bundle-plugin</artifactId>
> >     <version>3.0.1</version>
> >     <extensions>true</extensions>
> >     <configuration>
> >         <instructions>
> >             <Bundle-SymbolicName>${project.artifactId}</Bundle-
> > SymbolicName>
> >             <Bundle-Name>${project.artifactId}</Bundle-Name>
> >             <Bundle-Version>1.0.0</Bundle-Version>
> >             <Fragment-Host>com.example.host.bundle</Fragment-Host>
> >             <Export-Package>
> >                 com.example.log4j2.plugins.*
> >             </Export-Package>
> >             <DynamicImport-Package>
> >                 *;resolution:=optional
> >             </DynamicImport-Package>
> >             <Import-Package>
> >                 !com.example.log4j2.plugins.*
> >             </Import-Package>
> >         </instructions>
> >     </configuration>
> > </plugin>
> >
>
>
>
> --
> Matt Sicker <[hidden email]>
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins.dat file not packing with jar for OSGi bundle

Matt Sicker
Thanks for the update! This may be useful to add to the manual.

https://issues.apache.org/jira/browse/LOG4J2-2040

On 8 September 2017 at 01:11, Asma Zinneera Jabir <[hidden email]>
wrote:

> Solved this.
>
> The resources aren't packed to the bundle by default. I used
> <Include-Resource> to pack the resources. You can refer Apache Felix Maven
> Bundle Plugin (BND) Documentation
> <http://felix.apache.org/documentation/subprojects/
> apache-felix-maven-bundle-plugin-bnd.html>
> Added the following line after <Import-Package>
>
> <Include-Resource>${project.build.directory}/classes/</Include-Resource>
>
>
> On Fri, Sep 8, 2017 at 10:18 AM, Matt Sicker <[hidden email]> wrote:
>
> > Sounds like this could be a bug with the maven-bundle-plugin. Have you
> > tried bnd-maven-plugin? <http://bndtools.org/>
> >
> > Also, chances are there could be some ClassLoader issues anyways
> > considering all the log4j-core imports we've added to log4j-api to fix
> > similar issues. If you have issues with that, a bug report would be
> great.
> >
> > On 7 September 2017 at 13:11, Asma Zinneera Jabir <[hidden email]>
> > wrote:
> >
> > > I want to create an osgi bundle with custom appenders in it and tried
> > with
> > > creating a simple maven project. The Plugins.dat file gets packed in
> the
> > > jar with the simple maven pom. When I add the apache felix plugin and
> > > change packaging to bundle  to make it an OSGI bundle the Plugins.dat
> > does
> > > not get packed. The pom elements I used to convert it to an OSGI
> > >  bundle is as below.
> > >
> > >  <packaging>bundle</packaging>  and
> > >
> > > <plugin>
> > >     <groupId>org.apache.felix</groupId>
> > >     <artifactId>maven-bundle-plugin</artifactId>
> > >     <version>3.0.1</version>
> > >     <extensions>true</extensions>
> > >     <configuration>
> > >         <instructions>
> > >             <Bundle-SymbolicName>${project.artifactId}</Bundle-
> > > SymbolicName>
> > >             <Bundle-Name>${project.artifactId}</Bundle-Name>
> > >             <Bundle-Version>1.0.0</Bundle-Version>
> > >             <Fragment-Host>com.example.host.bundle</Fragment-Host>
> > >             <Export-Package>
> > >                 com.example.log4j2.plugins.*
> > >             </Export-Package>
> > >             <DynamicImport-Package>
> > >                 *;resolution:=optional
> > >             </DynamicImport-Package>
> > >             <Import-Package>
> > >                 !com.example.log4j2.plugins.*
> > >             </Import-Package>
> > >         </instructions>
> > >     </configuration>
> > > </plugin>
> > >
> >
> >
> >
> > --
> > Matt Sicker <[hidden email]>
> >
>



--
Matt Sicker <[hidden email]>