Tim Moloney wrote:
Tim Moloney wrote:
I'm trying to get cometd working with Felix. I believe that I have
it mostly working but I'm getting a ClassCastException on cometd
requests, specifically "can not cast
org.mortbay.jetty.nio.SelectChannelConnector$RetryContinuation to
org.mortbay.util.ajax.Continuation" (this is from memory so it may be
a bit off). I think that this is a classloader issue since the
RetryContinuation class implements the Continuation interface. I
know that split packages can cause ClassCastExceptions due to
different classloaders but I'm not sure this is the problem.
I'm using the following bundles:
- org.apache.felix:org.apache.felix.http.jetty:0.9.0-SNAPSHOT
(modified to use jetty 6.1.11)
- org.mortbay.jetty:jetty:6.1.11
- org.mortbay.jetty:jetty-util:6.1.11
- org.mortbay.jetty:servlet-api-2.5:6.1.11
- a custom comet bundle that
- inlines org.mortbay.jetty:cometd-api:0.9.20080221and
org.mortbay.jetty:cometd-bayeux:6.1.11
- maps org.mortbay.cometd.continuation.ContinuationCometdServlet to
/cometd
jetty-util exports org.mortbay.util but cometd-bayeux has
org.mortbay.util.ArrayQueue. I managed to get my custom comet bundle
to compile by making org.mortbay.util a private package. However,
this duplicates all of org.mortbay.util in my bundle which I think is
causing the ClassCastException.
What is the best way to handle the split package and avoid
ClassCastExceptions?
Tim
I found the split-package command in the bnd documentation. I tried
both merge-first and merge-last but I still got the
ClassCastExceptions. I think this is because the org.mortbay.util
package was still being duplicated in my bundle. I then tried first
which only copied org.mortbay.util.ArrayQueue into my bundle but then
the rest of org.mortbay.util couldn't be found. I finally tried using
the following but I'm still getting the original ClassCastExceptions.
<Private-Package>org.mortbay.util;-split-package:=first</Private-Package>
<Import-Package>!org.mortbay.log,!org.mortbay.thread,!org.mortbay.util.ajax,*</Import-Package>
<Require-Bundle>org.mortbay.jetty.util</Require-Bundle>
I'm out of ideas. Does anyone have any suggestions?
Tim
I managed to get things working by adding ArrayQueue to the jetty-util
bundle and modifying how http.jetty is packaged.
For http.jetty, I simply changed the Private-Package instruction as
shown below. Can someone review the change and commit it, if it doesn't
break anything?
Tomorrow, I'll investigate if I really needed to move ArrayQueue to the
jetty-util bundle.
Index: pom.xml
===================================================================
--- pom.xml (revision 676451)
+++ pom.xml (working copy)
@@ -97,7 +97,7 @@
</Export-Package>
<Private-Package>
org.apache.felix.http.jetty,
- org.mortbay.*;-split-package:=merge-first
+
org.mortbay.jetty.*;-split-package:=merge-first
</Private-Package>
<Import-Package>
javax.net.ssl; javax.security.cert;
Tim