You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by jm...@gmail.com on 2009/12/10 21:41:08 UTC

including resources in classpath for tests

I've hit a roadblock and haven't been able to find a solution through the wiki, mailing list or google. 

I have a persistence.xml file which contains hibernate configuration information,  http://pastie.org/737850
It is located in src/test/resources/META-INF/

my buildfile has the following two lines:

compile.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, GUICE
test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, DOM4J, HSQLDB, GUICE

the tests are failing because it can't find the persistence.xml file. How and where does the test task load the
resources? I tried doing some hacks like importing it into the classpath but that doesn't seem to help:


Java.classpath << _('src/test/resource/META-INF/persistence.xml')
test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, DOM4J, HSQLDB, GUICE

Any thoughts?

Thanks
jesus rodriguez

Re: including resources in classpath for tests

Posted by Alex Boisvert <al...@gmail.com>.
Hi Peter,

This seems to be a different issue.   You're using the open_jpa_enhance task
but in persistence.xml you're specifying the Hibernate persistence manager:

<provider>org.hibernate.ejb.HibernatePersistence</provider>

Using Hibernate here requires a different set of classpath libraries.    The
default classpath assumes you're using OpenJPA as provider.

If I comment the line above, the build runs fine.

alex


On Thu, Dec 10, 2009 at 10:37 PM, Peter Schröder <ps...@blau.de> wrote:

