2
我使用JBoss 6.1決賽,並獲得我的Web應用程序後,以下錯誤消息運行一段時間(注意應用程序不會崩潰),其次是一個很長的堆棧跟蹤。我注意到這個問題只發生在有狀態會話bean被注入到其中的有狀態會話bean中。鈍化問題有狀態會話Bean
16:10:59769 ERROR [org.jboss.ejb3.cache.simple.SimpleStatefulCache.UutSerialNumberServiceBean]問題鈍化螺紋:javax.ejb.EJBException異常:無法鈍化;未能保存狀態
這裏是有問題的有狀態會話bean ...
package com.ray.TEI.ejb;
import java.io.Serializable;
import javax.ejb.Stateful;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import com.ray.TEI.model.TestProcedure;
import com.ray.TEI.model.Uut;
import com.ray.TEI.model.UutSerialNumber;
@Stateful
public class UutSerialNumberServiceBean implements Serializable {
private static final long serialVersionUID = 1L;
@PersistenceContext(unitName="jasoni", type=PersistenceContextType.EXTENDED)
protected EntityManager em;
@Inject private ExecProcedureServiceBean execProcedureServiceBean;
public boolean isDuplicateSerialNumber(Uut uut, String serialNumber) {
return ((Number)em.createNamedQuery("UutSerialNumber.getCountByUutIdAndSerialNumber")
.setParameter("uut", uut)
.setParameter("serialNumber", serialNumber)
.getSingleResult()).intValue() > 0;
}
public UutSerialNumber findUutSerialNumberByUutSerialNumberId(Integer uutSerialNumberId) {
return em.find(UutSerialNumber.class, uutSerialNumberId);
}
public UutSerialNumber editSerialNumber(Integer uutSerialNumberId, String serialNumber) {
UutSerialNumber uutSerialNumber = findUutSerialNumberByUutSerialNumberId(uutSerialNumberId);
uutSerialNumber.setSerialNumber(serialNumber);
return uutSerialNumber;
}
public UutSerialNumber createSerialNumber(Uut uut, String serialNumber) {
UutSerialNumber uutSerialNumber = new UutSerialNumber();
uutSerialNumber.setSerialNumber(serialNumber);
uutSerialNumber.setUut(uut);
uut.getSerialNumbers().add(uutSerialNumber);
em.persist(uutSerialNumber);
for (TestProcedure testProcedure : uut.getTestProcedures()) {
execProcedureServiceBean.createExecProcedure(uutSerialNumber, testProcedure);
}
return uutSerialNumber;
}
}
這裏是注入有狀態會話bean ...
package com.ray.TEI.ejb;
import java.io.Serializable;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import com.ray.TEI.model.ExecProcedure;
import com.ray.TEI.model.TestProcedure;
import com.ray.TEI.model.UutSerialNumber;
@Stateful
public class ExecProcedureServiceBean implements Serializable {
private static final long serialVersionUID = 1L;
@PersistenceContext(unitName="jasoni", type=PersistenceContextType.EXTENDED)
protected EntityManager em;
public ExecProcedure createExecProcedure(UutSerialNumber uutSerialNumber, TestProcedure testProcedure) {
ExecProcedure execProcedure = new ExecProcedure();
execProcedure.setUutSerialNumber(uutSerialNumber);
execProcedure.setTestProcedure(testProcedure);
execProcedure.setIterationCount(0);
em.persist(execProcedure);
return execProcedure;
}
}
人知道什麼不對的?
感謝, 傑森
感謝月我試圖使用 停用鈍化「@CacheConfig(MAXSIZE = 0,idleTimeoutSeconds = 0)」 ,現在有不同的問題。我將這些有狀態會話Bean注入到RequestScoped支持bean中以加載視圖數據,現在看起來即使注入了一個對象(例如,打印出的參考給出了 「端口[jboss的無接口視圖.j2ee:?罐子= TEI.war,名稱= ProgramServiceBean,服務= EJB3]和會話43g443f-ep5eqs-h1822776-1-h18233w9-DF」 - 但是,方法對象調用不工作任何想法 謝謝再次!傑森 – JasonI 2012-04-19 17:03:38
不同的問題 - >新的問題... :)這是更容易處理。 – 2012-04-19 20:56:29
好的,會發布它! – JasonI 2012-04-19 21:44:41