I have a problem with a batchlet where I want to use an EJB to populate a list.
When I start the project, glassfish flags an error:
Caught exception executing step: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: java.lang.NullPointerException
Glassfish version is 4.1.1
The code of my batchlet is:
@Named
public class getPingStatusBatchlet extends AbstractBatchlet {
private static GetPingStatus gps = new GetPingStatus();
private List<Node> nodes = null;
@EJB
private NodeFacade nodeEJB;
@Override
public String process() throws NamingException {
nodes = nodeEJB.findAll();
for (Node item : nodes) {
gps.getPingStatus(item.getIpv4());
}
return "COMPLETED";
}
@Override
public void stop() throws Exception {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
I tried to run the application in debug and inspect the nodeEJB, it always keep the null value.
Have you an idea how I can use my EJB into my batchlet?
Thanks for your help
Ersch
EDIT:
the NodeFacade code:
@Stateless
public class NodeFacade extends AbstractFacade<Node> {
@PersistenceContext(unitName = "powwoPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public NodeFacade() {
super(Node.class);
}
}
beans.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"/>
getNetworkStatusBatch.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<job version="1.0" id="getNetworkStatusBatch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/jobXML_1_0.xsd" xmlns="http://xmlns.jcp.org/xml/ns/javaee" >
<step id="getNetworkStatusBatchlet">
<batchlet ref="com.powwo.app.batchlet.getPingStatusBatchlet"/>
</step>
</job>
myBackgroundJobManager.java:
@Singleton
@Startup
public class BackgroundJobManager {
@Schedule(minute = "*", hour = "*", second = "*/10", persistent = false)
public void myBackgroundJobManager() {
BatchRuntime.getJobOperator().start("getNetworkStatusBatch", null);
}
}