You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2012/07/23 15:20:37 UTC
[jira] [Resolved] (WW-3822) Struts 2 and Generic Class - Null
Pointer Exception
[ https://issues.apache.org/jira/browse/WW-3822?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart resolved WW-3822.
-------------------------------
Resolution: Fixed
Assignee: Lukasz Lenart
Solved as suggested, added check if setter exists. Thanks for reporting!
> Struts 2 and Generic Class - Null Pointer Exception
> ---------------------------------------------------
>
> Key: WW-3822
> URL: https://issues.apache.org/jira/browse/WW-3822
> Project: Struts 2
> Issue Type: Bug
> Components: Core Actions
> Affects Versions: 2.3.1.1
> Environment: Windows 7 - Java 6 - Tomcat 7
> Reporter: Daniel Matthews-Grout
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 2.3.5
>
>
> I have a class that extends a generic abstract class and types that generic - e.g.
> class MyClass extends AbstractClass<Integer> ..
> class AbstractClass<ID extends Serializable> {
> public abstract ID getId();
> }
> JSP:
> <s:property value="myClass.id"/>
> The abstract class defined an abstract getter that I implemented in the concrete class. I then referenced this getter in the JSP of a Struts 2 action and got the following:
> java.lang.NullPointerException
> at com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer.getClass(DefaultObjectTypeDeterminer.java:314)
> at com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer.getKeyClass(DefaultObjectTypeDeterminer.java:93)
> at com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor.getProperty(XWorkMapPropertyAccessor.java:93)
> at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2303)
> at ognl.ASTProperty.getValueBody(ASTProperty.java:114)
> at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
> at ognl.SimpleNode.getValue(SimpleNode.java:258)
> at ognl.ASTChain.getValueBody(ASTChain.java:141)
> at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
> at ognl.SimpleNode.getValue(SimpleNode.java:258)
> at ognl.Ognl.getValue(Ognl.java:494)
> at ognl.Ognl.getValue(Ognl.java:458)
> ....
> So what I had to do was to add a another get/set pair in the concrete class that updated/read from the same field. This stopped the error.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira