You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tommy Svensson <to...@me.com> on 2012/07/21 20:17:42 UTC

maven-jar-plugin refuses to include META-INF/persistence.xml !

Hello maven fans,

I've become slightly balder today. I've been tearing my hair over why JPA keeps insisting it cannot find my persistence unit. Everything in my persistence.xml file is correct I've checked it over an over. 

I've just discovered that the problem is not in the JPA provider (tried both EclipseLink and OpenJPA), but in Maven!!!

Maven just refuses to include META-INF/persistence.xml in the jar no matter what I do! It resides in src/main/resources/META-INF. After building it is also in target/classes/META-INF along with MANIFEST.MF, but it is missing in the jar file. 

I googled and someone suggested this (yes, I'm not alone with this problem):

        <resources>
            <resource>
                <filtering>false</filtering>
                <directory>${basedir}/src/main/resources</directory>
                <includes>
                    <include>META-INF/persistence.xml</include>
                </includes>
            </resource>
        </resources>

That however had no effect what so ever. Next I tried this:

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>META-INF/persistence.xml</include>
                    </includes>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>

That didn't help either. Then I found at codehaus that this was a bug and that it was fixed in version 2.1 of the maven-jar-plugin. So I tried to add version to the plugin specification. Version 2.4 was the latest I found:

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <includes>
                        <include>META-INF/persistence.xml</include>
                    </includes>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>

That didn't work either. I'm out of ideas and my fingers hurt from all the googling. Do anyone have any idea how to solve this truly annoying problem ?

I can add that I'm also using the Apache Felix maven-bundle-plugin. I don't know if it can affect this behavior. 

Anyhow, any suggestions are appreciated. Currently I have to manually jar my project. 

Regards,
Tommy Svensson


Re: maven-jar-plugin refuses to include META-INF/persistence.xml !

Posted by Aliaksei Lahachou <al...@gmail.com>.
Which packaging do have? Can you post your POM?
Am 21.07.2012 22:51 schrieb "Tommy Svensson" <to...@me.com>:

> Hello maven fans,
>
> I've become slightly balder today. I've been tearing my hair over why JPA
> keeps insisting it cannot find my persistence unit. Everything in my
> persistence.xml file is correct I've checked it over an over.
>
> I've just discovered that the problem is not in the JPA provider (tried
> both EclipseLink and OpenJPA), but in Maven!!!
>
> Maven just refuses to include META-INF/persistence.xml in the jar no
> matter what I do! It resides in src/main/resources/META-INF. After building
> it is also in target/classes/META-INF along with MANIFEST.MF, but it is
> missing in the jar file.
>
> I googled and someone suggested this (yes, I'm not alone with this
> problem):
>
>         <resources>
>             <resource>
>                 <filtering>false</filtering>
>                 <directory>${basedir}/src/main/resources</directory>
>                 <includes>
>                     <include>META-INF/persistence.xml</include>
>                 </includes>
>             </resource>
>         </resources>
>
> That however had no effect what so ever. Next I tried this:
>
>             <plugin>
>                 <artifactId>maven-jar-plugin</artifactId>
>                 <configuration>
>                     <includes>
>                         <include>META-INF/persistence.xml</include>
>                     </includes>
>                     <archive>
>
> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
>                     </archive>
>                 </configuration>
>             </plugin>
>
> That didn't help either. Then I found at codehaus that this was a bug and
> that it was fixed in version 2.1 of the maven-jar-plugin. So I tried to add
> version to the plugin specification. Version 2.4 was the latest I found:
>
>             <plugin>
>                 <artifactId>maven-jar-plugin</artifactId>
>                 <version>2.4</version>
>                 <configuration>
>                     <includes>
>                         <include>META-INF/persistence.xml</include>
>                     </includes>
>                     <archive>
>
> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
>                     </archive>
>                 </configuration>
>             </plugin>
>
> That didn't work either. I'm out of ideas and my fingers hurt from all the
> googling. Do anyone have any idea how to solve this truly annoying problem ?
>
> I can add that I'm also using the Apache Felix maven-bundle-plugin. I
> don't know if it can affect this behavior.
>
> Anyhow, any suggestions are appreciated. Currently I have to manually jar
> my project.
>
> Regards,
> Tommy Svensson
>
>

Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Wayne Fay <wa...@gmail.com>.
>> Most likely the "bundle" packaging does not include META-INF for some
>> reason. I would talk to the Apache Felix people about this issue so
>> they can resolve it in their code.
>
> This is working as designed, as covered in the FAQ:

