You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Giovanni Azua <br...@swissonline.ch> on 2007/11/30 23:17:23 UTC
errors for hibernate test cases
hi,
I have a set of test cases that pass fine under Eclipse .. but from Maven I
get java.lang.NoClassDefFoundError when running
TestHibernateGenericReadOnlyDao and TestHibernateGenericDao (see below).
My gut-feeling is that the auxiliary Fixture class Person (not a TestCase
and not Test* pattern) is being filtered out by Maven during testing?
Also can not tell from the logs that Person.hbm.xml is being picked up
properly ... does it belong under /src/test/java/<my packages>.../ ? or
under /src/test/resources/<my packages>.../ ?
If interested the sources are available for checkout from:
http://perfectjpattern.svn.sourceforge.net/svnroot/perfectjpattern/trunk/
TIA,
regards,
Giovanni
I have implemented a Generic Dao based on Hibernate and then included under
my test package:
trunk/
- perfectjpattern-j2ee
-- pom.xml
-- src/
--- test/
---- java/
----- perfectjpattern/
------ j2ee/
------- database/
-------- dao/
--------- hibernate/
---------- Person.java
---------- Person.hbm.xml
---------- TestHibernateGenericReadOnlyDao.java
---------- TestHibernateGenericDao.java
---- resources/
----- hibernate.cfg.xml
----- hsql.properties
----- hsql.script
----- log4j.xml
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: errors for hibernate test cases
Posted by Giovanni Azua <br...@swissonline.ch>.
ciao Marco,
Please find the stacktrace below
grazie! :)
<testcase time="0" name="testFindById">
<error message="Could not initialize class
perfectjpattern.j2ee.database.dao.hibernate.HibernateGenericDao"
type="java.lang.NoClassDefFoundError">java.lang.NoClassDefFoundError:
Could not initialize class
perfectjpattern.j2ee.database.dao.hibernate.HibernateGenericDao
at
perfectjpattern.j2ee.database.dao.hibernate.TestHibernateGenericReadOnlyDao.
setUp(TestHibernateGenericReadOnlyDao.java:147)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(Ab
stractDirectoryTestSuite.java:138)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractD
irectoryTestSuite.java:125)
at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireB
ooter.java:290)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818
)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818
)
</error>
</testcase>
> -----Original Message-----
> From: Marco Mistroni [mailto:mmistroni@gmail.com]
> Sent: Friday, November 30, 2007 11:40 PM
> To: Maven Users List
> Subject: Re: errors for hibernate test cases
>
> Giovanni,
> could you please post stacktrace of exception? i had also
> problems with hibernate and got everything sorted out..
> your hbm.xml files should end up in src/main/resources in
> order to be present in the classpath during testing(they'll
> end up in target\classes)
>
> regards
> marco
>
> On Nov 30, 2007 10:17 PM, Giovanni Azua
> <br...@swissonline.ch> wrote:
>
> > hi,
> >
> > I have a set of test cases that pass fine under Eclipse .. but from
> > Maven I get java.lang.NoClassDefFoundError when running
> > TestHibernateGenericReadOnlyDao and TestHibernateGenericDao
> (see below).
> >
> > My gut-feeling is that the auxiliary Fixture class Person (not a
> > TestCase and not Test* pattern) is being filtered out by
> Maven during testing?
> >
> > Also can not tell from the logs that Person.hbm.xml is
> being picked up
> > properly ... does it belong under /src/test/java/<my
> packages>.../ ?
> > or under /src/test/resources/<my packages>.../ ?
> >
> > If interested the sources are available for checkout from:
> >
> http://perfectjpattern.svn.sourceforge.net/svnroot/perfectjpattern/tru
> > nk/
> >
> > TIA,
> > regards,
> > Giovanni
> >
> > I have implemented a Generic Dao based on Hibernate and
> then included
> > under my test package:
> >
> > trunk/
> > - perfectjpattern-j2ee
> > -- pom.xml
> > -- src/
> > --- test/
> > ---- java/
> > ----- perfectjpattern/
> > ------ j2ee/
> > ------- database/
> > -------- dao/
> > --------- hibernate/
> > ---------- Person.java
> > ---------- Person.hbm.xml
> > ---------- TestHibernateGenericReadOnlyDao.java
> > ---------- TestHibernateGenericDao.java
> > ---- resources/
> > ----- hibernate.cfg.xml
> > ----- hsql.properties
> > ----- hsql.script
> > ----- log4j.xml
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > 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: errors for hibernate test cases
Posted by Marco Mistroni <mm...@gmail.com>.
Giovanni,
could you please post stacktrace of exception? i had also problems with
hibernate and got everything
sorted out..
your hbm.xml files should end up in src/main/resources in order to be
present in the classpath during
testing(they'll end up in target\classes)
regards
marco
On Nov 30, 2007 10:17 PM, Giovanni Azua <br...@swissonline.ch> wrote:
> hi,
>
> I have a set of test cases that pass fine under Eclipse .. but from Maven
> I
> get java.lang.NoClassDefFoundError when running
> TestHibernateGenericReadOnlyDao and TestHibernateGenericDao (see below).
>
> My gut-feeling is that the auxiliary Fixture class Person (not a TestCase
> and not Test* pattern) is being filtered out by Maven during testing?
>
> Also can not tell from the logs that Person.hbm.xml is being picked up
> properly ... does it belong under /src/test/java/<my packages>.../ ? or
> under /src/test/resources/<my packages>.../ ?
>
> If interested the sources are available for checkout from:
> http://perfectjpattern.svn.sourceforge.net/svnroot/perfectjpattern/trunk/
>
> TIA,
> regards,
> Giovanni
>
> I have implemented a Generic Dao based on Hibernate and then included
> under
> my test package:
>
> trunk/
> - perfectjpattern-j2ee
> -- pom.xml
> -- src/
> --- test/
> ---- java/
> ----- perfectjpattern/
> ------ j2ee/
> ------- database/
> -------- dao/
> --------- hibernate/
> ---------- Person.java
> ---------- Person.hbm.xml
> ---------- TestHibernateGenericReadOnlyDao.java
> ---------- TestHibernateGenericDao.java
> ---- resources/
> ----- hibernate.cfg.xml
> ----- hsql.properties
> ----- hsql.script
> ----- log4j.xml
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
RE: errors for hibernate test cases
Posted by Giovanni Azua <br...@swissonline.ch>.
Resolved!
I had the following entry in my pom.xml
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>log4j.xml</include>
</includes>
</testResource>
</testResources>
.. therefore it was excluding everything else, so got rid of this entry and
now it works fine.
Thanks!
Giovanni
> -----Original Message-----
> From: Giovanni Azua [mailto:bravegag@swissonline.ch]
> Sent: Friday, November 30, 2007 11:17 PM
> To: 'Maven Users List'
> Subject: errors for hibernate test cases
>
> hi,
>
> I have a set of test cases that pass fine under Eclipse ..
> but from Maven I get java.lang.NoClassDefFoundError when
> running TestHibernateGenericReadOnlyDao and
> TestHibernateGenericDao (see below).
>
> My gut-feeling is that the auxiliary Fixture class Person
> (not a TestCase and not Test* pattern) is being filtered out
> by Maven during testing?
>
> Also can not tell from the logs that Person.hbm.xml is being
> picked up properly ... does it belong under
> /src/test/java/<my packages>.../ ? or under
> /src/test/resources/<my packages>.../ ?
>
> If interested the sources are available for checkout from:
> http://perfectjpattern.svn.sourceforge.net/svnroot/perfectjpat
> tern/trunk/
>
> TIA,
> regards,
> Giovanni
>
> I have implemented a Generic Dao based on Hibernate and then
> included under my test package:
>
> trunk/
> - perfectjpattern-j2ee
> -- pom.xml
> -- src/
> --- test/
> ---- java/
> ----- perfectjpattern/
> ------ j2ee/
> ------- database/
> -------- dao/
> --------- hibernate/
> ---------- Person.java
> ---------- Person.hbm.xml
> ---------- TestHibernateGenericReadOnlyDao.java
> ---------- TestHibernateGenericDao.java
> ---- resources/
> ----- hibernate.cfg.xml
> ----- hsql.properties
> ----- hsql.script
> ----- log4j.xml
>
>
>
> ---------------------------------------------------------------------
> 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