Details

      Description

      Spring 4
      Resteasy 3.0.6
      Tomcat 7

      I've recently upgraded to Spring 4 and am using the spring configuration with SpringContextLoaderListener.

      Spring 4 have removed the deprecated ContextLoaderListener#createContextLoader - so this method is never invoked. See ( http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/web/context/ContextLoaderListener.html#getContextLoader() )

      Current workaround:

      public class MyContextLoaderListener extends ContextLoaderListener {
      	private SpringContextLoaderSupport springContextLoaderSupport = new SpringContextLoaderSupport();
      	@Override
      	protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext configurableWebApplicationContext) {
      		
      		super.customizeContext(servletContext, configurableWebApplicationContext);		
      		this.springContextLoaderSupport.customizeContext(servletContext, configurableWebApplicationContext);
      	}
      }
      

      Edit: 19.04.2014
      Seems like a couple of others are looking for a solution so will post a more complete solution/workaround..

      MyContextLoaderListener.java

      public class MyContextLoaderListener extends ContextLoaderListener {
       
      	private SpringContextLoaderSupport springContextLoaderSupport = new SpringContextLoaderSupport();
       
      	@Override
      	public void contextInitialized(ServletContextEvent event) {
      		boolean scanProviders = false;
      		boolean scanResources = false;
       
      		String sProviders = event.getServletContext().getInitParameter(
      				"resteasy.scan.providers");
      		if (sProviders != null) {
      			scanProviders = Boolean.valueOf(sProviders.trim());
      		}
      		String scanAll = event.getServletContext().getInitParameter(
      				"resteasy.scan");
      		if (scanAll != null) {
      			boolean tmp = Boolean.valueOf(scanAll.trim());
      			scanProviders = tmp || scanProviders;
      			scanResources = tmp || scanResources;
      		}
      		String sResources = event.getServletContext().getInitParameter(
      				"resteasy.scan.resources");
      		if (sResources != null) {
      			scanResources = Boolean.valueOf(sResources.trim());
      		}
       
      		if (scanProviders || scanResources) {
      			throw new RuntimeException(
      					"You cannot use resteasy.scan, resteasy.scan.resources, or resteasy.scan.providers with the SpringContextLoaderLister as this may cause serious deployment errors in your application");
      		}
       
      		super.contextInitialized(event);
      	}	
      	@Override
      	protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext configurableWebApplicationContext) {
      		
      		super.customizeContext(servletContext, configurableWebApplicationContext);		
      		this.springContextLoaderSupport.customizeContext(servletContext, configurableWebApplicationContext);
      	}
      }
      

      web.xml

      <listener>
      	<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
      </listener> 
      <!-- listener>
      	<listener-class>org.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
      </listener -->   
      <listener>	
      	<listener-class>yourpackage.spring.MyContextLoaderListener</listener-class>
      </listener>
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bill.burke Bill Burke
                Reporter:
                magnus.kvalheim Bård Magnus Kvalheim
              • Votes:
                12 Vote for this issue
                Watchers:
                15 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: