I've got a really strange thing going on with Maven (v. 1.0.2). It seems to
be using totally different class loaders depending on how I invoke Maven.

 

I have this debug code in my junit test case code:

 

        Class thisClass = this.getClass();

        System.err.println("The Class of the test suite is: " + thisClass); 

        ClassLoader classLoader = thisClass.getClassLoader();

        System.err.println("The class loader is: " + classLoader);

        Package thisPackage = thisClass.getPackage();

        String tmsg = "The " + thisClass.getName()

        + ".getPackage() method returned: " + thisPackage;

        System.err.println(tmsg);

 

 

When I run "maven site", I get this output, and my unit tests work:

 

[junit] The Class of the test suite is: class
com.manheim.PriceBookData.PriceBookDataTestSuite

[junit] The class loader is: [EMAIL PROTECTED]

[junit] The com.manheim.PriceBookData.PriceBookDataTestSuite.getPackage()
method returned: package com.manheim.PriceBookData

 

When I run "maven jar:jar", I get this output, and my unit tests fail
because of the null:

 

[junit] The Class of the test suite is: class
com.manheim.PriceBookData.PriceBookDataTestSuite

[junit] The class loader is: [EMAIL PROTECTED]

[junit] The com.manheim.PriceBookData.PriceBookDataTestSuite.getPackage()
method returned: null

 

In both cases, the unit tests are being run as a part of the test:test goal.

 

Note that a totally different class loader is being used in the two
different invocations of maven...

 

Even weirder is that the getPackage() method is returning a null!

 

Why are there two different class loaders being used depending on the way
maven is run?

 

Any help would be most appreciated!

 

Thanks,

 

Brad

Reply via email to