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

Thanks,

Sorry for the annoyance if I wasn't on the right list. To close this problem, here are the results :

I finally used your method and you were right, it really was a conflict between javax.servlet and org.eclipse.equinox.http.servlet.

In fact, instructions on the equinox website, says to checkout the following projects :

- javax.servlet
- org.apache.commons.logging
- org.eclipse.equinox.http.jetty
- org.eclipse.equinox.http.registry
- org.eclipse.equinox.http.servlet
- org.mortbay.jetty

Or, these projects do not use the same javax.servlet API , so , your own project may use randomly one of these Servlet API.

I first tried to use the same Servlet api as the http.registry project, but could not figure out wich one it really was because javax.servlet is not a project dependency but just an Imported Package.
I succesfully changed the dependencies in all these projects to make them use the same API javax.servlet ( I still don't know if it's the actual better solution , but this way, I was really sure they all use the same ).
The result is that it works fine from now.

These are the patchs if someone needs them.

Thanks to you

Greetings

Sébastien JUST



### Eclipse Workspace Patch 1.0
#P org.eclipse.equinox.http.jetty
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.equinox.http.jetty/META-INF/MANIFEST.MF,v
retrieving revision 1.2
diff -u -r1.2 MANIFEST.MF
--- META-INF/MANIFEST.MF    29 Sep 2006 19:11:26 -0000    1.2
+++ META-INF/MANIFEST.MF    1 Nov 2006 18:10:28 -0000
@@ -4,9 +4,7 @@
 Bundle-SymbolicName: org.eclipse.equinox.http.jetty
 Bundle-Version: 1.0.0.qualifier
 Bundle-Activator: org.eclipse.equinox.http.jetty.internal.Activator
-Import-Package: javax.servlet;version="[2.4.0,2.5.0)",
- javax.servlet.http;version="[2.4.0,2.5.0)",
- org.eclipse.equinox.http.servlet;version="1.0.0",
+Import-Package: org.eclipse.equinox.http.servlet;version="1.0.0",
  org.mortbay.http;version="[5.1.0,6.0.0)",
  org.mortbay.jetty.servlet;version="[5.1.0,6.0.0)",
  org.mortbay.util;version="[5.1.0,6.0.0)",
@@ -14,3 +12,4 @@
 Bundle-RequiredExecutionEnvironment: J2SE-1.4,
  CDC-1.0/Foundation-1.0,
  J2SE-1.3
+Require-Bundle: javax.servlet



### Eclipse Workspace Patch 1.0
#P org.eclipse.equinox.http.registry
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.equinox.http.registry/META-INF/MANIFEST.MF,v
retrieving revision 1.3
diff -u -r1.3 MANIFEST.MF
--- META-INF/MANIFEST.MF    29 Sep 2006 19:10:14 -0000    1.3
+++ META-INF/MANIFEST.MF    1 Nov 2006 18:21:21 -0000
@@ -6,10 +6,9 @@
 Bundle-Activator: org.eclipse.equinox.http.registry.internal.Activator
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.equinox.common,
- org.eclipse.equinox.registry
-Import-Package: javax.servlet;version="2.3",
- javax.servlet.http;version="2.3",
- org.osgi.framework;version="1.3.0",
+ org.eclipse.equinox.registry,
+ javax.servlet
+Import-Package: org.osgi.framework;version="1.3.0",
  org.osgi.service.http;version="1.2.0",
  org.osgi.service.packageadmin;version="1.2.0",
  org.osgi.util.tracker;version="1.3.1"


### Eclipse Workspace Patch 1.0
#P org.eclipse.equinox.http.servlet
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF,v
retrieving revision 1.2
diff -u -r1.2 MANIFEST.MF
--- META-INF/MANIFEST.MF    29 Sep 2006 18:46:34 -0000    1.2
+++ META-INF/MANIFEST.MF    1 Nov 2006 18:22:14 -0000
@@ -8,8 +8,7 @@
 Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,
  J2SE-1.3
 Export-Package: org.eclipse.equinox.http.servlet;version="1.0.0"
-Import-Package: javax.servlet;version="2.3",
- javax.servlet.http;version="2.3",
- org.osgi.framework;version="1.3.0",
+Import-Package: org.osgi.framework;version="1.3.0",
  org.osgi.service.http;version="1.2.0"
 Eclipse-LazyStart: true
+Require-Bundle: javax.servlet




Kaegi, Simon wrote:
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.
 
-Simon
 
 
 

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

Hi,

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

http://localhost:8080/BaseServlet


HTTP ERROR: 500
org.seij.jenova.server.impl.BaseServlet
RequestURI=/BaseServlet/
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++) {
                        System.out.println(is[i].getName());
                    }
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++) {
                        System.out.println(is[i].getName());
                    }
                   
                    Servlet newDelegate = (Servlet) extension;
                    newDelegate.init(config);
                    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.

_______________________________________________ equinox-dev mailing list equinox-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/equinox-dev