Thanks Stuart. This is a good thing to keep in mind for when future
felix users land here complaining about similar problems.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Stuart McCulloch <mc...@gmail.com>.
On 12 Aug 2012, at 03:54, Wayne Fay <wa...@gmail.com> wrote:

>> I'm also using the Apache Felix bundle-plugin which allows for:
>> 
>>        <packaging>bundle</packaging>
> 
> This is not a packaging delivered by Apache Maven. Thus you can
> "blame" whoever is making this packaging available to you.
> 
>> That is, I can use either or of "bundle" or "jar" for packaging. However when i use:
>> 
>>        <packaging>bundle</packaging>
>> 
>> I don't get the META-INF/persistence.xml file in the jar.
> 
> Most likely the "bundle" packaging does not include META-INF for some
> reason. I would talk to the Apache Felix people about this issue so
> they can resolve it in their code.

This is working as designed, as covered in the FAQ:

   http://felix.apache.org/site/apache-felix-bundle-plugin-faq.html#ApacheFelixBundlePluginFAQ-WhenIbuildabundle%252Csomeclassesarebuiltin%2522target%252Fclasses%2522butthey%2527renotincludedinthefinaljar.

Not everything in target/classes ends up in the bundle by default (unlike jar) - the underlying bnd library will only pull what resources/packages you tell it to into the bundle. While the plugin attempts to generate reasonable defaults based on your source, it can't do this for generated resources such as this persistence.xml file (see last FAQ item). Instead you need something like:

   <Include-Resource>{maven-resources}, META-INF/persistence.xml=target/classes/META-INF/persistence.xml</Include-Resource>

Where {maven-resources} is a placeholder for the default detected resources, as described in the Include-Resource section of http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

The raw format of bnd's Include-Resource instruction can be found at http://www.aqute.biz/Bnd/Format#include-resource

HTH

--
Cheers, Stuart

> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Wayne Fay <wa...@gmail.com>.
> I'm also using the Apache Felix bundle-plugin which allows for:
>
>         <packaging>bundle</packaging>

This is not a packaging delivered by Apache Maven. Thus you can
"blame" whoever is making this packaging available to you.

> That is, I can use either or of "bundle" or "jar" for packaging. However when i use:
>
>         <packaging>bundle</packaging>
>
> I don't get the META-INF/persistence.xml file in the jar.

Most likely the "bundle" packaging does not include META-INF for some
reason. I would talk to the Apache Felix people about this issue so
they can resolve it in their code.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Mark Derricutt <ma...@talios.com>.
If you use the <packaging>bundle</packaging> style in your pom, then its bnd that does the actual jar creation, and NOT the traditional jar plugin.

We hit this same issue awhile ago when including compiled coffee-script into our jars, just putting them directly in target/classes doesn't "just work".

Mark

On 13/08/2012, at 2:29 AM, Tommy Svensson <to...@natusoft.se> wrote:

> I didn't know that the bundle-plugin affected jar:ing. I thought it just packaged things correctly under target and then the maven-jar-plugin did the rest. 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Martin Gainty <mg...@hotmail.com>.
from now on we're going to rely on you... as our BND expert!

Glad to hear that worked
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


