Results 1 to 3 of 3

Thread: error integrating Spring MVC and Tiles

  1. #1
    Join Date
    Jun 2006
    Posts
    4

    Default error integrating Spring MVC and Tiles

    Hi all,
    trying to get a new app up and running using SpringMVC and Tiles. Get an NPE on startup (stack below). I will post my config files, if anyone's interested, but it seems like my problem is pretty basic -- like I'm missing some jar or some config for the JspFactory class. When I look at the code that throws the NPE, it's this:

    public ExpressionFactory getExpressionFactory() {
    return JspFactory.getDefaultFactory().getJspApplicationCo ntext(
    servletContext).getExpressionFactory();
    }

    Any advice?
    Thank you in advance,
    Olia


    Code:
    [tomcat:launch] java.lang.NullPointerException
    
    [tomcat:launch]         at org.apache.tiles.el.JspExpressionFactoryFactory.getExpressionFactory(JspExpressionFactoryFactory.java:61)
    
    [tomcat:launch]         at org.apache.tiles.el.ELAttributeEvaluator.init(ELAttributeEvaluator.java:106)
    
    [tomcat:launch]         at org.apache.tiles.factory.TilesContainerFactory.storeContainerDependencies(TilesContainerFactory.java:459)
    
    [tomcat:launch]         at org.apache.tiles.factory.TilesContainerFactory.initializeContainer(TilesContainerFactory.java:378)
    
    [tomcat:launch]         at org.apache.tiles.factory.TilesContainerFactory.createTilesContainer(TilesContainerFactory.java:293)
    
    [tomcat:launch]         at org.apache.tiles.factory.TilesContainerFactory.createContainer(TilesContainerFactory.java:237)
    
    [tomcat:launch]         at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
    
    [tomcat:launch]         at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
    
    [tomcat:launch]         at org.springframework.web.servlet.view.tiles2.TilesConfigurer.afterPropertiesSet(TilesConfigurer.java:203)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    
    [tomcat:launch]         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
    
    [tomcat:launch]         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    
    [tomcat:launch]         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    
    [tomcat:launch]         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
    
    [tomcat:launch]         at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
    
    [tomcat:launch]         at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
    
    [tomcat:launch]         at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
    
    [tomcat:launch]         at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    
    [tomcat:launch]         at javax.servlet.GenericServlet.init(GenericServlet.java:241)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
    
    [tomcat:launch]         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    
    [tomcat:launch]         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    
    [tomcat:launch]         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    
    [

  2. #2
    Join Date
    Jun 2006
    Posts
    4

    Default

    Ah, figured it out. Turns out it's a Tomcat 6 thing. You need to pre-load Jasper. Here is what solved it for me:

    add a listener (if you don't already have one).
    Config in web.xml to enable:

    <listener>
    <listener-class>imdb.webserverUtil.BaseTomcatListener</listener-class>
    </listener>



    Listener code:
    Code:
    package imdb.webserverUtil;
    
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    
    
    public class BaseTomcatListener implements ServletContextListener {
    
    	public void contextDestroyed(ServletContextEvent sce) {
    	}
    
    	public void contextInitialized(ServletContextEvent sce) {
    		try {	
    			Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
    		} catch (Exception e) {
    			System.out.println(e.toString());
    		}
    	}
    }

  3. #3
    Join Date
    Dec 2010
    Posts
    315

    Default

    The way you integrate Spring MVC and Tiles seems very obstrusive. In my implementation, I just had to provide the TilesViewResolver (the new one) and the accompanying xml config. The controllers only reference the String names you declared in the xml.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •