DISQUS

suresh's picture

Unregistered

Feeds

aliases

  • suresh

suresh

1 year ago

in Superceeded Article: Embedded Web Integration Testing with Jetty on Thinking inside a bigger box
Thanks for the article. I ran into an issue with Jetty classloading when running on a linux platform.

The code which retrieves Springs WebApplicatonContext using the jetty server's servlet context was failing. Specifically, the following code was throwing a ClassCastException:

ApplicationContext appctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(servletContext);

The reason being that the Spring's application context was loaded by Jetty's own classloader, hence cannot be used here.

The work around was to set the parentLoaderPriority to true while creating the Jetty server as described here: http://docs.codehaus.org/display/JETTY/Classloa...

eg:
WebAppContext context = new WebAppContext();
context.setParentLoaderPriority(true);
context.setContextPath("/");
context.setWar("path/to/war/or/exploded/war");
jettyServer.setHandler(context);

The errors happens didnt happen on a Windows XP box. But while running our CI builds on a Redhat EL4 box, the classcast exception was thrown.

Redhat EL4
JDK 1.5_07-b3
Jetty-6.1.1
Spring-Framework-2.0.2

Hope this might help someone who runs into the same problem.


-- suresh --
Returning? Login