I have a page that displays several select boxes whose content was acquired from an oracle datasource that was injected using @Resource(mappedName = "java:/myDatasource").
The submit button calls a different action class that is to instantiate the correct DAO, get the data and forward to the appropriate .xhtml. The submit button fragment is shown here.
<h:commandButton type="submit" action="#{reportList.submit}"/>
@Name("reportList")
public class ReportListAction implements ReportListLocal {
@Resource(mappedName = "java:/myDatasource")
private DataSource ds;
private Connection conn = null;
public String submit() {
// using ds here results in a nullpointer. Why?
conn = ds.getConnection();
}
// other setters to receive the form element values
}
Your class does not have an @Stateless or @Stateful annotation, so it is not a session bean.