Struts2 Action class validate method
<p>Trying to use validate method on Struts 2.3.4 but got below error:</p>

<blockquote>
  <p>java.lang.NullPointerException</p>
  
  <p>at com.action.LogonAction.validate(LogonAction.java:66)
  more......</p>
</blockquote>

<p><strong>Action class:</strong></p>

<pre><code>public class LogonAction extends ActionSupport{

private Logon logon;

public Logon getLogon() {
    return logon;
}

public void setLogon(Logon logon) {
    this.logon = logon;
}

public String execute(){
    return SUCCESS;
}

public void validate(){
    if(logon.getUserName() == null  || logon.getUserName().equals("")){
        addFieldError("logon.userName", "userName required");
    }

}
</code></pre>

<p><strong>Logon.class:</strong></p>

<pre><code>public class Logon {

private String password;
private String userName;


public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}

public String getUserName() {
    return userName;
}
public void setUserName(String userName) {
    this.userName = userName;
}
}
</code></pre>

<p><strong>struts.xml:</strong></p>

<pre class="lang-xml prettyprint-override"><code>&lt;struts&gt;

&lt;package name="struts2" namespace="/" extends="struts-default"&gt;

    &lt;action name="login" class="com.action.LogonAction"&gt;
        &lt;result name="input"&gt;Login.jsp&lt;/result&gt;
        &lt;result name="success"&gt;success.jsp&lt;/result&gt;
    &lt;/action&gt;

&lt;/package&gt;
</code></pre>

<p></p>

<p><strong>jsp:</strong></p>

<pre class="lang-jsp prettyprint-override"><code>&lt;s:form action="login" method="post"&gt;
&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;User name:&lt;s:textfield name="userName"/&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;s:submit type="button" value="submit" label="Submit" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;/s:form&gt;
</code></pre>

<p>Is there any way to fix this other than using the new version of Struts2?
Because I found one post said that Struts 2.3.4 have validate method bug.</p>