Olaf Bergner wrote:

I have - yet again - a minimal deployment scenario (1 service interface, 1
implementing component) I am struggling with. If I do a

merlin -execute conf/component-manager.block

(see below for more info) I get

[INFO   ] (kernel): installing:
file:/${user.dir}/conf/component-manager.block
[INFO   ] (components.component-manager): Executing
[INFO   ] (components.component-manager): Finished executing ...
[INFO   ] (kernel): dissassembly phase
[INFO   ] (kernel): disposal phase

i.e. all goes smoothly. If, however, I deploy the block using a custom
testcase derived from AbstractMerlinTestCase with only

final public void testAcquisition() throws Exception
        {
                final DAOFactoryBuilder builder = (DAOFactoryBuilder) 
resolve(RES_PATH);

                assertNotNull(
                        "resolve(\"" + RES_PATH + "\") returned <null>.",
                        builder);
        }

added, I get an exception complaining that the xinfo file for the component
to be deployed could not be found - that is TypeBuilder fails to locate the
corresponding .xinfo file within deployment jar. Needless to say that it is
definitely there, as merlin cli well notices. I took great care to ensure
that melin cli as well as my testcase do deploy the exact same block
containing the exact same info. The merlin.deployment entry in
merlin.properties points to file:/${user.dir}/conf/component-manager.block,
the block merlin cli swallows without further ado. I manually copied the
generated jars to merlin cli's repository, opened them and verified that
they are exactly the same as those used by my testcase.

According to the source in TypeBuilder.buildFromXMLDescriptor() the problem
might be tracked back to classLoader.getResourceAsStream(classname.xinfo)
failing to load the existing xinfo file. But why should this happen?


I'm trying to think why this would happen. Basically if I understand
correctly, Merlin has created a classloader and populated it with the
content you have specified in you block. The scanner then kicks in to
establsh the available components by read the metainfo from the .xinfo
resources. The TypeBuilder is supplied the component class from which
it gets the class's classloader to read the xinfo. In you the classloader
is not finding the xinfo.


This means one thing - the class in question already exists in a parent
classloader - but the xinfo is not present in that parent.  This suggests
that maybe you have a duplication of classes referenced in the jar file
component-impl-0.1.jar and classes in target/classes.


classLoader is the classloader that loaded the class itself, it should also load the .xinfo file in the same package. Or is it a classloader issue?


There is clearly a conflict going on at the classloader level. The class exists but its not being loaded from the jar file. To find out what is going on, set the following properties in merlin.properties

 merlin.debug = true
 merlin.info = true

Then run maven with debug enabled:

maven -X test

As the test cases kicks you will see merlin system debug messages and you
will also see junit messages.  From this you should be able to figer out
where the class is comming from.


I wrote an embedded kernel that closely taking AbstractMerlinTestCase as a
blueprint, and it shows the exact same behaviour.



This suggests that there is a duplicate class somewhere in the jars. But I'm just guessing.


Naturally, I would be glad
if anybody could explain to me what's going on here and how I might fix my
kernel.



Lets get some debug traces up and see where things are comming from.


Cheers, Stephen.

Cheers,

Olaf

P.S.: One minor issue: the line

final String message =
               REZ.getString( "builder.missing-info.error", path );

in TypeBuilder.buildFromXMLDescriptor() should probably be changed to

final String message =
               REZ.getString( "builder.missing-info.error", classname );

Otherwise, as you will see below, the exception message is a little
misleading.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++

Debug + Stacktrace:

[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/model-api-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/model-spi-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/model-impl-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/persistence-api-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/persistence-impl-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/component-api-0.1.jar
[DEBUG  ] (components.classloader.scanner): scanning: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/component-impl-0.1.jar
---- exception
report ----------------------------------------------------------
Exception: org.apache.avalon.merlin.KernelException
Message: Install failure:
file:/C:/Projekte/OBergner/EclipseWorkspace/manplan-merlin/component/impl/co
nf/component-manager.block
----
cause ---------------------------------------------------------------------
Exception: org.apache.avalon.composition.model.ModelException
Message: Could not create classloader.
----
cause ---------------------------------------------------------------------
Exception: org.apache.avalon.composition.model.ModelException
Message: Unexpected error while scanning jar file: file:/C:/Dokumente und
Einstellungen/Otto
Berg/.maven/repository/manplan-merlin/jars/component-impl-0.1.jar
----
cause ---------------------------------------------------------------------
Exception: java.lang.Exception
Message: Unable to locate resource from which to load info for component
implemented by class
"manplan/merlin/component/impl/persistence/DefaultDAOFactoryBuilder.xinfo".
---- stack
trace ---------------------------------------------------------------
java.lang.Exception: Unable to locate resource from which to load info for
component implemented by class
"manplan/merlin/component/impl/persistence/DefaultDAOFactoryBuilder.xinfo".
org.apache.avalon.meta.info.builder.TypeBuilder.buildFromXMLDescriptor(TypeB
uilder.java:186)
org.apache.avalon.meta.info.builder.TypeBuilder.buildType(TypeBuilder.java:1
04)
org.apache.avalon.composition.model.impl.Scanner.addType(Scanner.java:377)
org.apache.avalon.composition.model.impl.Scanner.scanJarFile(Scanner.java:25
8)
org.apache.avalon.composition.model.impl.Scanner.scanJarFileURL(Scanner.java
:239)
org.apache.avalon.composition.model.impl.Scanner.scanURL(Scanner.java:197)
org.apache.avalon.composition.model.impl.Scanner.scan(Scanner.java:170)
org.apache.avalon.composition.model.impl.DefaultClassLoaderModel.<init>(Defa
ultClassLoaderModel.java:235)
org.apache.avalon.composition.model.impl.DefaultClassLoaderModel.createClass
LoaderModel(DefaultClassLoaderModel.java:129)
org.apache.avalon.composition.model.impl.DefaultContainmentModel.createConta
inmentModel(DefaultContainmentModel.java:464)
org.apache.avalon.composition.model.impl.DefaultContainmentModel.createConta
inmentModel(DefaultContainmentModel.java:427)
org.apache.avalon.composition.model.impl.DefaultContainmentModel.createConta
inmentModel(DefaultContainmentModel.java:663)
org.apache.avalon.composition.model.impl.DefaultContainmentModel.addContainm
entModel(DefaultContainmentModel.java:288)
org.apache.avalon.composition.model.impl.DefaultContainmentModel.addModel(De
faultContainmentModel.java:282)
org.apache.avalon.merlin.impl.DefaultFactory.create(DefaultFactory.java:488)
org.apache.avalon.merlin.unit.AbstractMerlinTestCase.setUp(AbstractMerlinTes
tCase.java:198)
junit.framework.TestCase.runBare(TestCase.java:125)
junit.framework.TestResult$1.protect(TestResult.java:106)
junit.framework.TestResult.runProtected(TestResult.java:124)
junit.framework.TestResult.run(TestResult.java:109)
junit.framework.TestCase.run(TestCase.java:118)
junit.framework.TestSuite.runTest(TestSuite.java:208)
junit.framework.TestSuite.run(TestSuite.java:203)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:392)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:276)
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:167)
----------------------------------------------------------------------------
----

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++

component-manager.block:

<container name="components">

  <services>
    <service type="manplan.merlin.component.api.ComponentManager">
      <source>component-manager</source>
    </service>
  </services>

  <classloader>
    <classpath>
      <repository>
        <resource id="manplan-merlin:model-api" version="0.1"/>
        <resource id="manplan-merlin:model-spi" version="0.1"/>
        <resource id="manplan-merlin:model-impl" version="0.1"/>
        <resource id="manplan-merlin:persistence-api" version="0.1"/>
        <resource id="manplan-merlin:persistence-impl" version="0.1"/>
        <resource id="manplan-merlin:component-api" version="0.1"/>
        <resource id="manplan-merlin:component-impl" version="0.1"/>
        <resource id="log4j:log4j" version="1.2.8"/>
        <resource id="hibernate:hibernate" version="2.1.1"/>
        <resource id="commons-collections:commons-collections"
version="3.0-dev2"/>
        <resource id="dom4j:dom4j" version="1.4"/>
      </repository>
    </classpath>
  </classloader>

  <component name="component-manager"
      class="manplan.merlin.component.impl.DefaultComponentManager"
activation="startup">
  </component>

</container>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++

manplan/merlin/component/impl/DefaultComponentManager.xinfo (for what it's
worth):

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN"
"http://avalon.apache.org/dtds/meta/type_1_1.dtd"; >

<type>
 <info>
   <name>component-manager</name>
   <version>0.1.0</version>
   <lifestyle>singleton</lifestyle>
 </info>
 <services>
   <service type="manplan.merlin.component.api.ComponentManager"/>
 </services>
</type>


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





--


Stephen J. McConnell
mailto:[EMAIL PROTECTED]

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





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



Reply via email to