Target Unreachable, identifier resolved to null with defined Bean [duplicate] - jsf-2

This question already has answers here:
Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
(18 answers)
Closed 7 years ago.
Lately, I have been getting weird error's that mean one thing, but I'm experiencing another. Typically when this error occurs, it means that my Bean is not properly named, and therefore I am trying to reach a Bean that doesn't exist. An example can be found here: JSF Target unreachable identifier resolved to null.
In this case, I'm using CDI:
package account;
import general.Env;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
#ManagedBean(name="account")
#SessionScoped
public class Account implements Serializable{
String username;
String password;
String ouName;
String error = "";
Logger log = LogManager.getLogger("QCAuth");
public String getOuName() {
return ouName;
}
public void setOuName(String ouName) {
this.ouName = ouName;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
My html that is throwing the error:
<h:form id="form" method="post" onsubmit="return fullCheck()">
<div id="userdiv" class="form-inline">
<label for="username" class="control-label" style="color: #2E8AE6;margin-right:
50px">Username: </label>
<h:inputText class="form-control" id="user" style="margin-right: 125px" value="#
{account.username}"/>
</div>
<div class="form-inline">
</div>
<div id="passdiv" class="form-inline">
<label for="password" class="control-label" style="color: #2E8AE6;margin-right:
50px">Password: </label>
<h:inputText class="form-control" id="pass" style="margin-right: 123px" value="#
{account.password}"/>
</div>
<div class="form-inline">
<h:commandButton styleClass="btn btn-primary" style="background-image:linear-
gradient(to bottom, #2E8AE6 0%, #174470 100%);
color:#000000" id="submit" value="Submit" action="#{account.login}"/>
</div>
</h:form>
Stack trace:
WARNING: /index.xhtml #75,107 value="#{account.username}": Target Unreachable, identifier
'account' resolved to null
javax.el.PropertyNotFoundException: /index.xhtml #75,107 value="#{account.username}": Target
Unreachable, identifier 'account' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue
(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
at javax.faces.component.UIInput.validate(UIInput.java:976)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
at javax.faces.component.UIInput.processValidators(UIInput.java:712)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'account' resolved
to null
at org.apache.el.parser.AstValue.getTarget(AstValue.java:97)
at org.apache.el.parser.AstValue.getType(AstValue.java:81)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:171)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
I have my beans.xml (which is empty) in my WEB-INF folder. When trying to fill out a value or action of the jsf components, Eclipse provides "account" as a possible Bean, and I am able to pull the getters, setters, and methods of the Bean through default proposals. Essentially, Eclipse is telling me the bean is properly defined. Any possible cause of this error?
Edit: for whatever reason as well, when inspecting my web page before form submission occurs, my javascript has errors in it as well. I double checked and everything looks fine. Not sure if this would help
Edit 2: It turns out all my identifiers are appearing as null. Just tried my env bean and got the following stack trace:
javax.servlet.ServletException: javax.el.PropertyNotFoundException: /index.xhtml #102,259
action="#{env.devMode}": Target Unreachable, identifier 'env' resolved to null
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:67)
root cause
javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /index.xhtml #102,259
action="#{env.devMode}": Target Unreachable, identifier 'env' resolved to null
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAd
apter.java:94)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:67)
root cause
javax.el.PropertyNotFoundException: /index.xhtml #102,259 action="#{env.devMode}": Target
Unreachable, identifier 'env' resolved to null
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAd apter.java:87)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:67)
Class:
package general;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
#ManagedBean(name="env")
#ViewScoped
public class Env {
public static boolean prod = true;
public static String[] ouValues;
static int i = 0;
public static void initialize()
{
getConfigProperties config = new getConfigProperties();
Properties prop = config.getConfig();
String temp = prop.getProperty("ouValues");
ArrayList<String> tempProdArr= new ArrayList<String>(Arrays.asList(temp.split("\\s*,\\s*")));
ouValues=tempProdArr.toArray(new String[tempProdArr.size()]);
}
public static String[] getOuValues() {
return ouValues;
}
public static void setOuValues(String[] ouValues) {
Env.ouValues = ouValues;
}
public static boolean isProd()
{
if (i == 0) {
initialize();
i = 1;
}
return prod;
}
public String devMode() {
prod = false;
return "index.xhtml";
}
public void prodMode() {
prod = true;
}
}
So basically, I have multiple beans that are being confused for being null identifiers when they are actually properly defined. Could my install of eclipse be causing this? Or maybe a tomcat related issue such as not properly loading my managed beans? I really have no clue where to go from here.

