jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Strange error when using helper methods
Date Tue, 23 Jul 2002 10:37:58 GMT
Hi Evan,

I think I have some idea ... If probably has to do with classloader. If
you look at the stack trace, you'll see the JUnit calls the JDK
getDeclaredMethods(). It means that the SalutationsHome class is now
loaded when the getDeclaredMethods() is called whereas in the first test
it was only loaded during execution of the test.

Now as to why ... I know JUnit is using some special classloader to loaf
each test case independently. You may want to try to disable this (see
the junit FAQ or web site).

I cannot help you more at the moment (as I'm on holiday working offline)
but I hope it may give you some idea.

Cheers,
-Vincent

> -----Original Message-----
> From: Evan Jehu [mailto:evan@codepit.ca]
> Sent: 22 July 2002 22:53
> To: cactus-user@jakarta.apache.org
> Subject: Strange error when using helper methods
> 
> Hi All,
> 
> I am trying to execute some tests against EJB's deployed using
> jboss3.0.1RC1, the deployment executes as expected.  I am using
netbeans
> as
> my IDE and running the unit tests from within it.  I have mounted the
.jar
> files as described in the documentation etc.  My problem is that the
> following test executes as expected and passes:
> 
> public void testCreateSalutation() throws Exception {
> InitialContext ctx = new InitialContext() ;
> Object home = ctx.lookup("salutation") ;
> SalutationHome sHome =
(SalutationHome)PortableRemoteObject.narrow(home,
> SalutationHome.class) ;
> assertNotNull( sHome ) ;
> }
> 
> 
> however if I change the code to read:
> 
> public void testCreateSalutation() throws Exception {
> SalutationHome sHome = getSalutationHome() ;
> assertNotNull( sHome ) ;
> }
> 
> public SalutationHome getSalutationHome() throws Exception {
> InitialContext ctx = new InitialContext() ;
> Object home = ctx.lookup("salutation") ;
> return (SalutationHome)PortableRemoteObject.narrow(home,
> SalutationHome.class) ;
> }
> 
> I get the following stack trace:
> 
> Exception in thread "main" java.lang.NoClassDefFoundError:
> com/chryxus/cms/ejb/salutation/SalutationHome
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:1627)
> at java.lang.Class.privateGetPublicMethods(Class.java:1655)
> at java.lang.Class.getMethod0(Class.java:1744)
> at java.lang.Class.getMethod(Class.java:963)
> at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:72)
> at junit.awtui.TestRunner.runSuite(TestRunner.java:404)
> at junit.awtui.TestRunner.start(TestRunner.java:485)
> at junit.ui.TestRunner.main(TestRunner.java:11)
> at com.chryxus.cms.test.SalutationTest.main(SalutationTest.java:41)
> 
> 
> I have checked the classpath and my EJB's are on it (as they would
have to
> be for it to compile and execute the first test code).  This error
occures
> before the test calls the server.
> 
> I have been stuck on this all day and would love some suggestions :-)
> 
> Evan
> 
> 
> ------
> 
> Evan Jehu
> Software Developer
> 
> Tel./Fax: (416) 222-6931
> 
> "After three days without programming, life becomes meaningless."
>           The Tao of Programming - Book 2
>           http://misspiggy.gsfc.nasa.gov/tao.html
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message