What I am trying to do is have a user click a button on a JSF webpage. Clicking the button on the webpage will trigger a method in a managed bean. This manage Bean should then call a EJB which runs asynchronously (method is RunManager getRoutesOnRun(int runID)., The issue I am getting is that after I have annotated the various parts of code I am getting an error message when the user clicks on the button within the webpage - "runRoutesBean" does not exist.
The webpage command button
The code for the command button is
<h:commandButton value="Run!" action="#{runRoutesBean.setrunAlgorithm(runRoutesBean)}">
</h:commandButton>
Managed Bean
package Beans;
import AlgorithmAndLogic.Route;
import AlgorithmAndLogic.RunManager;
import DataBaseConnections.RunRouteDataBaseConnectivity;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties;
import javax.ejb.Asynchronous;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.ejb.SessionBean;
import javax.ejb.Stateless;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@Named(value = "runRoutesBean")
@RequestScoped
public class RunRoutesBean {
@EJB
private RunManager runManager;
private int runRoutesID;
private int runID;
private int routeID;
private String runDescription;
private String routeDescription;
private int locationsOnRoute;
private double originalDistance;
private double crossOverRate;
private double mutationRate;
private String survivalStrategy;
private int terminationCycle;
public void setrunAlgorithm(RunRoutesBean newRunRoutesObj) throws SQLException, IOException, NamingException {
runID = newRunRoutesObj.runID; //gets the runID from the RunRouteObj
runManager.getRoutesOnRun(runID);
}
}
The EJB
package AlgorithmAndLogic;
import javax.ejb.*;
@Stateless public class RunManager{
// Holds our routes
private ArrayList run = new ArrayList<>();
@Asynchronous
public void getRoutesOnRun(int runID) throws SQLException, IOException{
Does some work
}
The Stack trace (partial)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'runRoutesBean' resolved to null
at com.sun.el.parser.AstValue.getTarget(AstValue.java:174)
at com.sun.el.parser.AstValue.getType(AstValue.java:86)
at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
at org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98