terjekid commented on PR #3579:
URL: https://github.com/apache/avro/pull/3579#issuecomment-3892346218

   It seems that the mentioned [example 
program](https://github.com/apache/avro/blob/main/lang/java/ipc-jetty/src/test/java/org/apache/avro/ipc/jetty/TestStatsPluginAndServlet.java#L175)
 has some issues as starting it throws the following exception: `Multiple 
servlets map to path /: 
org.apache.avro.ipc.jetty.StaticServlet-477b4cdf[mapped:EMBEDDED:null],org.apache.avro.ipc.stats.StatsServlet-7770f470[mapped:EMBEDDED:null]`
   
   Removing the StaticServlet the page can load but no js/css available on the 
page. The following code in `StatServer(StatsPlugin plugin, int port)` worked 
and loaded the css/js files also (the `StaticServlet` not needed):
   ```
       ServletContextHandler servletContext = new 
ServletContextHandler(ServletContextHandler.SESSIONS);
       servletContext.setContextPath("/");
   
       ServletHolder servletHolder = new ServletHolder(new 
StatsServlet(plugin));
       servletContext.addServlet(servletHolder, "/");
   
       ResourceHandler resourceHandler = new ResourceHandler();
       
resourceHandler.setBaseResource(Resource.newClassPathResource("/org/apache/avro/ipc/stats/static"));
       resourceHandler.setDirectoriesListed(false); // Optional: prevent 
directory listing
   
       ContextHandler staticContext = new ContextHandler();
       staticContext.setContextPath("/static");
       staticContext.setHandler(resourceHandler);
   
       HandlerList handlers = new HandlerList();
       handlers.setHandlers(new org.eclipse.jetty.server.Handler[] {
           staticContext, // Static content first
           servletContext // Servlet second (will catch the root '/' not caught 
by staticContext)
       });
   
       httpServer.setHandler(handlers);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to