A failure to Define class org.apache.directory.ldap.client.api.LdapConnection was causing my Account class to not load. As a result, Tomcat was unable to find the class. After including this jar in my WEB-INF/lib folder, these errors went away.

Related

Variable cannot be resolved error in struts2

My requirement is am trying to populate pid(projectid) from project table and name from userdetails table as an drop down for a form.Am new to struts framework. Could someone please throw us some light on this issue please.
Here is the code:
sprintform.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="css/jquery.ui.datepicker.css" rel="stylesheet"
type="text/css" />
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.17.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){$('.dateTxt').datepicker({
dateFormat : 'yy-mm-dd'
}); });
</script>
</head>
<body>
<h1 style="color: green">Sprint</h1>
<s:form action="sprintInsert" namespace="/" method="post"
name="sprintForm" theme="xhtml">
<s:textfield name="title:" size="40" maxlength="40" required="true"
label="Title" />
<p>
Begin Date: <input id="one" class="dateTxt" type="text"
name="begindate" />
</p>
<p>
End Date: <input id="two" class="dateTxt" type="text" name="enddate" />
</p>
<s:select label="ProjectId" headerKey="-1"
headerValue="Select Project Id" list="projectidList" name="pid" />
<%-- <s:select label="Owner" headerKey="-1"
headerValue="Select Sprint Owner" list="sprintownerList"
name="sprintowner" /> --%>
<tr>
<td>State:</td>
<td><select name="state">
<option value="">Choose a state..</option>
<option value="A">Active</option>
<option value="F">Future</option>
<option value="C">Close</option>
</select></td>
</tr>
<s:textfield name="targetestimatedpoints" size="40" maxlength="40"
required="true" label="Target Estimate pts:" />
<s:textfield name="totalestimatedpoints" size="40" maxlength="40"
required="true" label="Total Estimate pts:" />
<s:textfield name="totaldefaultestimatedhours" size="40"
maxlength="40" required="true" label="Total Detail Estimate Hrs: " />
<s:textfield name="todohours:" size="40" maxlength="40"
required="true" label="Total To Do Hrs:" />
<s:textfield name="description: :" size="40" maxlength="40"
required="true" label="Description: " />
<tr align="right">
<td><div align="center">
<input type="submit" value="save">
</div>
<td align="center"><input type="reset" value="Reset"></td>
</tr>
</s:form>
<s:if test="hasActionErrors()">
<div id="fieldErrors">
<s:actionerror />
</div>
</s:if>
</body>
</html>
SprintAction.java:
package com.bits.sprintanalyzer.action;
import java.util.List;
import org.apache.log4j.Logger;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.dao.SprintDAO;
import com.opensymphony.xwork2.ActionSupport;
public class SprintAction extends ActionSupport {
private static final Logger LOG = Logger.getLogger(SprintAction.class);
/**
*
*/
private static final long serialVersionUID = -6257623073537028210L;
private String title;
private String begindate;
private String enddate;
private String pid;
private String sprintowner;
private String state;
private int targetestimatedpoints;
private int totalestimatedpoints;
private int totaldefaultestimatedhours;
private int todohours;
private String description;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getSprintowner() {
return sprintowner;
}
public void setSprintowner(String sprintowner) {
this.sprintowner = sprintowner;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getTargetestimatedpoints() {
return targetestimatedpoints;
}
public void setTargetestimatedpoints(int targetestimatedpoints) {
this.targetestimatedpoints = targetestimatedpoints;
}
public int getTotalestimatedpoints() {
return totalestimatedpoints;
}
public void setTotalestimatedpoints(int totalestimatedpoints) {
this.totalestimatedpoints = totalestimatedpoints;
}
public int getTotaldefaultestimatedhours() {
return totaldefaultestimatedhours;
}
public void setTotaldefaultestimatedhours(int totaldefaultestimatedhours) {
this.totaldefaultestimatedhours = totaldefaultestimatedhours;
}
public int getTodohours() {
return todohours;
}
public void setTodohours(int todohours) {
this.todohours = todohours;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String display() throws Exception {
return INPUT;
}
public String getBegindate() {
return begindate;
}
public void setBegindate(String begindate) {
this.begindate = begindate;
}
public String getEnddate() {
return enddate;
}
public void setEnddate(String enddate) {
this.enddate = enddate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<String> getpidList() throws ResourceException {
return SprintDAO.getpidList();
}
public List<String> getOwnerList() throws ResourceException {
return SprintDAO.getOwnerList();
}
#Override
public void validate() {
}
#Override
public String execute() throws Exception {
LOG.info("title" + title);
LOG.info("begindate" + begindate);
LOG.info("enddate" + enddate);
LOG.info("pid" + pid);
LOG.info("sprintowner" + sprintowner);
LOG.info("state" + state);
LOG.info("targetestimatedpoints" + targetestimatedpoints);
LOG.info("totalestimatedpoints" + totalestimatedpoints);
LOG.info("totaldefaultestimatedhours" + totaldefaultestimatedhours);
LOG.info("todohours" + todohours);
LOG.info("description" + description);
// ProjectDAO.insert(projectname,description,scrummaster,productowner,begindate,enddate);
int i = SprintDAO.save(this);
if (i > 0) {
return "success";
}
return "error";
}
}
SprintDAO:
package com.bits.sprintanalyzer.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.action.SprintAction;
import com.bits.sprintanalyzer.util.ConnectionUtil;
public class SprintDAO {
private static final String PROJECTQUERY = "select pid from project";
private static final String USERQUERY = "select name from userdetail";
public static List<String> getpidList() throws ResourceException{
List<String> projectidList = new ArrayList<String>();
// this should be populated from DB
try (Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement st = con.prepareStatement(PROJECTQUERY)){
ResultSet rs =st.executeQuery();
while(rs.next()){
projectidList.add(rs.getString(1));
}
return projectidList;
}
catch (SQLException | ResourceException e) {
throw new ResourceException("Failed to validate project id", e);
}
}
public static List<String> getOwnerList() throws ResourceException{
List<String> sprintownerList = new ArrayList<String>();
// this should be populated from DB
try (Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement st = con.prepareStatement(USERQUERY)){
ResultSet rs =st.executeQuery();
while(rs.next()){
sprintownerList.add(rs.getString(1));
}
return sprintownerList;
}
catch (SQLException | ResourceException e) {
throw new ResourceException("Failed to validate productowner", e);
}
}
//insert into database
public static int save(SprintAction SA) throws Exception{
int status=0;
try{
Connection con = ConnectionUtil.INSTANCE.getConnection();
PreparedStatement ps = con.prepareStatement("insert into sprint(pid,title,begindate,enddate,owner,state,targetestimatedpoints,totalestimatedpoints,totaldefaultestimatedhours,todohours,description) values(?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1, SA.getPid());
ps.setString(2, SA.getTitle());
ps.setString(3, SA.getBegindate());
ps.setString(4, SA.getEnddate());
ps.setString(5, SA.getSprintowner());
ps.setString(6, SA.getState());
ps.setInt(7, SA.getTargetestimatedpoints());
ps.setInt(8, SA.getTotalestimatedpoints());
ps.setInt(9, SA.getTotaldefaultestimatedhours());
ps.setInt(10, SA.getTodohours());
ps.setString(11, SA.getDescription());
status=ps.executeUpdate();
}catch(Exception e){
e.printStackTrace();}
return status;
}
}
struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"/WEB-INF/classes/struts-2.1.7.dtd">
<struts>
<!--
You could also set the constants in the struts.properties file
placed in the same directory as struts.xml
-->
<constant name="struts.devMode" value="true" />
<package name="sprintanalyzer" extends="struts-default" namespace="/">
<!--
If no class attribute is specified the framework will assume success and
render the result index.jsp
If no name value for the result node is specified the success value is the default
-->
<action name="">
<result>/jsp/login.jsp</result>
</action>
<!--
If the URL is hello.action then call the execute method of class HelloWorldAction.
If the result returned by the execute method is success render the HelloWorld.jsp
-->
<action name="login" class="com.bits.sprintanalyzer.action.LoginAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
<result name="input">/jsp/login.jsp</result>
</action>
<action name="projectform" class="com.bits.sprintanalyzer.action.ProjectAction"
method="display">
<result name="input">/jsp/projectform.jsp</result>
</action>
<action name="projectInsert" class="com.bits.sprintanalyzer.action.ProjectAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
</action>
<action name="sprintform" class="com.bits.sprintanalyzer.action.SprintAction"
method="display">
<result name="input">/jsp/sprintform.jsp</result>
</action>
<action name="sprintInsert" class="com.bits.sprintanalyzer.action.SprintAction"
method="execute">
<result name="success">/jsp/sprintanalyzer.jsp</result>
</action>
</package>
</struts>
Issue is coming from both projectidlist and sprintownerList. Please advise accordingly.
Please find below stacktrace:
2016-10-01T18:23:38.916+0530|Info: 2016-10-01 18:23:38,916 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:38.917+0530|Info: 2016-10-01 18:23:38,917 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:38.925+0530|Info: 2016-10-01 18:23:38,924 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:38.925+0530|Info: 2016-10-01 18:23:38,925 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:57.121+0530|Info: 2016-10-01 18:23:57,120 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:57.121+0530|Info: 2016-10-01 18:23:57,121 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:23:57.128+0530|Info: 2016-10-01 18:23:57,128 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.opensymphony.xwork2.ActionSupport) could not locate the message resource with key 'Login'
2016-10-01T18:23:57.129+0530|Info: 2016-10-01 18:23:57,128 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'Login' was evaluated and did not match a property. The literal value 'Login' will be used.
2016-10-01T18:24:03.841+0530|Severe: Sat Oct 01 18:24:03 IST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2016-10-01T18:24:04.022+0530|Info: 2016-10-01 18:24:04,021 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The first TextProvider in the ValueStack (com.bits.sprintanalyzer.action.LoginAction) could not locate the message resource with key 'welcome to Sprint Analyzer Tool'
2016-10-01T18:24:04.022+0530|Info: 2016-10-01 18:24:04,022 WARN org.apache.struts2.util.TextProviderHelper.warn:45 - The default value expression 'welcome to Sprint Analyzer Tool' was evaluated and did not match a property. The literal value 'welcome to Sprint Analyzer Tool' will be used.
2016-10-01T18:24:06.835+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
at org.apache.struts2.components.UIBean.end(UIBean.java:510)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at org.apache.jsp.jsp.sprintform_jsp._jspx_meth_s_select_0(sprintform_jsp.java:236)
at org.apache.jsp.jsp.sprintform_jsp._jspx_meth_s_form_0(sprintform_jsp.java:144)
at org.apache.jsp.jsp.sprintform_jsp._jspService(sprintform_jsp.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptorcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
2016-10-01T18:24:06.844+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at
Here is the login code:
package com.bits.sprintanalyzer.action;
import org.apache.log4j.Logger;
import com.bits.sprintanalyzer.ResourceException;
import com.bits.sprintanalyzer.dao.LoginDAO;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private static final Logger LOG = Logger.getLogger(LoginAction.class);
/**
*
*/
private static final long serialVersionUID = 6877145894906143530L;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
#Override
public void validate(){
if (username==null || username.length()==0 || password ==null || password.length() ==0 )
addActionError(getText("User name or Password cannot be null"));
}
#Override
public String execute() throws Exception {
try{
if( LoginDAO.isValidUser(username, password) ){
return SUCCESS;
}
else
{
addActionError(getText("Invalid Username or Password"));
}
}catch(ResourceException e){
LOG.error("Failed to valid User", e);
addActionError(getText("Something Went wrong with DBConnection"));
}
return INPUT;
}
}
Latest stacktrace after changing connection string:
2016-10-01T18:55:04.396+0530|Warning: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'pid': The requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
at org.apache.struts2.components.UIBean.end(UIBean.java:510)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at va:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
1) You have MySQL connection exception as below:
Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
To resolve this use the connection string like below:(change the db name to your existing db name)
jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useSSL=false
This needs to be sorted first, that's why the values of the variables are not been rendered
2) In the Latest trace the requested list key 'projectidList' could not be resolved as a collection/array/map/enumeration/iterator type.
This error occurs when you try to access a list/collection which haven't been created.
Try to initialize the collection objects List<String> projectidList at class level.
when particular action is triggered at that time, JSP page is not knowing the the type of field, in this case, when you write List<String> projectidList = new ArrayList<String>(); instead of this, change it to ArrayList projectidList = new ArrayList();.
Make sure that you access list after the action class is instantiated i.e. corresponding action is called.
If you want to directly access it before calling action make it static and access it inside jsp.

Cannot load sidepanel.jelly in Jenkins plugin

Im getting the next error when I try to load "sidepanel.jelly" in my Jenkins plugin action jelly file.
javax.servlet.ServletException: org.apache.commons.jelly.JellyTagException: file:/C:/Documents%20and%20Settings/Tecnoy/Escritorio/vats_eclipse/src/main/resources/org/jenkinsci/plugins/vats/VatsBuildAction/index.jelly:4:42: <st:include> No page found 'sidepanel.jelly' for class org.jenkinsci.plugins.vats.VatsBuildAction
at org.kohsuke.stapler.jelly.JellyClassTearOff.serveIndexJelly(JellyClassTearOff.java:117)
at org.kohsuke.stapler.jelly.JellyFacet.handleIndexRequest(JellyFacet.java:127)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:717)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:390)
...
Caused by: org.apache.commons.jelly.JellyTagException: file:/C:/Documents%20and%20Settings/Tecnoy/Escritorio/vats_eclipse/src/main/resources/org/jenkinsci/plugins/vats/VatsBuildAction/index.jelly:4:42: <st:include> No page found 'sidepanel.jelly' for class org.jenkinsci.plugins.vats.VatsBuildAction
at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:124)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
...
My jelly file has the following lines
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:t="/lib/hudson">
<l:layout norefresh="true">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<h1>Vats Summary:</h1>
<div id="canvas-holder">
<p><canvas id="chart-area" width="300" height="300"/></p>
</div>
<script type="text/javascript" src="${resURL}/plugin/vats/scripts/chart.min.js"></script>
<script type="text/javascript">
...
</script>
<canvas id="myChart" width="400" height="400"></canvas>
</l:main-panel>
</l:layout>
</j:jelly>
Any idea how can I fix it?
Thanks!
Add the <l:main-panel> tag and the the <l:layout norefresh="true">tag to the index.jelly file.
And include the side panel:
Pass the the build to Action (through a parameter of the constructor)
The build can be retrieved out of the parameters of the perform method which is inherited from the BuildStepCompatibilityLayer class (by Extending Publisher).
Create a getBuild() method in the Action class
Add the <st:include it="${it.build}" page="sidepanel.jelly" /> tag with the build
Jelly Example (index.jelly):
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<l:layout norefresh="true">
<st:include it="${it.build}" page="sidepanel.jelly" />
<l:main-panel>
<f:validateButton title="${%Restart Jenkins}" progress="${%Restarting...}" method="JksRestart" with="" />
</l:main-panel>
</l:layout>
</j:jelly>
Java Action class example:
package tryPublisher.tryPublisher;
import hudson.model.Action;
import hudson.model.AbstractBuild;
public class ExampleAction implements Action {
AbstractBuild<?,?> build;
public ExampleAction(AbstractBuild<?,?> build) {
this.build = build;
}
#Override
public String getIconFileName() {
return "/plugin/action.png";
}
#Override
public String getDisplayName() {
return "ExampleAction";
}
#Override
public String getUrlName() {
return "ExampleActionUrl";
}
public AbstractBuild<?,?> getBuild() {
return this.build;
}
}
Java Publisher class example:
package tryPublisher.tryPublisher;
import java.io.IOException;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
public class ExamplePublisher extends Publisher {
#Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}
#Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws InterruptedException, IOException {
build.getActions().add(new ExampleAction(build));
return true;
}
}
The .jelly file has to be in the right resources map of the plugin project. In a map with the same name as the name of the Java class implementing Action. The name of the .jelly is important also.