> Subject: Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved
> From: tommy@natusoft.se
> Date: Sun, 12 Aug 2012 16:29:18 +0200
> To: users@maven.apache.org
> 
> I pulled those parts out and replaced them with "..." to make the example smaller. I didn't think those parts relevant, but apparently they are since the following suggested by Stuart McCulloch does work:
> 
> 	<Include-Resource>{maven-resources}, META-INF/persistence.xml=target/classes/META-INF/persistence.xml</Include-Resource>
> 
> I didn't know that the bundle-plugin affected jar:ing. I thought it just packaged things correctly under target and then the maven-jar-plugin did the rest. 
> 
> I'm starting to realize that just assuming is probably a bad idea ...
> 
> /Tommy 
> 
> 12 aug 2012 kl. 03:54 skrev Martin Gainty <mg...@hotmail.com>:
> 
> > 
> > http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
> > 
> > I didnt see your  
> > Export-Package
> > Private-Package
> > Bundle-Activator
> > At execution time you will need to config the maven-bundle-plugin with configuration instructions such as what is here:
> > <build>
> >   <plugins>
> >     <plugin>    <!-- (2) START -->
> >       <groupId>org.apache.felix</groupId>
> >       <artifactId>maven-bundle-plugin</artifactId>
> >       <extensions>true</extensions>
> >       <configuration>
> >         <instructions>
> >           <Export-Package>com.my.company.api</Export-Package>
> >           <Private-Package>com.my.company.*</Private-Package>
> >           <Bundle-Activator>com.my.company.Activator</Bundle-Activator>
> >         </instructions>
> >       </configuration>
> >     </plugin>    <!-- (2) END -->
> >   </plugins>
> > </build> The Export-Package of com.my.company.api indicates
> > the plugin will copy the Log Service package into the resulting bundle JAR file and export to other bundles
> > The Private-Package of com.my.company.* indicates
> > the available package(s) to copy into the bundle but NOT export to other bundles
> > 
> > But if you really want total control of your bundle you'll want to learn BND
> > The *best* example of BND configuration and an explanation of BND supported attributes are located here
> > http://www.aqute.biz/Bnd/Bnd
> > 
> > Martin Gainty 
> > ______________________________________________ 
> > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
> > 
> > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> > 
> > 
> >> From: tommybsvensson@me.com
> >> Subject: Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved
> >> Date: Sat, 11 Aug 2012 18:56:43 +0200
> >> To: users@maven.apache.org
> >> 
> >> I finally found the source of this problem! Or close to it at least. I have managed to get my META-INF/persistence.xml included in the jar, but I'm unsure what is to blame :-).
> >> 
> >> I'm also using the Apache Felix bundle-plugin which allows for:
> >> 
> >> 	<packaging>bundle</packaging>
> >> 
> >> This due to the following configuration:
> >> 
> >>           <plugin>
> >>               <groupId>org.apache.felix</groupId>
> >>               <artifactId>maven-bundle-plugin</artifactId>
> >>               <version>2.3.5</version>
> >>               <extensions>true</extensions>
> >>              ...
> >>               <configuration>
> >>                   <supportedProjectTypes>
> >>                       <supportedProjectType>jar</supportedProjectType>
> >>                       <supportedProjectType>bundle</supportedProjectType>
> >>                   </supportedProjectTypes>
> >>                   ...
> >>               </configuration>
> >>           </plugin>
> >> 
> >> That is, I can use either or of "bundle" or "jar" for packaging. However when i use:
> >> 
> >> 	<packaging>bundle</packaging>
> >> 
> >> I don't get the META-INF/persistence.xml file in the jar.
> >> 
> >> But when I change to:
> >> 
> >> 	<packaging>jar</packaging>
> >> 
> >> It is included! So my guess is that the maven-jar-plugin is affected by the packaging. The Felix bundle-plugin still works OK with packaging "jar" so I'll stick with that for now on.
> >> 
> >> /Tommy
> >> 
> >> 22 jul 2012 kl. 18:27 skrev Wayne Fay <wa...@gmail.com>:
> >> 
> >>>> I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right
> >>>> Wayne, I need to isolate what is causing this. Thanks.
> >>> 
> >>> If META-INF/persistence.xml was not even showing up in target, then we
> >>> might be able to provide a simple "recipe" to solve it. But that is
> >>> not the case here. Come back and let us know when you solve it.
> >>> 
> >>> Wayne
> >>> 
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>> For additional commands, e-mail: users-help@maven.apache.org
> >>> 
> >> 
> > 		 	   		  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
 		 	   		  

Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Tommy Svensson <to...@natusoft.se>.
I pulled those parts out and replaced them with "..." to make the example smaller. I didn't think those parts relevant, but apparently they are since the following suggested by Stuart McCulloch does work:

	<Include-Resource>{maven-resources}, META-INF/persistence.xml=target/classes/META-INF/persistence.xml</Include-Resource>

