リストを作成するためにEJBを使用するバッチレットに問題があります。 JSR-352バッチレットejb nullPointerException
私はプロジェクトを開始
、GlassFishのフラグエラー:@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.
}
}
私が実行しようとした:
Caught exception executing step: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: java.lang.NullPointerException
Glassfishのバージョンは、私のbatchletのコードは4.1.1
ですアプリケーションをデバッグしてnodeEJBを検査すると、常にnull値が保持されます。
私のバッチレットに私のEJBをどう使うことができますか?あなたの助けのための
おかげ
Ersch
EDIT:
NodeFacadeコード:
@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"/>
getNetworkStatusB atch.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);
}
}
NodeFacade.javaの内容を投稿してください。 – D00de
こんにちは、私は投稿を追加しました。 – Ersch
注入され、nullに評価されません。あなたのプロジェクトをgithubに投稿できますか?どのGlassfishバージョンを使用していますか? – D00de