sebastien | 1 Nov 16:51

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





Kaegi, Simon | 1 Nov 18:12

RE: 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.
 
-Simon
 
 
 
From: equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org [mailto:equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org] On Behalf Of sebastien
Sent: Wednesday, November 01, 2006 10:51 AM
To: equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
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.
Nikunj Mehta | 1 Nov 19:00
Picon

Servlet API support

The equinox bundle org.eclipse.equinox.servlet.api_1.0.0 containing the servlet API says that it exports javax.servlet; version =2.3 and javax.servlet.http; version =2.3.

However, none of the >2.1 servlet API features work when using org.eclipse.equinox.http_1.0.100 bundle and result in

java.lang.UnsupportedOperationException: HttpService only supports servlet 2.1 specification.

Can someone throw light on the reason behind such behavior?

Nikunj
Kaegi, Simon | 1 Nov 19:21

RE: Servlet API support

The OSGi HttpService requires a minimum of Servlet 2.1 support.
The org.eclipse.equinox.http bundle provides just such a minimal implementation and is tiny in terms of its overall size.
The trade-off is that it doesn't support the Servlet API beyond 2.1. Changes were put in the code so that it would still be able to resolve against a higher Servlet API albeit throws UnsupportedOperationExceptions for the use of those methods.
 
If you want an Http Service that supports Servlet 2.4 you can use the Jetty based implementation e.g. org.eclipse.equinox.http.jetty.
See http://www.eclipse.org/equinox/server/http_in_equinox.php (I'd recommend using the teamset to collect up the right dependencies)
 
HTH
-Simon

From: equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org [mailto:equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org] On Behalf Of Nikunj Mehta
Sent: Wednesday, November 01, 2006 1:00 PM
To: equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
Subject: [equinox-dev] Servlet API support

The equinox bundle org.eclipse.equinox.servlet.api_1.0.0 containing the servlet API says that it exports javax.servlet; version =2.3 and javax.servlet.http; version =2.3.

However, none of the >2.1 servlet API features work when using org.eclipse.equinox.http_1.0.100 bundle and result in
java.lang.UnsupportedOperationException: HttpService only supports servlet 2.1 specification.

Can someone throw light on the reason behind such behavior?

Nikunj
 
     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.
Nikunj Mehta | 1 Nov 19:25
Picon

Re: Servlet API support

Simon,

I am aware the the OSGi HttpService has a minimum expectation of Servlet API support which is being met by the equinox service. My point is, however, that the OSGi versioning and dependency resolution is broken here since I express a dependency on the desired version but still can't find out until runtime that my selection of bundles was incorrect.

Does this appear as a limitation of OSGi or is there something smarter that equinox can do in terms of declaring exports in its manifest?

Thanks for the jetty heads up!

Nikunj.

On 11/1/06, Kaegi, Simon <Simon.Kaegi-z7oUXpO1oczQT0dZR+AlfA@public.gmane.org> wrote:
The OSGi HttpService requires a minimum of Servlet 2.1 support.
The org.eclipse.equinox.http bundle provides just such a minimal implementation and is tiny in terms of its overall size.
The trade-off is that it doesn't support the Servlet API beyond 2.1. Changes were put in the code so that it would still be able to resolve against a higher Servlet API albeit throws UnsupportedOperationExceptions for the use of those methods.
 
If you want an Http Service that supports Servlet 2.4 you can use the Jetty based implementation e.g. org.eclipse.equinox.http.jetty.
See http://www.eclipse.org/equinox/server/http_in_equinox.php (I'd recommend using the teamset to collect up the right dependencies)
 
HTH
-Simon

From: equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org [mailto:equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org] On Behalf Of Nikunj Mehta
Sent: Wednesday, November 01, 2006 1:00 PM
To: equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
Subject: [equinox-dev] Servlet API support

The equinox bundle org.eclipse.equinox.servlet.api_1.0.0 containing the servlet API says that it exports javax.servlet; version =2.3 and javax.servlet.http; version =2.3.

However, none of the >2.1 servlet API features work when using org.eclipse.equinox.http_1.0.100 bundle and result in
java.lang.UnsupportedOperationException: HttpService only supports servlet 2.1 specification.

Can someone throw light on the reason behind such behavior?

Nikunj
 
     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-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev



sebastien | 1 Nov 19:36

Re: 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
<at> <at> -4,9 +4,7 <at> <at>
 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)",
<at> <at> -14,3 +12,4 <at> <at>
 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
<at> <at> -6,10 +6,9 <at> <at>
 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
<at> <at> -8,8 +8,7 <at> <at>
 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-j9T/66MeVpFAfugRpC6u6w@public.gmane.org [mailto:equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org] On Behalf Of sebastien