I didn't know that the bundle-plugin affected jar:ing. I thought it just packaged things correctly under target and then the maven-jar-plugin did the rest. 

I'm starting to realize that just assuming is probably a bad idea ...

/Tommy 

12 aug 2012 kl. 03:54 skrev Martin Gainty <mg...@hotmail.com>:

> 
> http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
> 
> I didnt see your  
> Export-Package
> Private-Package
> Bundle-Activator
> At execution time you will need to config the maven-bundle-plugin with configuration instructions such as what is here:
> <build>
>   <plugins>
>     <plugin>    <!-- (2) START -->
>       <groupId>org.apache.felix</groupId>
>       <artifactId>maven-bundle-plugin</artifactId>
>       <extensions>true</extensions>
>       <configuration>
>         <instructions>
>           <Export-Package>com.my.company.api</Export-Package>
>           <Private-Package>com.my.company.*</Private-Package>
>           <Bundle-Activator>com.my.company.Activator</Bundle-Activator>
>         </instructions>
>       </configuration>
>     </plugin>    <!-- (2) END -->
>   </plugins>
> </build> The Export-Package of com.my.company.api indicates
> the plugin will copy the Log Service package into the resulting bundle JAR file and export to other bundles
> The Private-Package of com.my.company.* indicates
> the available package(s) to copy into the bundle but NOT export to other bundles
> 
> But if you really want total control of your bundle you'll want to learn BND
> The *best* example of BND configuration and an explanation of BND supported attributes are located here
> http://www.aqute.biz/Bnd/Bnd
> 
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
> 
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
>> From: tommybsvensson@me.com
>> Subject: Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved
>> Date: Sat, 11 Aug 2012 18:56:43 +0200
>> To: users@maven.apache.org
>> 
>> I finally found the source of this problem! Or close to it at least. I have managed to get my META-INF/persistence.xml included in the jar, but I'm unsure what is to blame :-).
>> 
>> I'm also using the Apache Felix bundle-plugin which allows for:
>> 
>> 	<packaging>bundle</packaging>
>> 
>> This due to the following configuration:
>> 
>>           <plugin>
>>               <groupId>org.apache.felix</groupId>
>>               <artifactId>maven-bundle-plugin</artifactId>
>>               <version>2.3.5</version>
>>               <extensions>true</extensions>
>>              ...
>>               <configuration>
>>                   <supportedProjectTypes>
>>                       <supportedProjectType>jar</supportedProjectType>
>>                       <supportedProjectType>bundle</supportedProjectType>
>>                   </supportedProjectTypes>
>>                   ...
>>               </configuration>
>>           </plugin>
>> 
>> That is, I can use either or of "bundle" or "jar" for packaging. However when i use:
>> 
>> 	<packaging>bundle</packaging>
>> 
>> I don't get the META-INF/persistence.xml file in the jar.
>> 
>> But when I change to:
>> 
>> 	<packaging>jar</packaging>
>> 
>> It is included! So my guess is that the maven-jar-plugin is affected by the packaging. The Felix bundle-plugin still works OK with packaging "jar" so I'll stick with that for now on.
>> 
>> /Tommy
>> 
>> 22 jul 2012 kl. 18:27 skrev Wayne Fay <wa...@gmail.com>:
>> 
>>>> I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right
>>>> Wayne, I need to isolate what is causing this. Thanks.
>>> 
>>> If META-INF/persistence.xml was not even showing up in target, then we
>>> might be able to provide a simple "recipe" to solve it. But that is
>>> not the case here. Come back and let us know when you solve it.
>>> 
>>> Wayne
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>> 
>> 
> 		 	   		  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Martin Gainty <mg...@hotmail.com>.
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

