commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Essl <christiane...@yahoo.de>
Subject Re: [Hivemind] Question about customized ClassResolvers
Date Wed, 10 Mar 2004 09:55:58 GMT
I don't know why you get this exceptions, but why don't you just put your 
module-descriptor in src/META-INF/hivemodule.xml. And than call
Registry reg = RegistryBuilder.constructDefaultRegistry(). This will take 
all the META-INF/hivemodule.xml which are on the classpath - wheter jared 
or not.

Apart of this my JUnit tests generally extend from 
org.apache.hivemind.test.HiveMindTestCase. It has a number of convienience 
methods one of which is buildFrameworkRegistry(), which also loads like 
above the hivemodules in META-INF, but for which you can additional 
specify module-descriptors which are located anywhere in the class-path.

Hopefully this helps a bit.

Chris


On Wed, 10 Mar 2004 01:37:55 -0500, Geoff Longman 
<glongman@intelligentworks.com> wrote:

> Hey, I have tweaked up my own version of HiveMindFilter's init() method
> because I want to run a junit test in Eclipse and have the Registry pick 
> up
> my as yet notjarred hivemodule.xml
>
> Having looked at TestRegistryBuilder, it appears that this should work:
>
> // want to pick up META-INF/hivemodule.xml in the project root
> File f = new File("");
> URL[] urls = new URL[] { f.toURL()};
> ClassLoader loader =
>     new URLClassLoader(urls,
> Thread.currentThread().getContextClassLoader());
> ClassResolver resolver = new DefaultClassResolver(loader);
> // end of Tweak
> RegistryBuilder builder = new RegistryBuilder();
> builder.processModules(resolver);
> _registry = builder.constructRegistry(getRegistryLocale());
>
> When checking the URL from the File in the debugger it looks right, i.e. 
> the
> URL refers to the root of my project.
>
> But, I get the following error:
>
> org.apache.hivemind.ApplicationRuntimeException: Registry does not 
> contain
> module 'com.iw.session.local'.
>  ^^^ the name of the module I have constructed.
>
> Even stranger, if I leave the code above as is and force the Eclipse 
> junit
> test launch config classpath to contain the project root folder, 
> everything
> works - green lights across the board..
>
> I'm not really that up on these classloader tricks. Does anyone see
> something here?
>
> Geoff
>
> Geoffrey Longman
> Intelligent Works Inc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org



-- 
Christian Essl 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message