Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Problem when trying to mix a Jetty-12 ee8 Servlet and Jetty Handler s

Hello,

I am trying to migrate my application using an embedded jetty 10 (10.0.20) to jetty 12 (12.0.14) and I would like to migrate all I can to the Jetty Handler paradigm (rather than Servlet). Yet, my application uses the ImageServlet of JasperReports 6 which relies on Servlet 4.0.

I have written this :

Server httpServer = ...

 

ContextHandler adminContextHandler = new ContextHandler("/admin");

// add the SessionHandler in first place

SessionHandler sessionHandler = new SessionHandler();

adminContextHandler.setHandler(sessionHandler);

Handler.Sequence adminHandlers = new Handler.Sequence();

sessionHandler.setHandler(adminHandlers);

// the regular adminHandler with the Jetty Handler paradigm

PathMappingsHandler adminHandler = new PathMappingsHandler();

...

// add the adminHandler to the sequence

adminHandlers.addHandler(adminHandler);

 

// the ee8 Servlet for JasperReports which supports Servlet 4.0

// the ImageServlet is a built-in servlet of JasperReport used to get the images from a Html report.

// since ee8 ServletContextHandler seems to not extend ContextHandler,

// I use the addHandler(Supplier<Handler>) method of the Handler.Collection

ServletContextHandler jasperServletContextHandler = new ServletContextHandler();

jasperServletContextHandler.addServlet(ImageServlet.class, "/reports/image");

// add the ServletContextHandler to the Sequence

adminHandlers.addHandler(jasperServletContextHandler);

...

// the collection holding every contexts

ContextHandlerCollection contextCollection = new ContextHandlerCollection(adminContextHandler, ...);

httpServer.setHandler(contextCollection);

When I am trying to make a report, which leads to download an image from the the ImageServlet, I get this Error :

HTTP ERROR 404 Not Found
URI: /admin/reports/image
STATUS: 404
MESSAGE: Not Found
SERVLET: org.eclipse.jetty.ee8.servlet.ServletHandler$Default404Servlet-7c8326a4

I am then not sure that I am using the mix Jetty Handler paradigm and Jetty Servlet EE8 properly. Is it okay to add a ee8 ServletContextHandler into a Handler.Sequence like I did ? It seems to me that with my structure, the ImageServlet is never invoked.

BTW, I was not able to find the source code for the ee8 packages on the jetty-project github.

Thanks for your help.

 

 


Back to the top