I didnt see your  
Export-Package
Private-Package
Bundle-Activator
At execution time you will need to config the maven-bundle-plugin with configuration instructions such as what is here:
 <build>
    <plugins>
      <plugin>    <!-- (2) START -->
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Export-Package>com.my.company.api</Export-Package>
            <Private-Package>com.my.company.*</Private-Package>
            <Bundle-Activator>com.my.company.Activator</Bundle-Activator>
          </instructions>
        </configuration>
      </plugin>    <!-- (2) END -->
    </plugins>
  </build> The Export-Package of com.my.company.api indicates
the plugin will copy the Log Service package into the resulting bundle JAR file and export to other bundles
The Private-Package of com.my.company.* indicates
the available package(s) to copy into the bundle but NOT export to other bundles

But if you really want total control of your bundle you'll want to learn BND
The *best* example of BND configuration and an explanation of BND supported attributes are located here
http://www.aqute.biz/Bnd/Bnd

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


> From: tommybsvensson@me.com
> Subject: Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved
> Date: Sat, 11 Aug 2012 18:56:43 +0200
> To: users@maven.apache.org
> 
> I finally found the source of this problem! Or close to it at least. I have managed to get my META-INF/persistence.xml included in the jar, but I'm unsure what is to blame :-).
> 
> I'm also using the Apache Felix bundle-plugin which allows for:
> 
> 	<packaging>bundle</packaging>
> 
> This due to the following configuration:
> 
>             <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <version>2.3.5</version>
>                 <extensions>true</extensions>
>                ...
>                 <configuration>
>                     <supportedProjectTypes>
>                         <supportedProjectType>jar</supportedProjectType>
>                         <supportedProjectType>bundle</supportedProjectType>
>                     </supportedProjectTypes>
>                     ...
>                 </configuration>
>             </plugin>
> 
> That is, I can use either or of "bundle" or "jar" for packaging. However when i use:
> 
> 	<packaging>bundle</packaging>
> 
> I don't get the META-INF/persistence.xml file in the jar.
> 
> But when I change to:
> 
> 	<packaging>jar</packaging>
> 
> It is included! So my guess is that the maven-jar-plugin is affected by the packaging. The Felix bundle-plugin still works OK with packaging "jar" so I'll stick with that for now on.
> 
> /Tommy
> 
> 22 jul 2012 kl. 18:27 skrev Wayne Fay <wa...@gmail.com>:
> 
> >> I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right
> >> Wayne, I need to isolate what is causing this. Thanks.
> > 
> > If META-INF/persistence.xml was not even showing up in target, then we
> > might be able to provide a simple "recipe" to solve it. But that is
> > not the case here. Come back and let us know when you solve it.
> > 
> > Wayne
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> > 
> 
 		 	   		  

Re: maven-jar-plugin refuses to include META-INF/persistence.xml ! - Problem solved

Posted by Tommy Svensson <to...@me.com>.
I finally found the source of this problem! Or close to it at least. I have managed to get my META-INF/persistence.xml included in the jar, but I'm unsure what is to blame :-).

I'm also using the Apache Felix bundle-plugin which allows for:

	<packaging>bundle</packaging>

This due to the following configuration:

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.5</version>
                <extensions>true</extensions>
               ...
                <configuration>
                    <supportedProjectTypes>
                        <supportedProjectType>jar</supportedProjectType>
                        <supportedProjectType>bundle</supportedProjectType>
                    </supportedProjectTypes>
                    ...
                </configuration>
            </plugin>

That is, I can use either or of "bundle" or "jar" for packaging. However when i use:

	<packaging>bundle</packaging>

