Am Donnerstag, 19. Juli 2007 19:53 schrieb [EMAIL PROTECTED]:
> Hi,
>
> i have strange classLoader problem. I use maven, eclipse and jetty.
>
> i want to write a functional test with htmlunit, something like shown here
>
> http://today.java.net/pub/a/today/2007/04/12/embedded-integration-testing-o
>f-web-applications.html
>
> i start a jetty container with
>
> private static Server startServer ( ) throws Exception
> {
> // 0 means assign any free port
> Server server = new Server(0);
> server.addHandler(new WebAppContext("target/myproject", ""));
> server.start();
> // getLocalPort returns the port that was actually assigned
> port = server.getConnectors()[0].getLocalPort();
> return server;
> }
>
> jetty starts up fine.
> but now i want to get the WebApplicationContext from the spring like this
>
> WebAppContext jettyCtx = (WebAppContext) server.getHandler();
> ServletContext sc = jettyCtx.getServletHandler().getServletContext();
> String key =
> WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
> System.out.println(sc.getAttribute(key).getClass());
> WebApplicationContext ctx = (WebApplicationContext)
> sc.getAttribute(key);
>
> it prints:
> class org.springframework.web.context.support.XmlWebApplicationContext
> and throws then a
> ClassCastException
> But XmlWebApplicationContext IS A WebApplicationContext, so it SHOULD be
> castable
i fixed it myself by giving jetty a different directory:
server.addHandler(new WebAppContext("src/main/webapp", ""));
kind regards,
Janning
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]