[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [equinox-dev] Server Side problem - Servlet ClassCastException

Hi Sebastien,
You should ask this type of question in the equinox user newsgroup.
That said...
If I had to, I'd guess that your bundle is resolving the Servlet API against a different bundle than http.registry.
Check if you have two bundles that are exporting the servlet api.
If that's not it can you send the result of an "ss" in the console.

From: equinox-dev-bounces@xxxxxxxxxxx [mailto:equinox-dev-bounces@xxxxxxxxxxx] On Behalf Of sebastien
Sent: Wednesday, November 01, 2006 10:51 AM
To: equinox-dev@xxxxxxxxxxx
Subject: [equinox-dev] Server Side problem - Servlet ClassCastException


I'm just trying to build-up a new HTTP/Servlet server based on Equinox.
I followed exactly the instructions on http://www.eclipse.org/equinox/server/http_in_equinox.php
I also created a new bundle, an can access the static resources in this bundle.

I tried then to create a new Servlet named BaseServlet, extending HTTPServlet. Then created a new Extension to the org.eclipse.equinox.http.registry.servlets extension point, then access via my browser.
But it fails on HTTP 500


Powered by Jetty://

In my console logs I see :

GRAVE: /BaseServlet/:
java.lang.ClassCastException: org.seij.jenova.server.impl.BaseServlet
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.initializeDelegate(ServletManager.java:154)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:128)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:91)

Or, I'm sure BaseServlet implements Servlet anyway ( I searched hours )

I tried also to touch the code of org.eclipse.equinox.http.registry.internal.ServletManager, and it appears that IConfigurationElement.createExecutableExtension(CLASS) ( line 143 ) ; returns me  the correct class, but , for an unknown reason, it doesn't casts to Servlet anymore !!!

But with a simple check, I
                    Class[] is = extension.getClass().getInterfaces();
                    for ( int i = 0 ; i < is.length ; i++) {
It appears that my class is anyway an implementation of javax.servlet.Servlet

But anyway, the line after my test :

Servlet newDelegate = (Servlet) extension;

Gots the classCastException ....

I'm sorry to bother you with that but I still can't understand. Have we got problems with createExecutableExtension() ??

Complete modified code source for test :

package org.eclipse.equinox.http.registry.internal;
public class ServletManager implements ExtensionPointTracker.Listener {


        private synchronized void initializeDelegate() throws ServletException {
            if (delegate == null) {
                try {
                    Object extension = element.createExecutableExtension(CLASS);
                    Class[] is = extension.getClass().getInterfaces();
                    for ( int i = 0 ; i < is.length ; i++) {
                    Servlet newDelegate = (Servlet) extension;
                    delegate = newDelegate;
                } catch (CoreException e) {
                    throw new ServletException(e);



Can someone help ?

Thank you

Sébastien JUST

     This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.