Sent: Wednesday, November 01, 2006 10:51 AM
To: equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
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-j9T/66MeVpFAfugRpC6u6w@public.gmane.org https://dev.eclipse.org/mailman/listinfo/equinox-dev

BJ Hargrave | 1 Nov 19:40
Picon
Favicon

Re: Servlet API support

OSGi package versioning is working fine.

You are seeing an implementation issue with the httpservice 
implementation. It just has not (fully) implemented those methods. They 
methods are present but their implementation just throws an exception. The 
OSGi framework or JVM have not way of knowing this. 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargrave@...

office: +1 407 849 9117
mobile: +1 386 848 3788

"Nikunj Mehta" <nrmehtais@...> 
Sent by: equinox-dev-bounces@...
11/01/2006 01:25 PM
Please respond to
Equinox development mailing list <equinox-dev@...>

To
"Equinox development mailing list" <equinox-dev@...>
cc

Subject
Re: [equinox-dev] Servlet API support

Simon,

I am aware the the OSGi HttpService has a minimum expectation of Servlet 
API support which is being met by the equinox service. My point is, 
however, that the OSGi versioning and dependency resolution is broken here 
since I express a dependency on the desired version but still can't find 
out until runtime that my selection of bundles was incorrect. 

Does this appear as a limitation of OSGi or is there something smarter 
that equinox can do in terms of declaring exports in its manifest?

Thanks for the jetty heads up!

Nikunj.

On 11/1/06, Kaegi, Simon <Simon.Kaegi@...> wrote:
The OSGi HttpService requires a minimum of Servlet 2.1 support.
The org.eclipse.equinox.http bundle provides just such a minimal 
implementation and is tiny in terms of its overall size.
The trade-off is that it doesn't support the Servlet API beyond 2.1. 
Changes were put in the code so that it would still be able to resolve 
against a higher Servlet API albeit throws UnsupportedOperationExceptions 
for the use of those methods.

If you want an Http Service that supports Servlet 2.4 you can use the 
Jetty based implementation e.g. org.eclipse.equinox.http.jetty.
See http://www.eclipse.org/equinox/server/http_in_equinox.php (I'd 
recommend using the teamset to collect up the right dependencies)

HTH
-Simon 

From: equinox-dev-bounces@... [mailto:
equinox-dev-bounces@...] On Behalf Of Nikunj Mehta
Sent: Wednesday, November 01, 2006 1:00 PM
To: equinox-dev@...
Subject: [equinox-dev] Servlet API support

The equinox bundle org.eclipse.equinox.servlet.api_1.0.0 containing the 
servlet API says that it exports javax.servlet; version =2.3 and 
javax.servlet.http; version =2.3.

However, none of the >2.1 servlet API features work when using 
org.eclipse.equinox.http_1.0.100 bundle and result in
java.lang.UnsupportedOperationException: HttpService only supports servlet 
2.1 specification.

Can someone throw light on the reason behind such behavior? 

Nikunj

     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@...
https://dev.eclipse.org/mailman/listinfo/equinox-dev

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

Thomas Watson | 1 Nov 22:04
Picon
Favicon

Equinox projects tagged for 3.3 M3 build


Two more fixes in Equinox for M3.

The map file has been updated for the following Bug changes:
+ Bug 162935. BundleDescription leak in UserState (FIXED)
+ Bug 163106. GenericDescription leak in Resolver (FIXED)

The following projects have changed:
org.eclipse.osgi

Tom

Jeff McAffer | 2 Nov 02:05
Picon

Re: Server Side problem - Servlet ClassCastException


I'm not following here.  That list of bundles should include only one set of javax.servlet packages so everyone will be bound to the same one.  Are you sayig that http.servlet also includes the javax.servlet packages?  Note that we are actively moving away from Require-Bundle for these sorts of infrastructure bundles where pluggability really is an option.

Jeff



sebastien <sebastien-579njTLRwr8@public.gmane.org>
Sent by: equinox-dev-bounces <at> eclipse.org

11/01/2006 01:36 PM

Please respond to
Equinox development mailing list <equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org>

To
Equinox development mailing list <equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org>
cc
Subject
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
<at> <at> -4,9 +4,7 <at> <at>
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)",
<at> <at> -14,3 +12,4 <at> <at>
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
<at> <at> -6,10 +6,9 <at> <at>
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
<at> <at> -8,8 +8,7 <at> <at>
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-j9T/66MeVpFAfugRpC6u6w@public.gmane.org [mailto:equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org] On Behalf Of sebastien
Sent: Wednesday, November 01, 2006 10:51 AM
To: equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
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-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev
 
_______________________________________________
equinox-dev mailing list
equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Nikunj Mehta | 2 Nov 02:07
Picon

Eclipse plugin for equinox

Hi,

What is the most effective way of updating a bundle and rerunning the OSGi environment with the new bundle *if its component descriptions have changed*?

Thanks,
Nikunj


Gmane