Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Junit class loading problems under Project Builder



Erik Norvelle wrote:
| I'm attempting to use Project Builder to construct a Junit test suite, and
| am running into problems with the classpath that Junit apparently is seeing.
| Junit performs dynamic loading of classes when it runs a test suite. It
| is able to find the classes that comprise the code that I created, but it is
| unable to find any of the code that resides in other, external jar file.
|
| For instance, one of my test cases relies on HttpUnit, whose code lives in
| httpunit.jar, which I have placed in /Library/Java/Extensions, along with
| its other dependent jars. Project Builder sees all HttpUnit classes at
| compile time, but at runtime, Junit reports a
| java.lang.NoClassDefFoundError.
|
| My guess is that Project Builder is somehow giving the runtime JVM a
| different classpath than it uses at compile time...

While the PB compile-time and runtime classpaths are, indeed, distinct (as they are for all Java development), that's not likely the problem. Jar files in /Library/Java/Extensions are always automatically used by the standard class loader, which is why you didn't have to tell PB about them during compilation. (Strictly, there are ways to get the JVM not to search /L/J/E, but they require doing things that are generally better not done, and which I doubt very much you're doing. [The secret word is "bootclasspath".])

I'd guess that JUnit may be using a *non-standard* class loader, one of its own which doesn't know about /L/J/E.

Glen Fisher
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Junit class loading problems under Project Builder (From: "Erik Norvelle" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.