javax.faces.el.EvaluationException: java.lang.NullPointerException in my jsf web App

I am working on a dynamic Web Application and as a first step i want to use my jsf page to save a new Group in the DataBase .I am connecting to an Oracle 10g DataBase, working on eclipse Kepler, with Glassfish4 and using primefaces 4.0.This the StackTrace
2013-12-07T00:38:34.028+0100|Avertissement: #{groupeBean.createGroupe}: java.lang.NullPointerException
javax.faces.FacesException: #{groupeBean.createGroupe}: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIData.broadcast(UIData.java:1108)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 35 more
Caused by: java.lang.NullPointerException
at com.portail.dao.DaoGroupe.ajouter(DaoGroupe.java:21)
at com.portail.managedBeans.GroupeBean.createGroupe(GroupeBean.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.el.parser.AstValue.invoke(AstValue.java:275)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 36 more
This is the code of the managedBean
#ManagedBean
#ViewScoped
public class GroupeBean {
private Groupe newGroupe=new Groupe();
public Groupe getNewGroupe() {
return newGroupe;
}
public void setNewGroupe(Groupe newGroupe) {
this.newGroupe = newGroupe;
}
private DaoGroupe gdao= new DaoGroupe();
public void createGroupe()
{
gdao.ajouter(newGroupe);
}}
This is the code of the Dao Class
public class DaoGroupe {
private static final String JPA_UNIT_NAME="Portail";
private EntityManager entityManager;
protected EntityManager getEntityManager() {
if (entityManager == null) {
entityManager = Persistence.createEntityManagerFactory(
JPA_UNIT_NAME).createEntityManager();
}
return entityManager;
}
public void ajouter(Groupe g)
{
EntityTransaction tx = entityManager.getTransaction();
tx.begin();
entityManager.persist(g);
tx.commit();}}
And this is the insert tab in my jsf page
<p:tab title="Groupe">
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Nom : *" />
<p:inputText value="#{groupeBean.newGroupe.nom}" required="true"
label="nomgrp" validatorMessage="Nom de Groupe Obligatoire" />
<h:outputText value="Numéro : *" />
<p:inputText value="#{groupeBean.newGroupe.idGroupe}" required="true"
label="numgrp" validatorMessage="Numéro de Groupe Obligatoire" />
</h:panelGrid>
<p:commandButton value="Ajouter"
style="width:205px;margin-left:10%"
action="#{groupeBean.createGroupe}" />
</h:form>
</p:tab>
You get a NullPointerException in your DaoGroupe-Class within the method ajouter.
I guess the entityManager.getTransaction() is the reason, because the entityManager is not filled anywhere. Replacing it with using your getEntityManager()-method might be a first point to start debugging from.
EntityTransaction tx = getEntityManager().getTransaction();
Hope it helps...

FileDownload Component of primefaces causes exception NullPointerException in report generation with JasperReports

I have an application for reporting. When I deploy and run locally, it generates the report and it downloads perfectly, no problems. (Creates the file in the application reports and file download is done)
However, when I deployed the application on the company server, I tried to print the report and the exception occurred NullPointterException.
Here's the stack trace:
Aug 21, 2013 5:26:01 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [FacesServlet] in context with path [/WebMap] threw exception [javax.servlet.ServletException] with root cause
java.lang.NullPointerException
at org.primefaces.component.filedownload.FileDownloadActionListener.processAction(FileDownloadActionListener.java:53)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:84)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:773)
at javax.faces.component.UICommand.broadcast(UICommand.java:296)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at web.web.filter.ConexaoHibernateFilter.doFilter(ConexaoHibernateFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:344)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:110)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:98)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:95)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:120)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:55)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:36)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:106)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:150)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
The code portion of this application is the one below:
Download Page
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
<ui:composition template="/templates/interno.xhtml">
<ui:define name="titulo">
Módulo de Relatórios
</ui:define>
<ui:define name="corpo">
<p:tabView id="tabView">
<p:tab id="tab1" title="Download do relatorio das torres">
<div id="administracao_de_usuarios">
<h:form>
<span style="color: RGB(48, 122, 239);"> Para realizar o download do relatório, clique em uma das
opções de arquivo abaixo: </span>
<br />
<h:messages id="excecoes"
style="list-style-type: decimal; font-size: 14px; padding-left: 5px;"
title="Erros de preenchimento encontrados" />
<br />
<h:commandLink title="Relatório em PDF">
<f:setPropertyActionListener target="#{relatorioBean.tipoRelatorio}"
value="1" />
<p:fileDownload value="#{relatorioBean.arquivoRetorno}" />
<h:graphicImage library="imagens" name="pdf.png" />
<span class="menu_link2">Arquivo PDF</span>
</h:commandLink>
</h:form>
</div>
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
</html>
RelatorioBean
import java.util.HashMap;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.primefaces.model.StreamedContent;
import web.util.RelatorioUtil;
import web.util.UtilException;
#ManagedBean(name = "relatorioBean")
#RequestScoped
public class RelatorioBean {
private StreamedContent arquivoRetorno;
private int tipoRelatorio;
public StreamedContent getArquivoRetorno() {
FacesContext context = FacesContext.getCurrentInstance();
String nomeRelatorioJasper = "relatorio";
String nomeRelatorioSaida = "Relatório_torres_de_transmissão";
RelatorioUtil relatorioUtil = new RelatorioUtil();
HashMap parametrosRelatorio = null;
try {
this.arquivoRetorno = relatorioUtil.geraRelatorio(
parametrosRelatorio, nomeRelatorioJasper,
nomeRelatorioSaida, this.tipoRelatorio);
} catch (UtilException e) {
context.addMessage(null, new FacesMessage(e.getMessage()));
return null;
}
return this.arquivoRetorno;
}
public void setArquivoRetorno(StreamedContent arquivoRetorno) {
this.arquivoRetorno = arquivoRetorno;
}
public int getTipoRelatorio() {
return tipoRelatorio;
}
public void setTipoRelatorio(int tipoRelatorio) {
this.tipoRelatorio = tipoRelatorio;
}
}
RelatorioUtil
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import web.util.UtilException;
public class RelatorioUtil {
public static final int RELATORIO_PDF = 1;
public StreamedContent geraRelatorio(HashMap parametrosRelatorio,
String nomeRelatorioJasper, String nomeRelatorioSaida,
int tipoRelatorio) throws UtilException {
StreamedContent arquivoRetorno = null;
try {
FacesContext context = FacesContext.getCurrentInstance();
Connection conexao = this.getConexao();
String caminhoRelatorio = context.getExternalContext().getRealPath(
"relatorios");
String caminhoArquivoJasper = caminhoRelatorio + File.separator
+ "relatorioTorres" + ".jasper";
String caminhoArquivoRelatorio = null;
JasperReport relatorioJasper = (JasperReport) JRLoader
.loadObject(caminhoArquivoJasper);
JasperPrint impressoraJasper = JasperFillManager.fillReport(
relatorioJasper, parametrosRelatorio, conexao);
JRExporter tipoArquivoExportado = null;
String extensaoArquivoExportado = "";
File arquivoGerado = null;
switch (tipoRelatorio) {
case RelatorioUtil.RELATORIO_PDF:
tipoArquivoExportado = new JRPdfExporter();
extensaoArquivoExportado = "pdf";
break;
default:
tipoArquivoExportado = new JRPdfExporter();
extensaoArquivoExportado = "pdf";
break;
}
caminhoArquivoRelatorio = caminhoRelatorio + File.separator
+ nomeRelatorioSaida + "." + extensaoArquivoExportado;
arquivoGerado = new java.io.File(caminhoArquivoRelatorio);
tipoArquivoExportado.setParameter(JRExporterParameter.JASPER_PRINT,
impressoraJasper);
tipoArquivoExportado.setParameter(JRExporterParameter.OUTPUT_FILE,
arquivoGerado);
tipoArquivoExportado.exportReport();
arquivoGerado.deleteOnExit();
InputStream conteudoRelatorio = new FileInputStream(arquivoGerado);
arquivoRetorno = new DefaultStreamedContent(conteudoRelatorio,
"application/" + extensaoArquivoExportado,
nomeRelatorioSaida + "." + extensaoArquivoExportado);
} catch (JRException e) {
throw new UtilException("Não foi possível gerar o relatório.", e);
} catch (FileNotFoundException e) {
throw new UtilException("Arquivo do relatório não encontrado.", e);
}
return arquivoRetorno;
}
private Connection getConexao() throws UtilException {
java.sql.Connection conexao = null;
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext
.lookup("java:/comp/env/");
javax.sql.DataSource ds = (javax.sql.DataSource) envContext
.lookup("jdbc/WebConection");
conexao = (java.sql.Connection) ds.getConnection();
} catch (NamingException e) {
throw new UtilException(
"Não foi possível encontrar o nome da conexão do banco.", e);
} catch (SQLException e) {
throw new UtilException("Ocorreu um erro de SQL.", e);
}
return conexao;
}
}
Can anyone help me to solve this error? Why this locally generating the file and performing the download, but this problem occurs on the server?
Based on PrimeFaces 2.1 source code, a NPE on line 53 of FileDownloadActionListener suggests that #{relatorioBean.arquivoRetorno} actually returned null. Let's look there:
} catch (UtilException e) {
context.addMessage(null, new FacesMessage(e.getMessage()));
return null;
}
It look like that it's returning null when an UtilException is been thrown. That adding of faces message is by the way completely pointless on a file download request. It won't appear anywhere. You'd better print/log the stack trace
} catch (UtilException e) {
e.printStackTrace();
return null;
}
or, better, just remove that whole try-catch and throw that exception directly.
public StreamedContent getArquivoRetorno() throws UtilException {
// ...
}
This way you'll face the real exception instead of a NullPointerException which is hiding the real problem.
After a long time without looking at stackoverflow, I realized that I needed to put the solution to this problem, which occurred a long time ago. So here it is:
In this case I made the report template based on a database table structure, which had a nomenclature pattern.
When I took the code to the server, there was a database table structure, which had a different naming pattern.
In this way, the report was not generated and could not be downloaded, generating NullPointerException.
After noticing that there were minimal changes to the database table structure of the server, I had to redo the report template with iReport Designer, based on the new table structure, which followed a different naming pattern than the previous table structure.
So when I refactored the template based on the new structure, the report generation with JasperReports returned perfectly.

DefaultInstanceManager can not access a member of class with modifiers ""

not sure whats wrong here, please assist.
this is the exception :
SEVERE: Exception starting filter com.bannerplay.beans.LoginFilter
java.lang.IllegalAccessException: Class org.apache.catalina.core.DefaultInstanceManager can not access a member of class com.bannerplay.beans.LoginFilter with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:134)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
login.xhtml
<h:form>
Username : <h:inputText value="#{loginBean.username}" />
Password : <h:inputSecret value="#{loginBean.password}" />
<h:commandButton value="Login" action="#{loginBean.checkLogin}" />
</h:form>
web.xml
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>com.bannerplay.beans.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/login.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
...
and LoginFilter.java
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
#WebFilter("/admin/*")
class LoginFilter implements Filter {
#Override
public void doFilter(ServletRequest request , ServletResponse response , FilterChain chain) throws ServletException, IOException {
HttpSession session = ((HttpServletRequest) request).getSession();
UserBean userBean = (UserBean) session.getAttribute("userBean");
if (userBean != null) {
User user = userBean.getUser();
if (user == null) {
((HttpServletResponse) response).sendRedirect("/login.xhtml");
} else
chain.doFilter(request, response);
} else
((HttpServletResponse) response).sendRedirect("/login.xhtml");
}
public void init(FilterConfig fc) {
}
public void destroy() {
}
}
I have no idea where this exception comes from,please shade some light on this issue. Thanks!
EDIT1: adding UserBean.java code :
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean
#SessionScoped
class UserBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
private User user;
}
BTW, SEVERE: Context [/projectName] startup failed due to previous errors
Change :
class LoginFilter implements Filter {
to
public class LoginFilter implements Filter {
For me the issue was that of the 'constructor' not being public.

Resources