You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tiles.apache.org by "Scot Meyer (JIRA)" <ji...@apache.org> on 2007/03/07 19:17:11 UTC
[jira] Created: (TILES-134) NullPointer Exception when tiles
servlet is not defined
NullPointer Exception when tiles servlet is not defined
-------------------------------------------------------
Key: TILES-134
URL: https://issues.apache.org/struts/browse/TILES-134
Project: Tiles
Issue Type: Improvement
Components: tiles-jsp (jsp support)
Affects Versions: 2.0.2
Environment: Tomcat 5.5.20, jre1.5_06
Reporter: Scot Meyer
When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
--- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
+++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
@@ -136,13 +136,11 @@
*
* @param nestedTag the put tag desciendent.
*/
- public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
+ public void processNestedTag(PutAttributeTag nestedTag) {
ComponentAttribute attribute = new ComponentAttribute(
nestedTag.getValue(), nestedTag.getRole(),
nestedTag.getType());
- if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
-
componentContext.putAttribute(
nestedTag.getName(),
attribute
~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonio Petrelli reassigned TILES-134:
--------------------------------------
Assignee: Antonio Petrelli
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonio Petrelli resolved TILES-134.
------------------------------------
Resolution: Fixed
Fix Version/s: 2.0.2
Issue resolved by throwing a JspException in ContainerTagSupport.doStartTag when no container has been found.
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
> Fix For: 2.0.2
>
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonio Petrelli updated TILES-134:
-----------------------------------
Affects Version/s: (was: 2.0.2)
2.0.1
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.1
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonio Petrelli updated TILES-134:
-----------------------------------
Affects Version/s: (was: 2.0.1)
2.0.2
Whoops! sorry, it does affect 2.0.2 version.
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40475 ]
Antonio Petrelli commented on TILES-134:
----------------------------------------
The container can be (currently) initialized through the use of TilesServlet, TilesListener or the <tiles:initContainer> tag.
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40464 ]
Antonio Petrelli commented on TILES-134:
----------------------------------------
Scot wrote:
---
Honestly without completly inspecting the code I assumed that there was good reason for container being null in startContext and it appeared that the componentContext was only initially retrieved from the container at this point. So perhaps its really a check of the componentContext validity after the if in the startContext although putting it in doStartTag would effectively be the same assuming you checked after the startContext method call.
---
Well, in fact you're right, because attribute tags extend(ed) ContainerTagSupport, though they really don't need them (they interact only with parent tags), see TILES-135
In the remaining tags (the Insert***Tag classes) the container is essential to work (at least they need to use the correct ComponentContext).
I committed some code (very different from the one you posted, sorry) that throws a JspException in ContainerTagSupport.doStartTag when a container is not found.
Thanks a lot anyway, your effort was not thrown away! And go on inspecting code, every help is welcome :-)
Let me know if it fits your needs, so I will resolve this issue.
Antonio
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (TILES-134) NullPointer Exception when tiles servlet
is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonio Petrelli closed TILES-134.
----------------------------------
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
> Fix For: 2.0.2
>
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Scot Meyer (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scot Meyer updated TILES-134:
-----------------------------
Honestly without completly inspecting the code I assumed that there was good reason for container being null in startContext and it appeared that the componentContext was only initially retrieved from the container at this point. So perhaps its really a check of the componentContext validity after the if in the startContext although putting it in doStartTag would effectively be the same assuming you checked after the startContext method call.
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Antonio Petrelli (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40455 ]
Antonio Petrelli commented on TILES-134:
----------------------------------------
I think you opened a Pandora's vase!
In fact when a TilesContainer is not present (by not using TilesServlet or other means of container initialization), everything will fail.
Anyway I think that your proposed patch is not enough, I think that throwing a JspException in ContainerTagSupport.doStartTag when a container is not found is a better solution.
Thoughts?
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TILES-134) NullPointer Exception when tiles
servlet is not defined
Posted by "Scot Meyer (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/TILES-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scot Meyer updated TILES-134:
-----------------------------
At first glance it looks good. I will dl and recompile and check it out, later. Is there anticipation that the container would be initialized potentially outside the tiles servlet? i will document this if that is the case. I would think though in most cases the TilesServlet is the way to go.
> NullPointer Exception when tiles servlet is not defined
> -------------------------------------------------------
>
> Key: TILES-134
> URL: https://issues.apache.org/struts/browse/TILES-134
> Project: Tiles
> Issue Type: Improvement
> Components: tiles-jsp (jsp support)
> Affects Versions: 2.0.2
> Environment: Tomcat 5.5.20, jre1.5_06
> Reporter: Scot Meyer
> Assigned To: Antonio Petrelli
>
> When implementing a simple template and the tiles servlet is not defined in the web.xml you get a NullPointer exception at line 144 when running. This can be difficult for the implementer to realize what they did wrong. A suggestion would be to throw and exception when the context is null. It might be better to throw a TilesException however the interface defines a JspException so I used it.
> --- RenderTagSupport.java 2007-03-05 16:53:50.000000000 -0500
> +++ tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java 2007-03-05 16:52:49.000000000 -0500
> @@ -136,13 +136,11 @@
> *
> * @param nestedTag the put tag desciendent.
> */
> - public void processNestedTag(PutAttributeTag nestedTag) throws JspException {
> + public void processNestedTag(PutAttributeTag nestedTag) {
> ComponentAttribute attribute = new ComponentAttribute(
> nestedTag.getValue(), nestedTag.getRole(),
> nestedTag.getType());
> - if (componentContext==null) throw new JspException("componentContext is null. Do you have the org.apache.tiles.servlet.TilesServlet defined in the web.xml?");
> -
> componentContext.putAttribute(
> nestedTag.getName(),
> attribute
> ~
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.