Hi Steve, > I'm currently digging into you source code - there is something wrong in > the kernel initialization bvut I havn't located the issue just yet. > Could you do me a favour and send to me the source?
Below you will find the source. Please let me know if you would prefer it as an attachment. Referring to my prior posting, I still suspect that the problem is related to merlin's insisting on using the hardcoded defaults dpml.net and ibiblio.org no matter what you pass as hosts in DefaultInitialContext(cache, hosts). Cheers, Olaf Source: /* * Created on 16.12.2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package org.merlinaop.main; import java.io.File; import java.lang.reflect.Method; import java.util.Map; import org.apache.avalon.repository.Artifact; import org.apache.avalon.repository.main.DefaultBuilder; import org.apache.avalon.repository.main.DefaultInitialContext; import org.apache.avalon.repository.provider.Builder; import org.apache.avalon.repository.provider.Factory; import org.apache.avalon.repository.provider.InitialContext; import org.apache.avalon.util.env.Env; import org.apache.avalon.util.exception.ExceptionHelper; /** * * <p>Created: 16.12.2003</p> * * @author <a href="mailto:[EMAIL PROTECTED]>Olaf Bergner</a> * */ public class Main { //-------------------------------------------------------------------------- // static //-------------------------------------------------------------------------- private static final String MERLIN_PROPERTIES = "merlin.properties"; private static final String IMPLEMENTATION_KEY = "merlin.implementation"; private static final String APPLICANCE_CLASSNAME = "org.apache.avalon.activation.appliance.Appliance"; /** * */ public Main() { } public static void main(final String[] args) throws Exception { ClassLoader bootstrap = Main.class.getClassLoader(); try { final File cache = new File(getBaseDirectory(), "cache"); final File repo = new File(getMavenLocalHome(), "repository"); Artifact artifact = DefaultBuilder.createImplementationArtifact( bootstrap, getBaseDirectory(), getBaseDirectory(), MERLIN_PROPERTIES, IMPLEMENTATION_KEY); final String repository = repo.toURL().toExternalForm(); final String[] hosts = { repository, "http://dpml.net", "http://www.ibiblio.org/maven/" }; InitialContext context = new DefaultInitialContext(cache, hosts); Builder builder = new DefaultBuilder(context, artifact); final ClassLoader classloader = builder.getClassLoader(); Factory factory = builder.getFactory(); Map criteria = factory.createDefaultCriteria(); // // set the defaults // criteria.put("merlin.repository", cache.getAbsolutePath()); criteria.put("merlin.context", "target"); criteria.put("merlin.server", "true"); criteria.put("merlin.info", "true"); criteria.put("merlin.debug", "true"); // // if the deployment path is undefined then the best we // can do is to assume ${basedir}/target/classes and/or // ${basedir}/target/test-classes contains a BLOCK-INF/block.xml // and from this, derive a merlin.deployment value // String[] deployment = (String[]) criteria.get("merlin.deployment"); if (deployment.length == 0) { String path = buildDefaultTestPath(); if (null != path) { criteria.put("merlin.deployment", path); } else { final String error = "Cannot locate a deployment objective."; throw new IllegalStateException(error); } } // // if the ${merlin.override} value is undefined, check for // the existance of an override file in ${basedir}/conf/config.xml // and if it exists assign it as the override parameter // if (null == criteria.get("merlin.override")) { String override = buildDefaultOverridePath(); if (null != override) { criteria.put("merlin.override", override); } } // // go ahead with the deployment of the kernel // final Object kernel = factory.create(criteria); final Method shutdown = kernel.getClass().getMethod("shutdown", new Class[0]); final Method method = kernel.getClass().getMethod("getBlock", new Class[0]); final Object root = method.invoke(kernel, new Object[0]); final Method locate = root.getClass().getMethod( "locate", new Class[] { String.class }); Class applianceClass = classloader.loadClass(APPLICANCE_CLASSNAME); final Method resolve = applianceClass.getMethod("resolve", new Class[0]); // // shutdown kernel // shutdown.invoke(kernel, new Object[0]); } catch (Throwable e) { final String error = ExceptionHelper.packException(e, true); System.out.println(error); throw new Exception(error); } } //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- private static String buildDefaultOverridePath() { File base = getBaseDirectory(); File config = new File(base, "conf/override.xml"); return config.toString(); } private static String buildDefaultTestPath() { File base = getBaseDirectory(); File classes = new File(base, "conf/sample.block"); return classes.toString(); } private static File getMavenLocalHome() throws Exception { final String mavenLocalHome = System.getProperty( "maven.local.home", Env.getEnvVariable("MAVEN_LOCAL_HOME")); return new File(mavenLocalHome); } private static File getBaseDirectory() { final String base = System.getProperty("basedir"); if (null != base) { return new File(base); } return new File(System.getProperty("user.dir")); } /** * Return the merlin home directory. * @return the merlin install directory */ private static File getMerlinHome() { return new File(getMerlinHomePath()); } /** * Return the merlin home directory path. * @return the merlin install directory path */ private static String getMerlinHomePath() { try { String merlin = System.getProperty( "merlin.home", Env.getEnvVariable("MERLIN_HOME")); if (null != merlin) return merlin; return System.getProperty("user.home") + File.separator + ".merlin"; } catch (Throwable e) { final String error = "Internal error while attempting to access MERLIN_HOME environment."; final String message = ExceptionHelper.packException(error, e, true); throw new RuntimeException(message); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
