Hello, this used to work previously but not anymore, lease point on what I'm missing...

Java 19 from GraalVM.

Below are the code snippets, but the test project in on github, https://github.com/fedd/cameljettyssl (it also tests the SSL which also seized working. Run and try access http://localhost:8585 for non SSL - it doesn't print the strings on session start)

    private static final String JETTY = "jetty";
    private static final String JETTYINSECURE = "jetty-insecure";
    .....
                // creating another jetty component for insecure access. So there are two jettys, one for http another for https                 // see https://stackoverflow.com/questions/67920367/create-http-and-https-endpoint-using-camel-in-the-same-server-with-jetty                 getContext().addComponent(JETTYINSECURE, new JettyHttpComponent9());
    .....
                // Jetty style session handlers. They can't be reused in both components of jetty, so there are two of them
                // this one for the insecure jetty
                final SessionHandler sess = new SessionHandler();
                String sessionHandlerString = "jettySessionHandler";
getContext().getRegistry().bind(sessionHandlerString, sess); // supposed to make it available to the "from" uri
                // thsi one for the https jetty
                final SessionHandler sessHttps = new SessionHandler();
                String sessionHandlerHttpsString = "jettySessionHandlerHttps";
getContext().getRegistry().bind(sessionHandlerHttpsString, sessHttps);

                // a standard session listener that will be invoked by the jetty handlers (see below)
                // TODO: doesn't work
                HttpSessionListener sessionListener = new HttpSessionListener() {
                    @Override
                    public void sessionCreated(HttpSessionEvent se) {
System.out.println("-----------------------SESSIONSTARTED-----------------------");
                    }

                    @Override
                    public void sessionDestroyed(HttpSessionEvent se) {
System.out.println("-----------------------SESSIONDESTROYED-----------------------");
                    }
                };
                // this object can be used in both copies of jetty component
                sess.addEventListener(sessionListener);
                sessHttps.addEventListener(sessionListener);

                // a simple home grown dispatcher for the catch-all uri path
                Processor dispatcher = new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
    ...........
                    }
                };

                // initialize two jettys with https and http
                // session handler doesn't get invoked (neither with nor without the #hash)                 from(JETTY + ":https://0.0.0.0:8543?matchOnUriPrefix=true&enableMultipartFilter=true&handlers=#jettySessionHandlerHttps";)
                        .process(dispatcher);

                from(JETTYINSECURE + ":http://0.0.0.0:8585?matchOnUriPrefix=true&enableMultipartFilter=true&handlers=#jettySessionHandler";)
                        .process(dispatcher);

Thanks!

Reply via email to