I don't get the META-INF/persistence.xml file in the jar.

But when I change to:

	<packaging>jar</packaging>

It is included! So my guess is that the maven-jar-plugin is affected by the packaging. The Felix bundle-plugin still works OK with packaging "jar" so I'll stick with that for now on.

/Tommy

22 jul 2012 kl. 18:27 skrev Wayne Fay <wa...@gmail.com>:

>> I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right
>> Wayne, I need to isolate what is causing this. Thanks.
> 
> If META-INF/persistence.xml was not even showing up in target, then we
> might be able to provide a simple "recipe" to solve it. But that is
> not the case here. Come back and let us know when you solve it.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


Re: maven-jar-plugin refuses to include META-INF/persistence.xml !

Posted by Wayne Fay <wa...@gmail.com>.
> I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right
> Wayne, I need to isolate what is causing this. Thanks.

If META-INF/persistence.xml was not even showing up in target, then we
might be able to provide a simple "recipe" to solve it. But that is
not the case here. Come back and let us know when you solve it.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-jar-plugin refuses to include META-INF/persistence.xml !

Posted by Tommy Svensson <to...@natusoft.se>.
I was hoping for a "Well, thats easy, just do ..." :-). But you are of course right Wayne, I need to isolate what is causing this. Thanks.

/Tommy

22 jul 2012 kl. 05:30 skrev Wayne Fay:

>> Maven just refuses to include META-INF/persistence.xml in the jar no matter
>> what I do! It resides in src/main/resources/META-INF. After building it is also
>> in target/classes/META-INF along with MANIFEST.MF, but it is missing in the
>> jar file.
> 
> Try a very simple test...
> Run "mvn archetype:generate" (and pick maven-archetype-quickstart
> which is 205 for me). Specify whatever values when prompted.
> Then "mkdir src/main/resources/META-INF".
> Copy your persistence.xml file there.
> Run "mvn package" from the project directory.
> Then "cd target" and "jar -tvf blah-1.0-SNAPSHOT.jar | grep
> persistence" and see if it is in the jar.
> 
> If so, there *must* be some additional configuration which you are
> applying which is causing this to fail.
> 
> "mvn help:effective-pom" might be helpful in tracking this down more.
> I would remove as much configuration from your pom as possible while
> keeping the basic functionality you require.
> 
>> I can add that I'm also using the Apache Felix maven-bundle-plugin. I don't know
>> if it can affect this behavior.
> 
> No clue. If your test above works, I'd try to build things without
> this plugin and see if the problem goes away. If that works, I'd ask
> the Apache Felix team about it. Perhaps they are doing something funky
> which causes this file to not be included in your artifacts.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-jar-plugin refuses to include META-INF/persistence.xml !

Posted by Wayne Fay <wa...@gmail.com>.
> Maven just refuses to include META-INF/persistence.xml in the jar no matter
> what I do! It resides in src/main/resources/META-INF. After building it is also
> in target/classes/META-INF along with MANIFEST.MF, but it is missing in the
> jar file.

Try a very simple test...
Run "mvn archetype:generate" (and pick maven-archetype-quickstart
which is 205 for me). Specify whatever values when prompted.
Then "mkdir src/main/resources/META-INF".
Copy your persistence.xml file there.
Run "mvn package" from the project directory.
Then "cd target" and "jar -tvf blah-1.0-SNAPSHOT.jar | grep
persistence" and see if it is in the jar.

If so, there *must* be some additional configuration which you are
applying which is causing this to fail.

"mvn help:effective-pom" might be helpful in tracking this down more.
I would remove as much configuration from your pom as possible while
keeping the basic functionality you require.

> I can add that I'm also using the Apache Felix maven-bundle-plugin. I don't know
> if it can affect this behavior.

No clue. If your test above works, I'd try to build things without
this plugin and see if the problem goes away. If that works, I'd ask
the Apache Felix team about it. Perhaps they are doing something funky
which causes this file to not be included in your artifacts.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org