[jetty-user] ClassCastException...Jetty6Continuation when hot deploying

Sean Rhea <[email protected]> Wed, 20 Apr 2011 10:42:41 -0700
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
Hello,

I'm using jetty 6.1.22 with cometd-java-server-2.1.0 and
jetty-continuation-7.3.0.v20110203.  I hot deploy my app using a
WebAppContext, but when I touch the context file, the next attempt by
a cometd client causes this error:

java.lang.ClassCastException: org.eclipse.jetty.continuation.Jetty6Continuation
	at org.eclipse.jetty.continuation.ContinuationFilter.doFilter(ContinuationFilter.java:76)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        ...
        (full stack trace below)

Line 76 of ContinuationFilter.java is trying to cast the continuation
to type Continuation, which Jetty6Continuation inherits, so it should
work.  I suspect the problem is with the class loader, in that the
Jetty6Continuation object in hand is from the class loader used before
the restart, whereas the Continuation interface being used is the one
from after the restart.  If that were the case, then in fact the
exception is the expected behavior.  To try and fix it, I added

  <Set name="systemClasses">
    <Array type="java.lang.String">
      <Item>org.eclipse.jetty.</Item>
      ...
    </Array>
  </Set>

to my context.xml, so that the Continuation interface and
Jetty6Continuation class would be loaded by the system class loader,
but that doesn't seem to have helped--I still get the exception.

Has anyone else seen this?  Any ideas?  The full text of my web
context is below.

Thanks,
Sean

nmr.xml (my web context):

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
  <Set name="war"><SystemProperty name="jetty.home"
default="."/>/webapps/nmr</Set>
  <!-- <Set name="extractWAR">true</Set> -->
  <Get name="errorHandler">
    <Call name="setShowStacks">
      <Arg type="boolean">false</Arg>
    </Call>
  </Get>
  <Set name="copyWebDir">true</Set>
  <Set name="systemClasses">
    <Array type="java.lang.String">
      <Item>java.</Item>
      <Item>javax.</Item>
      <Item>org.eclipse.jetty.</Item>
      <Item>org.mortbay.</Item>
      <Item>org.xml.</Item>
      <Item>org.w3c.</Item>
      <Item>org.srhea.scalaqlite.</Item>
      <Item>scala.</Item>
    </Array>
  </Set>
</Configure>

web.xml:

<web-app>
  <servlet>
    <servlet-name>cometd</servlet-name>
    <servlet-class>org.cometd.server.CometdServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
      <param-name>timeout</param-name>
      <param-value>60000</param-value>
    </init-param>
    <init-param>
      <param-name>logLevel</param-name>
      <param-value>3</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>cometd</servlet-name>
    <url-pattern>/cometd/*</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>initializer</servlet-name>
    <servlet-class>BayeuxInitializer</servlet-class>
    <load-on-startup>3</load-on-startup>
  </servlet>

  <filter>
    <filter-name>continuation</filter-name>
    <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>continuation</filter-name>
    <url-pattern>/cometd/*</url-pattern>
  </filter-mapping>

 <servlet>
   <servlet-name>NmrServlet</servlet-name>
   <servlet-class>NmrServlet</servlet-class>
   <load-on-startup>2</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>NmrServlet</servlet-name>
   <url-pattern>/*</url-pattern>
 </servlet-mapping>
</web-app>

full stack trace:

java.lang.ClassCastException: org.eclipse.jetty.continuation.Jetty6Continuation
	at org.eclipse.jetty.continuation.ContinuationFilter.doFilter(ContinuationFilter.java:76)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:398)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at org.mortbay.jetty.nio.SelectChannelConnector$RetryContinuation.run(SelectChannelConnector.java:525)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

-- 
Construct the world in which you want to live.  Then live there.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email