|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
unit test compiles but throws NoClassDefFound exceptionHi,
I'm just starting with trails. Using http://docs.codehaus.org/display/TRAILS/Testing as a guide, I'm trying to test the mappings and eventually load my database with data from files. public void testCreate() { DomainObj o = new DomainObj(); o.setName("some name"); o = persistenceService.save(o); // assertEquals(o.getName(), "some name"); // assertNotNull(o.getId()); } The method compiles but throws an exception at persistenceService.save(o). java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet The website Trails has generated runs fine, so I'm missing something simple. Thanks, -Bill |
|
|
Re: unit test compiles but throws NoClassDefFound exceptionYou are missing servlet-api from your test classpath.
Kalle On Sun, Mar 15, 2009 at 8:36 AM, warner <wwarner@...> wrote:
|
|
|
Re: unit test compiles but throws NoClassDefFound exceptionThanks!
I edited pom.xml and added <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>test</scope> </dependency> Now i'm on to a new error; FileNotFoundException: hibernate.cfg.xml. It must be a classpath issue again.
|
|
|
Re: unit test compiles but throws NoClassDefFound exceptionHi
It's not necessarily a classpath issue. When you compile the application Trails creates an hibernate.cfg.xml file on the fly (I'm not very fan of this functionality) and this functionality is not available for testing. Try this: After compiling look for target/classes/hibernate.cfg.xml (or target/generated-sources/resources/hibernate.cfg.xml) and copy it to src/test/resources/hibernate.cfg.xml Eventually, you will need to maintain this file manually every time you add or delete an @Entity. Let us know if it works. Saludos. Alejandro. -- Alejandro Scandroli - http://weblog.amneris.es/ Amneris: We build process-driven web applications. http://www.amneris.es On Sun, Mar 15, 2009 at 10:46 PM, beel <wwarner@...> wrote: > > Thanks! > I edited pom.xml and added > > <dependency> > <groupId>javax.servlet</groupId> > <artifactId>servlet-api</artifactId> > <version>2.4</version> > <scope>test</scope> > </dependency> > > Now i'm on to a new error; FileNotFoundException: hibernate.cfg.xml. It must > be a classpath issue again. > > > Kalle Korhonen-2 wrote: >> >> You are missing servlet-api from your test classpath. >> >> Kalle >> >> >> On Sun, Mar 15, 2009 at 8:36 AM, warner <wwarner@...> wrote: >> >>> >>> Hi, >>> >>> I'm just starting with trails. Using >>> http://docs.codehaus.org/display/TRAILS/Testing as a guide, I'm trying to >>> test the mappings and eventually load my database with data from files. >>> >>> public void testCreate() { >>> DomainObj o = new DomainObj(); >>> o.setName("some name"); >>> o = persistenceService.save(o); >>> // assertEquals(o.getName(), "some name"); >>> // assertNotNull(o.getId()); >>> } >>> >>> The method compiles but throws an exception at >>> persistenceService.save(o). >>> >>> java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet >>> >>> The website Trails has generated runs fine, so I'm missing something >>> simple. >>> >>> Thanks, >>> >>> -Bill >>> -- >>> View this message in context: >>> http://www.nabble.com/unit-test-compiles-but-throws-NoClassDefFound-exception-tp22524377p22524377.html >>> Sent from the Trails - Users mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> >> >> > > -- > View this message in context: http://www.nabble.com/unit-test-compiles-but-throws-NoClassDefFound-exception-tp22524377p22528594.html > Sent from the Trails - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |