Hi Robert,

I cannot promise a fix within JCS anytime soon, as this requires a major 
release (4) of JCS. So let’s see what we can do instead.

> Am 11.06.2025 um 16:13 schrieb robertlazarski <robertlazar...@gmail.com>:
> 
> Indeed, org.apache.commons.jcs3.utils.servlet.JCSServletContextListener via
> web.xml or modern equivalent. I am trying to get that working in the latest
> Spring Boot 3
> 

Actually, JCSServletContextListener doesn't do very much. It only makes sure 
that JCS is shut down properly when the web application stops. In your case, 
that saves the cache keys to the auxiliary disk cache, which may or may not be 
necessary, depending on what you want to cache. If you have other means of 
hooking into the shutdown process of your application (Spring Boot: 
@PreDestroy), just add the line

JCS.shutdown();

somewhere.

In all other cases, this is the complete code of the servlet filter:
—8<— 
public class JCSServletContextListener
implements ServletContextListener
{
  /** The logger */
  private static final Log log = Log.getLog( JCSServletContextListener.class );

  /**
   * Shutdown JCS.
   *
   * @see 
javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
   */
  @Override
  public void contextDestroyed( final ServletContextEvent arg0 )
  {
    log.debug( "contextDestroyed, shutting down JCS." );

    JCS.shutdown();
  }

  /**
   * This does nothing. We don't want to initialize the cache here.
   *
   * @see 
javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
   */
  @Override
  public void contextInitialized( final ServletContextEvent arg0 )
  {
    log.debug( "contextInitialized" );
  }
} 
—8<— 

HTH
Bye, Thomas 
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to