You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mi...@amsterdam.politie.nl on 2007/06/08 11:43:31 UTC

Classpath issues with maven 2.0.6


Hi folks

Unfortunately I run into classpath problems when running my unittests
with 'mvn test'.

I have the following situation. To be able to test static blocks in my
classes under various conditions I need to be sure these static block
are executed multiple times. The only thing I know that can achieve this
situation is using a separate classloader for every test. After some
googling I found the ReloadableClassLoader from
http://sourceforge.net/projects/escher .

In eclipse I was able to get this to work and verified that I have a
different classloader for every test. However when running the same
unittest (that worked in eclipse) from 'mvn test'. I run into a
ClassNotFoundException  :-(

Looking a bit deeper I discovered the classpath being used in Eclipse
contains a lot more entries than the one being used by maven. 

Eclipse has:
	K:\Sources\Prefs\memoryprefs\target\test-classes
	K:\Sources\Prefs\memoryprefs\target\classes
	
K:\Repositories\maven2\.m2\repository\junit\junit\4.3.1\junit-4.3.1.jar
	
K:\Repositories\maven2\.m2\repository\org\slf4j\slf4j-api\1.4.0\slf4j-ap
i-1.4.0.jar
	
K:\Repositories\maven2\.m2\repository\org\slf4j\slf4j-simple\1.4.0\slf4j
-simple-1.4.0.jar
	
K:\DevTools\eclipse\3.3M6\eclipse\configuration\org.eclipse.osgi\bundles
\70\1\.cp
	
K:\DevTools\eclipse\3.3M6\eclipse\configuration\org.eclipse.osgi\bundles
\68\1\.cp

Maven has:
	K:\DevTools\maven\maven-2.0.6\boot\classworlds-1.1.jar

Looking even deeper I found out that ReloadableClassLoader uses system
property 'java.class.path' to get the actual classpath. 

My question now is, how can I make sure that my classes under test will
be part of the classpath. In other words how can I get maven to add all
necessary dependencies to the "java.class.path" system property.
Alternatively, assuming maven uses java -cp, how can I reach the proper
classpath to feed my custom ClassLoader.

Any help is appreciated.

Kind regards,

Minto van der Sluis

--- Today's code is tomorrow's legacy. ---



DISCLAIMER
De informatie in deze e-mail is vertrouwelijk en uitsluitend bestemd voor de geadresseerde. Indien u niet de geadresseerde bent, wordt u er hierbij op gewezen, dat u geen recht heeft kennis te nemen van de rest van deze e-mail, deze te gebruiken, te kopieren of te verstrekken aan andere personen dan de geadresseerde. Indien u deze e-mail abusievelijk hebt ontvangen, brengt u dan alstublieft de afzender op de hoogte, waarbij u bij deze gevraagd wordt het originele bericht te vernietigen. Politie Amsterdam-Amstelland is niet verantwoordelijk voor de inhoud van deze e-mail en wijst iedere aansprakelijkheid af voor en/of in verband met alle gevolgen en/of schade van een onjuiste of onvolledige verzending ervan. Tenzij uitdrukkelijk het tegendeel blijkt, kunnen aan dit bericht geen rechten worden ontleend. Het gebruik van Internet e-mail brengt zekere risico's met zich. Daarom wordt iedere aansprakelijkheid voor het gebruik van dit medium door de Politie Amsterdam-Amstelland van de hand gewezen. 

Re: Classpath issues with maven 2.0.6

Posted by Jo Vandermeeren <jo...@gmail.com>.
On 6/8/07, Minto.van.der.Sluis@amsterdam.politie.nl
<Mi...@amsterdam.politie.nl>
wrote:
>
> Looking a bit deeper I discovered the classpath being used in Eclipse
> contains a lot more entries than the one being used by maven.
>

Hi Minto

The classpath used to startup maven is different from the one that is used
to build and test your modules.
Hence the dependencies section in your pom.xml file.

Have you included the libraries needed for testing as test-scoped
dependencies in the pom.xml file of the resp. module?

Cheers
Jo