Calling servlets in org.eclipse.equinox.http [message #78395] |
Mon, 04 December 2006 19:38 |
John J. Barton Messages: 311 Registered: July 2009 |
Senior Member |
|
|
I am trying to get org.eclipse.equinox.http to run inside of
eclipse and delegate to my servlet in a plugin. I got it to
start and to call my plugin Activator. But when I try to GET
a page I fail with a class loading error,
<plugin name> was unable to load class <servletname>.
Any Hints?
The eclipse PDE provided MANIFEST.MF for my plugin is
------------------------------
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: AjaxProxy Plug-in
Bundle-SymbolicName: com.ibm.research.AjaxProxy; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.ibm.research.ajaxproxy.Activator
Bundle-Vendor: IBM Almaden Reseach Center
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources
Eclipse-LazyStart: true
Bundle-ClassPath: bin/,
.
----------------------------------
To get my plugin to compile I put javax.servlet on my plugins build
path, but fact is not apparent from the MANIFEST.MF, plugin.xml, or
build.propreties.
I also don't understand why the server is started, I guess I am grateful
so far but I expected it to have to cause it to load and start when my
plugin started.
Thanks,
John.
|
|
|
Re: Calling servlets in org.eclipse.equinox.http [message #78416 is a reply to message #78395] |
Mon, 04 December 2006 23:14 |
John J. Barton Messages: 311 Registered: July 2009 |
Senior Member |
|
|
More "information", which is to say stuff I think is relevant but
may be chaff:
The HTTP server starts if I run a "Equinox OSGi Framework" launch
configuration; it does *not* start if I run an "Eclipse Application".
I understand "Eclipse Application" as a clone of my dev env with the
plugins I am developing injected. I don't know what the Equinox thing
is, except that it starts the HTTP server but it has no GUI (console
osgi>).. It does have the interesting setting "Start plugins
automatically", set to true.
In the "Eclipse Application" version I can see the http plugin if the
print all bundles:
369:Bundle Name=org.eclipse.equinox.http id=382 state=RESOLVED
Bundle-ManifestVersion = 2
Bundle-Vendor = Eclipse.org
Bundle-Version = 1.0.100.qualifier
Bundle-Activator = org.eclipse.equinox.http.Activator
Bundle-Copyright = Copyright (c) IBM Corp. 1999, 2005
Bundle-SymbolicName = org.eclipse.equinox.http
Bundle-Name = HTTP Service
Import-Package =
javax.servlet,javax.servlet.http,org.osgi.framework;version= "1.0",org.osgi.service.cm;version="1.0",org.osgi.service.http;version= "1.1",org.osgi.service.log;version="1.0",org.osgi.util.tracker;version= "1.1",org.eclipse.osgi.util
Export-Package =
org.eclipse.equinox.http;x-internal:=true,org.eclipse.equino x.http.servlet;x-internal:=true,org.eclipse.equinox.socket;x -internal:=true,org.eclipse.equinox.socket.https;x-internal: =true
Import-Service = org.osgi.service.log.LogService
Export-Service = org.osgi.service.http.HttpService
Bundle-Localization = plugin
-----------------------------
If I print all services, nothing with "http" shows up.
So it looks like the http plugin is available but not offering its
service. I'll see if I can call its "start()" method somehow
JOHN J. BARTON wrote:
> I am trying to get org.eclipse.equinox.http to run inside of
> eclipse and delegate to my servlet in a plugin. I got it to
> start and to call my plugin Activator. But when I try to GET
> a page I fail with a class loading error,
> <plugin name> was unable to load class <servletname>.
> Any Hints?
>
> The eclipse PDE provided MANIFEST.MF for my plugin is
> ------------------------------
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: AjaxProxy Plug-in
> Bundle-SymbolicName: com.ibm.research.AjaxProxy; singleton:=true
> Bundle-Version: 1.0.0
> Bundle-Activator: com.ibm.research.ajaxproxy.Activator
> Bundle-Vendor: IBM Almaden Reseach Center
> Bundle-Localization: plugin
> Require-Bundle: org.eclipse.ui,
> org.eclipse.core.runtime,
> org.eclipse.core.resources
> Eclipse-LazyStart: true
> Bundle-ClassPath: bin/,
> .
> ----------------------------------
> To get my plugin to compile I put javax.servlet on my plugins build
> path, but fact is not apparent from the MANIFEST.MF, plugin.xml, or
> build.propreties.
>
> I also don't understand why the server is started, I guess I am grateful
> so far but I expected it to have to cause it to load and start when my
> plugin started.
>
> Thanks,
> John.
|
|
|
|
Re: Calling servlets in org.eclipse.equinox.http [message #78597 is a reply to message #78428] |
Thu, 07 December 2006 03:40 |
Eclipse User |
|
|
|
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com
Launch an Equinox framework and set the bundles you want to be started
on the appropriate tab in the launch configuration dialog. This is the
easiest way to run something and control what is started and at what level.
if you are runnign an Eclipse application, it is just that, an
application. This may be your IDE or some RCP app you wrote or... In
that case you genearlly do not have control over what is started when
unless you provide a template config.ini that lists the bundles you want
started on the osgi.bundles list.
as for automatically starting bundles on restart, yes, this is part of
the OSGi spec. Once marked as "started" (by calling Bundle.start()), a
bundle is started automatically until it is stopped (by calling
Bundle.stop()).
Jeff
JOHN J. BARTON wrote:
> I was able to get my servlet called. My recipe:
> 1) Walk the BundleContext given to me when my plugin started
> looking for a bundle with getSymbolicName() equal to
> org.eclipse.equinox.http; return that bundles getBundleId().
> (getSymbolicName() is OSGi speak; plugin id is eclipse speak for the
> same string).
>
> 2) Use the BundleContext again to getBundle(id) above; call "start()" on
> the result.
>
> Now the server is started. Big surprise: it will start in the future
> without this step. Ouch.
>
> 3) repeat #1 and #2 with org.eclipse.equinox.http.registry.
>
> Now the servlet is registered and gets called by server. And subsequent
> runs of the code don't need steps 1-3 because of some magic unknown to me.
>
> Surely this is not the right way to do this,
> John.
|
|
|
|
Re: Calling servlets in org.eclipse.equinox.http [message #78770 is a reply to message #78669] |
Sat, 09 December 2006 04:24 |
Eclipse User |
|
|
|
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com
JOHN J. BARTON wrote:
> Is there another way to prevent auto-restart other than Bundle.stop()?
> My basic activity in Plugin development involves launching the app,
> running it until is crashes or I kill it, then launching again. With
> auto-restart I won't be getting the same result each time and I can't
> reliably call Bundle.stop() because my code is broken. Maybe this
> config.ini thing can be erased each time?
Well, it is part of the spec and there is no option to turn that off per
se. In Equinox however you can run with -clean (there is actually a
check box for this in the Equinox framework launcher) in which case all
bundles are removed and reinstalled (and as such, not started until
someone start()s them).
Another option is to use the
Eclipse-LazyStart: true
header in your bundles. This tells Equinox to start() your bundles the
first time one of their classes is loaded. This may work for some
bundles as is but adding this flag (if I recall correctly) has the side
effect that if you start() such a bundle explicitly, that fact is not
persisted across restarts.
Jeff
|
|
|
Powered by
FUDForum. Page generated in 0.02845 seconds