> i didnt dig into this any deeper. it fails with:
>
> Compiling killer-app:teh-impl into
> /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/target/classes
> WARNING: Unable to load persistence provider
> "org.hibernate.ejb.HibernatePersistence" due to
> "java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence"
> E, [2009-12-11T07:30:21.868000 #17051] ERROR -- : Error instantiating
> 'enhancer' task: org.apache.tools.ant.BuildException:
> java.util.MissingResourceException:
> /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/src/main/resources/META-INF/persistence.xml
> Buildr aborted!
> org.apache.tools.ant.BuildException: java.util.MissingResourceException:
> /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/src/main/resources/META-INF/persistence.xml
> /Users/peterschroder/ruby/buildr-examples/projects/killer-app/buildfile:37
>
>
>
> ___________________________________________________________
> Peter Schröder
> IT-Development
>
> blau Mobilfunk GmbH  *  Schulterblatt 124  *  20357 Hamburg
>
> T   +49 (0)40 288 071-44                M   +49 (0)178 1391035
> F   +49 (0)40 288 071-71                E    ps@blau.de
>
> www.blau.de   Sei schlau, telefonier blau. - Frei telefonieren für nur 9
> Cent/Min. & SMS
> www.blauworld.de   the call home SIM - Günstig ab 5 Cent/Min. ins Ausland
> telefonieren
> www.blux.de   bestens.günstig.fairsorgt - Ökostrom & Gas ohne
> Vertragsbindung
> www.blauworld.voicecash.de   die blauworld Prepaid MasterCard(R) - Günstig
> weltweit Geld übertragen
>
> blau.de wurde vom Deutschen Institut für Service-Qualität als "Bester
> Mobilfunkanbieter 2009" ausgezeichnet. Getestet wurden 19 Mobilfunkanbieter
> Deutschlands.
>
> Sitz: Hamburg, HRB 80531 Amtsgericht Hamburg
> Geschäftsführer: Dirk Freise, Martin Ostermayer, Thorsten Rehling
> ________________________________________
> Von: Alex Boisvert [alex.boisvert@gmail.com]
> Gesendet: Donnerstag, 10. Dezember 2009 23:04
> An: users@buildr.apache.org
> Betreff: Re: including resources in classpath for tests
>
> Anything under src/test/resources should automatically be in the classpath
> for test execution.
>
> You can add other resource locations by using test.with
> _("path/to/other/location"")
>
> If you can send a (small) project that illustrates the issue, I'm sure I
> can
> help you further.
>
> alex
>
> On Thu, Dec 10, 2009 at 1:39 PM, Peter Schröder <ps...@blau.de> wrote:
>
> > hi jesus,
> >
> > are you working with jpa compiler? i tried to follow the example provided
> > in the buildr docs, but i could not get it working.
> >
> > it always fails with a java.util.MissingResourceException which i thought
> > might be related to http://issues.apache.org/jira/browse/OPENJPA-889
> >
> > i dont have knowledge of using jpa, so i skipped that example...
> >
> > kind regards,
> > peter
> >
> > ________________________________________
> > Von: jmrodri@gmail.com [jmrodri@gmail.com]
> > Gesendet: Donnerstag, 10. Dezember 2009 21:41
> > An: users@buildr.apache.org
> > Betreff: including resources in classpath for tests
> >
> > I've hit a roadblock and haven't been able to find a solution through the
> > wiki, mailing list or google.
> >
> > I have a persistence.xml file which contains hibernate configuration
> > information,  http://pastie.org/737850
> > It is located in src/test/resources/META-INF/
> >
> > my buildfile has the following two lines:
> >
> > compile.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE,
> > JDOM, GUICE
> > test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE,
> JDOM,
> > DOM4J, HSQLDB, GUICE
> >
> > the tests are failing because it can't find the persistence.xml file. How
> > and where does the test task load the
> > resources? I tried doing some hacks like importing it into the classpath
> > but that doesn't seem to help:
> >
> >
> > Java.classpath << _('src/test/resource/META-INF/persistence.xml')
> > test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE,
> JDOM,
> > DOM4J, HSQLDB, GUICE
> >
> > Any thoughts?
> >
> > Thanks
> > jesus rodriguez
> >
>

AW: including resources in classpath for tests

Posted by Peter Schröder <ps...@blau.de>.
i didnt dig into this any deeper. it fails with:

Compiling killer-app:teh-impl into /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/target/classes
WARNING: Unable to load persistence provider "org.hibernate.ejb.HibernatePersistence" due to "java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence"
E, [2009-12-11T07:30:21.868000 #17051] ERROR -- : Error instantiating 'enhancer' task: org.apache.tools.ant.BuildException: java.util.MissingResourceException: /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/src/main/resources/META-INF/persistence.xml
Buildr aborted!
org.apache.tools.ant.BuildException: java.util.MissingResourceException: /Users/peterschroder/ruby/buildr-examples/projects/killer-app/teh-impl/src/main/resources/META-INF/persistence.xml
/Users/peterschroder/ruby/buildr-examples/projects/killer-app/buildfile:37



___________________________________________________________
Peter Schröder
IT-Development

blau Mobilfunk GmbH  ∙  Schulterblatt 124  ∙  20357 Hamburg

T   +49 (0)40 288 071-44                M   +49 (0)178 1391035
F   +49 (0)40 288 071-71                E    ps@blau.de

www.blau.de   Sei schlau, telefonier blau. – Frei telefonieren für nur 9 Cent/Min. & SMS
www.blauworld.de   the call home SIM – Günstig ab 5 Cent/Min. ins Ausland telefonieren
www.blux.de   bestens.günstig.fairsorgt – Ökostrom & Gas ohne Vertragsbindung
www.blauworld.voicecash.de   die blauworld Prepaid MasterCard® – Günstig weltweit Geld übertragen

blau.de wurde vom Deutschen Institut für Service-Qualität als „Bester Mobilfunkanbieter 2009“ ausgezeichnet. Getestet wurden 19 Mobilfunkanbieter Deutschlands.

Sitz: Hamburg, HRB 80531 Amtsgericht Hamburg
Geschäftsführer: Dirk Freise, Martin Ostermayer, Thorsten Rehling
________________________________________
Von: Alex Boisvert [alex.boisvert@gmail.com]
Gesendet: Donnerstag, 10. Dezember 2009 23:04
An: users@buildr.apache.org
Betreff: Re: including resources in classpath for tests

Anything under src/test/resources should automatically be in the classpath
for test execution.

You can add other resource locations by using test.with
_("path/to/other/location"")

If you can send a (small) project that illustrates the issue, I'm sure I can
help you further.

alex

On Thu, Dec 10, 2009 at 1:39 PM, Peter Schröder <ps...@blau.de> wrote:

> hi jesus,
>
> are you working with jpa compiler? i tried to follow the example provided
> in the buildr docs, but i could not get it working.
>
> it always fails with a java.util.MissingResourceException which i thought
> might be related to http://issues.apache.org/jira/browse/OPENJPA-889
>
> i dont have knowledge of using jpa, so i skipped that example...
>
> kind regards,
> peter
>
> ________________________________________
> Von: jmrodri@gmail.com [jmrodri@gmail.com]
> Gesendet: Donnerstag, 10. Dezember 2009 21:41
> An: users@buildr.apache.org
> Betreff: including resources in classpath for tests
>
> I've hit a roadblock and haven't been able to find a solution through the
> wiki, mailing list or google.
>
> I have a persistence.xml file which contains hibernate configuration
> information,  http://pastie.org/737850
> It is located in src/test/resources/META-INF/
>
> my buildfile has the following two lines:
>
> compile.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE,
> JDOM, GUICE
> test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM,
> DOM4J, HSQLDB, GUICE
>
> the tests are failing because it can't find the persistence.xml file. How
> and where does the test task load the
> resources? I tried doing some hacks like importing it into the classpath
> but that doesn't seem to help:
>
>
> Java.classpath << _('src/test/resource/META-INF/persistence.xml')
> test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM,
> DOM4J, HSQLDB, GUICE
>
> Any thoughts?
>
> Thanks
> jesus rodriguez
>

Re: including resources in classpath for tests

Posted by Alex Boisvert <al...@gmail.com>.
Anything under src/test/resources should automatically be in the classpath
for test execution.

You can add other resource locations by using test.with
_("path/to/other/location"")

If you can send a (small) project that illustrates the issue, I'm sure I can
help you further.

alex

On Thu, Dec 10, 2009 at 1:39 PM, Peter Schröder <ps...@blau.de> wrote:

> hi jesus,
>
> are you working with jpa compiler? i tried to follow the example provided
> in the buildr docs, but i could not get it working.
>
> it always fails with a java.util.MissingResourceException which i thought
> might be related to http://issues.apache.org/jira/browse/OPENJPA-889
>
> i dont have knowledge of using jpa, so i skipped that example...
>
> kind regards,
> peter
>
> ________________________________________
> Von: jmrodri@gmail.com [jmrodri@gmail.com]
> Gesendet: Donnerstag, 10. Dezember 2009 21:41
> An: users@buildr.apache.org
> Betreff: including resources in classpath for tests
>
> I've hit a roadblock and haven't been able to find a solution through the
> wiki, mailing list or google.
>
> I have a persistence.xml file which contains hibernate configuration
> information,  http://pastie.org/737850
> It is located in src/test/resources/META-INF/
>
> my buildfile has the following two lines:
>
> compile.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE,
> JDOM, GUICE
> test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM,
> DOM4J, HSQLDB, GUICE
>
> the tests are failing because it can't find the persistence.xml file. How
> and where does the test task load the
> resources? I tried doing some hacks like importing it into the classpath
> but that doesn't seem to help:
>
>
> Java.classpath << _('src/test/resource/META-INF/persistence.xml')
> test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM,
> DOM4J, HSQLDB, GUICE
>
> Any thoughts?
>
> Thanks
> jesus rodriguez
>

AW: including resources in classpath for tests

Posted by Peter Schröder <ps...@blau.de>.
hi jesus,

are you working with jpa compiler? i tried to follow the example provided in the buildr docs, but i could not get it working.

it always fails with a java.util.MissingResourceException which i thought might be related to http://issues.apache.org/jira/browse/OPENJPA-889

i dont have knowledge of using jpa, so i skipped that example...

kind regards,
peter

________________________________________
Von: jmrodri@gmail.com [jmrodri@gmail.com]
Gesendet: Donnerstag, 10. Dezember 2009 21:41
An: users@buildr.apache.org
Betreff: including resources in classpath for tests

I've hit a roadblock and haven't been able to find a solution through the wiki, mailing list or google.

I have a persistence.xml file which contains hibernate configuration information,  http://pastie.org/737850
It is located in src/test/resources/META-INF/

my buildfile has the following two lines:

compile.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, GUICE
test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, DOM4J, HSQLDB, GUICE

the tests are failing because it can't find the persistence.xml file. How and where does the test task load the
resources? I tried doing some hacks like importing it into the classpath but that doesn't seem to help:


Java.classpath << _('src/test/resource/META-INF/persistence.xml')
test.with COMMONS, DB, JERSEY, JUNIT, LOG4J, HIBERNATE, BOUNCYCASTLE, JDOM, DOM4J, HSQLDB, GUICE

Any thoughts?

Thanks
jesus rodriguez