001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.http.commons;
007
008import org.springframework.beans.factory.BeanDefinitionStoreException;
009import org.springframework.web.context.ContextLoaderListener;
010
011import javax.servlet.ServletContextEvent;
012
013import static org.slf4j.LoggerFactory.getLogger;
014
015/**
016 * This class wraps the standard Spring ContextLoaderListener in order to catch initialization errors.
017 * 
018 * @author awoods
019 * @since 2016-06-09
020 */
021public class FedoraContextLoaderListener extends ContextLoaderListener {
022
023    private static final org.slf4j.Logger LOGGER = getLogger(FedoraContextLoaderListener.class);
024
025    @Override
026    public void contextInitialized(final ServletContextEvent event) {
027        try {
028            super.contextInitialized(event);
029        } catch (final BeanDefinitionStoreException e) {
030            final String msg = "\n" +
031                    "=====================================================================\n" +
032                    "=====================================================================\n" +
033                    "---------- FEDORA CONFIGURATION ERROR ----------\n" +
034                    "\n" +
035                    "See documentation specific to your version of Fedora\n" +
036                    "https://wiki.lyrasis.org/display/FEDORA6x/Application+Configuration\n" +
037                    "\n" +
038                    "=====================================================================\n" +
039                    "=====================================================================\n";
040            LOGGER.error(msg);
041        }
042
043    }
044
045}