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
|