This is a classloader problem. It looks like you have a jar file in your project.xml that contains classes that are needed for compilation, however, during runtime an invocation on one of those classes is causing the loading of another class - and this new class is not in the maven classloader. Remember that the JVM only look upwards from the point where a class is requested.


Generally speaking you solve this problem by identifying the class that is triggering the loading of the class within the maven classloader (use maven -X when running your test and you will see a lot of information about where classes are being loaded from.

More notes in line:

[EMAIL PROTECTED] wrote:
Hi,

I am trying to create an integration test case using AbstractMerlinTestCase but it fails with a ClassNotFoundException for an external jar file, which is declared inside block.xml.

The test is proceeding a bit further when I add the jar file inside the dependencies element inside project.xml, but then I get a ClassCastException

when doing:

TheClass theClass = (TheClass) resolve( "/MyProject/myContainer" );

Classic case of TheClass your casting to is not the same instance of the TheClass that the component is implementing. In this example TheClass has to be in the maven classloader because your referencing it in your testcase.


even though the object returned by resolve actually is of the 'TheClass'
type
(as I verified in a log message).

It may have the same name but that does not mean its the same class instance.


The project.xml includes the reference to the block.xml as stated in:
http://avalon.apache.org/merlin/starting/advanced/unit/index.html

Is it perhaps a classloader problem, where part of the test is getting its
dependent classes from project.xml and part of it from the supplied
block.xml?

The issue is that you have something in the maven definition that is calling something which you probably have in your block definition. In this case the dependent needs to be declared in the maven project.xml.


Where does AbstractMerlinTestCase read it's dependencies from?

If you peek inside the merlin-unit jar file you will see a resource named merlin.properties that contains the property merlin.implementation.


The value 'merlin:merlin-impl;3.3-SNAPSHOT' get translated to ${merlin.system}/merlin/jars/merlin-impl-3.3-SNAPSHOT.jar.meta which in turn contains the list of all of the merlin unit dependencies. The merlin unit quietly loads all of this in the background using the avalon-repository package.

Stephen.

Regards,
Tobias


------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/merlin/distributions/latest    |
|------------------------------------------------|

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to