Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341736

Summary: Jetty Nested OSGi integration
Product: [RT] Jetty Reporter: Greg Wilkins <gregw>
Component: serverAssignee: Hugues Malphettes <hmalphettes>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: holger.staudacher, jetty-inbox, slewis
Version: 7.3.1   
Target Milestone: 7.4.x   
Hardware: All   
OS: All   
Whiteboard:

Description Greg Wilkins CLA 2011-04-04 01:17:33 EDT
Allow the jetty nested connector (JETTY-1354) to be used from OSGi
Comment 1 Greg Wilkins CLA 2011-04-04 01:19:17 EDT
I've split out (r2959) the servlet to a test-jetty-nested module and left the jetty-nested module as just a connector on which something has to call service.
Comment 2 Hugues Malphettes CLA 2011-04-04 02:12:52 EDT
Thanks Greg!

The goal of this enhancement is to support something similar to servlet bridge except that the entire jetty-osgi will be run inside equinox and all the http requests from the external servlet container will be routed to their web-bundles running inside jetty-osgi.
Comment 3 Hugues Malphettes CLA 2011-05-03 03:26:42 EDT
The goal of this enhancement is to support the ability to have an HttpServlet handle the errors or to user jetty's ErrorPageErrorHandler's API.

A simple static method would be used to set the servlet or to access the ErrorPageErrorHandler.
Comment 4 Hugues Malphettes CLA 2011-05-03 03:32:23 EDT
(In reply to comment #3)
> The goal of this enhancement is to support the ability to have an HttpServlet
> handle the errors or to user jetty's ErrorPageErrorHandler's API.
> 
> A simple static method would be used to set the servlet or to access the
> ErrorPageErrorHandler.
Wrong bug sorry for the noise.
Comment 5 Hugues Malphettes CLA 2011-05-06 21:00:05 EDT
Fixed for 7.4.1

Method 1: use a servlet to handle the error.
To setup a servlet called when the HttpService is sending an error:
org.eclipse.jetty.osgi.httpservice.HttpServiceErrorHandlerHelper.setHttpServiceErrorHandler(HttpServlet)

In this servlet the error code, exception object etc can be access using the org.eclipse.jetty.servlet.Dispatcher constants.
For example:
int errorCode = httpServletRequest.getAttribute(Dispatcher.ERROR_STATUS_CODE)


Method 2: configure the jetty error handler org.eclipse.jetty.osgi.httpservice.HttpServiceErrorPageErrorHandler.getInstance()
returns an ErrorPageErrorHandler which API enables the configuration of the error handling.
Comment 6 Hugues Malphettes CLA 2011-05-06 21:25:16 EDT
I keep commenting the wrong bug and I am starting to blame my browser somehow.

This enhancement is more or less ready now.
We end-up reusing servletbridge from equinox (http://www.eclipse.org/equinox/server/http_in_container.php) with an extended FrameworkLauncher.

The project that builds the war that bootstraps equinox with the extended framework launcher is jetty-osgi-servletbridge.
At the moment it is not built with the rest of jetty because we cannot find servletbridge on the central maven repository.

The webstarterkit build and jetty-osgi-boot contain a typical jetty xml configuration for equinox inside an extended jetty-nested-connector is configured.
When started it registers a servlet delegate into the equinox's ServletBridge.
After this both web-bundles and the HttpService are running inside equinox+jetty and will receive the request dispatched from the external web-server.

The extended FrameworkLauncher supports bootstrapping installations made by p2.
The base FrameworkLauncher provided by equinox assumes a roaming layout for the eclipse installation. The extended one we put in place reads the p2's ini file to locate where the bundles are.
Once this is all stable and we figure out all those enhancemet we will propose to equinox to adopt them.

A new optional init-parameter defines the location of the eclipse installation.
It detects if that installation is in a folder that is writeable and in that case it will run it in place. The original FrameworkLauncher would copy the eclipse installation in a temporary folder.
Comment 7 Hugues Malphettes CLA 2012-05-08 20:34:51 EDT
Marking as fixed as suggested by Jan.
We are looking at how to build it with the rest of jetty: just missing the equinox-servletbridge in maven central.