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-of-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 The problem is, that i have all my maven dependencies on the classpath (either running from mvn test or inside eclipse), but jetty seems to use a different classLoader which loads the classes from WEB-INF/lib So the XmlWebApplicationContext is from target/WEB-INF/lib ClassLoader and is in a different "class Loader hierarchie"?? I dont understand much of classloaders. but if i delete all jar files from WEB-INF/lib, it works fine. I know this question is not directly related to maven but i don't have any clue how to fix it and where to ask. I want my testcase to try to load its classes from target/WEB-INF/lib falling back to maven dependencies. How can i manipulate the classLoader at runtime and advise it to look first in WEB-INF/lib ? any help is very appreciated kind regards, janning --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]