Daniel Matthews-Grout created WW-3822:
-----------------------------------------

             Summary: 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
            Priority: Minor


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

        

Reply via email to