> "Craig R. McClanahan" wrote:
> > Yesterday, I added an update to Embedded.start() to set "catalina.base"
to
> > the value of "catalina.home" if it's not already set.  That way, others
> > won't get bit by this one.
>
> Yes, I saw the commit message in CVS, which hinted that I should do it
> manually with RC1. :-)
>
> > It's certainly an odd symptom.  One potentially significant
environmental
> > difference is that Embedded does not set up the usual class loader
> > hierarchy that org.apache.catalina.startup.Bootstrap does.  What is the
> > class loader environment when you're running into this?
>
> The parent classloader is set to the application classloader that JBoss
> provides. The code I use to access the EmbeddedManager looks like this:
>    protected WebApplication performDeploy(String ctxPath, String warUrl,
> AbstractWebContainer.WebDescriptorParser webAppParser) throws Exception
>    {
>       String deployPath = ctxPath.equals("/") ? "" : ctxPath;
>       ClassLoader ctxClassLoader =
> Thread.currentThread().getContextClassLoader();
>       Context ctx = mapper.deploy(deployPath, warUrl);
>       ctx.setParentClassLoader(ctxClassLoader);
>       ClassLoader scl = (ClassLoader) ctx.getLoader().getClassLoader();
>
>       ServletContext servletCtx = ctx.getServletContext();
> //      Element webXml = (Element) ctx.getAttribute("web-app.xml");
> //      Element jbossWebXml = (Element)
> ctx.getAttribute("jboss-web.xml");
>       URL url = new URL(warUrl);
>       WebApplication appInfo = new WebApplication(url.getFile(), url,
> scl);
> //      appInfo.setWebApp(webXml);
> //      appInfo.setJbossWeb(jbossWebXml);
>       appInfo.setAppData(ctx);
>
>       return appInfo;
>    }
> and mapper.deploy looks like this:
>    public Context deploy(String cxPath, String warUrl) throws
> DeploymentException
>    {
>       if (warUrl.startsWith("file:"))
>          warUrl = warUrl.substring(5);
>       try
>       {
>          Context context = (Context) mBServ.invoke(catName,
> "createContext", new Object[]{ cxPath,warUrl }, new String[]{
> "java.lang.String", "java.lang.String" });
>          StandardLoader loader = new
> StandardLoader(Thread.currentThread().getContextClassLoader());

That's unrelated, but maybe you should try using the WebappLoader (if what
you're loading is a webapp, of course). It is more robust (and a lot faster
too) than the StandardLoader.

>          context.setLoader(loader);
>          context.setReloadable(true);
>          deployHost.addChild(context);
>          return context;
>       } catch (RuntimeErrorException e)
>       {
>          e.getTargetError().printStackTrace();
>          throw new DeploymentException(e.getLocalizedMessage());
>       } catch (Exception e)
>       {
>          e.printStackTrace();
>          throw new DeploymentException(e.getLocalizedMessage());
>       }
>    }
> ---
> (Yes the parent CL is set twice, which is redundant, but shouldn't cause
> any actual problems).
>
> Any ideas on this?

Not yet. I tried things with the Embedded class and it worked decent.
Try the small patch to ContextConfig I mentined in the comments in the bug
(if you use a Catalina version built from CVS, of course), as the exception
you get is interesting - I want to see where it happens.

Note: The ctxPath *must* start with a "/". If it doesn't, it will break when
trying to use getResource (the algorithm is picky on the path parsing at the
moment, and it will be made more robust later).

> I'm developing this by mostly guessing how to do it
> properly, so any more educated guesses would be appreciated :-) You have
> no idea how much I want this to work! 8-)

:)

Remy

Reply via email to