Announcement Announcement Module
Collapse
No announcement yet.
Null Pointer Exception with Tiles2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Null Pointer Exception with Tiles2

    Hello,

    I am attempting to configure tiles2 with spring 2.5. The spring conf file is as follow:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="messageSource"
    class="org.springframework.context.support.Resourc eBundleMessageSource">
    <property name="basename" value="messages" />
    </bean>

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBas edViewResolver">
    <property name="viewClass"
    value="org.springframework.web.servlet.view.tiles2 .TilesView" />
    </bean>

    <bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles2 .TilesConfigurer">
    <property name="definitions">
    <list>
    <value>/WEB-INF/defs/definitions.xml</value>
    </list>
    </property>
    </bean>

    <bean id="urlMapping"
    class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="/*.html">viewController</prop>
    </props>
    </property>
    </bean>

    <bean id="viewController"
    class="org.springframework.web.servlet.mvc.UrlFile nameViewController" />
    </beans>

    The tiles file is as follows:

    <tiles-definitions>

    <!-- DEFAULT MAIN TEMPLATE -->
    <definition name="template" page="/WEB-INF/jsp/main.jsp"/>

    <definition name="index" extends="template">
    <put name="content" value="/WEB-INF/jsp/index.jsp" type="page"/>
    </definition>

    </tiles-definitions>

    When I deploy to to tomcat, it deploys fine - however when I visit the url to try and view a page, I get:

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.apache.tiles.TilesException
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:535)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:453)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)

    root cause

    org.apache.tiles.TilesException
    org.apache.tiles.impl.BasicTilesContainer.render(B asicTilesContainer.java:427)
    org.apache.tiles.impl.BasicTilesContainer.render(B asicTilesContainer.java:370)
    org.springframework.web.servlet.view.tiles2.TilesV iew.renderMergedOutputModel(TilesView.java:83)
    org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:252)
    org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1162)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:900)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:808)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:523)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:453)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)

    root cause

    java.lang.NullPointerException
    org.apache.tiles.servlet.context.ServletTilesReque stContext.forward(ServletTilesRequestContext.java: 198)
    org.apache.tiles.servlet.context.ServletTilesReque stContext.dispatch(ServletTilesRequestContext.java :185)
    org.apache.tiles.impl.BasicTilesContainer.render(B asicTilesContainer.java:419)
    org.apache.tiles.impl.BasicTilesContainer.render(B asicTilesContainer.java:370)
    org.springframework.web.servlet.view.tiles2.TilesV iew.renderMergedOutputModel(TilesView.java:83)
    org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:252)
    org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1162)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:900)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:808)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:523)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:453)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:803)


    I have searched around the forums and outside but I cannot see what the issue could be. Has anyone come across this and if so could you point me in the right direction please?

    Thanks, in advance for your help.

    Cheers,

    Neil
    Last edited by neil.benn; May 17th, 2008, 03:26 PM. Reason: typo in header

  • #2
    Null Pointer Exception with Tiles2

    Hello,

    A quick update, looking through the logs coming out from spring, there is something which is possibly relevant:

    DEBUG [http-8080-1] (UrlDefinitionsFactory.java:253) - File jndi:/localhost/web-based-barcode-decoding-0.0.1-SNAPSHOT/WEB-INF/defs/definitions_en.xml not found, continue
    DEBUG [http-8080-1] (UrlDefinitionsFactory.java:253) - File jndi:/localhost/web-based-barcode-decoding-0.0.1-SNAPSHOT/WEB-INF/defs/definitions_en_GB.xml not found, continue
    DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='index' extends='main'.
    DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='index' extends='main'.
    DEBUG [http-8080-1] (BasicTilesContainer.java:416) - Dispatching to definition path 'null '
    ERROR [http-8080-1] (BasicTilesContainer.java:425) - Error rendering tile
    java.lang.NullPointerException

    --

    I guess that is a language file but I cannot find any reference to these files in the docs!!

    Cheers,

    Neil

    Comment


    • #3
      Solution

      I had same problem. Finally i found solution.

      Change

      <definition name="template" page="/WEB-INF/jsp/main.jsp"/>

      to

      <definition name="template" template="/WEB-INF/jsp/main.jsp"/>

      Attribute page works only with tiles1 not with tiles2.

      Comment


      • #4
        FYI,

        Changed page attribute to template attribute in tiles definition and worked a treat.

        Credit to mystik on this one.

        Comment


        • #5
          check this link: :http://forum.springframework.org/showthread.php?t=47712

          hope this helps you.

          Regards,

          DeepEdward

          Comment

          Working...
          X