Получение исключения, когда я уже предоставил: @TransactionManagement (javax.ejb.TransactionManagementType.BEAN)
Пожалуйста, помогите исправить ошибку
insertNewRecord:java.lang.IllegalStateException: WFLYEJB0137: Only session and message-driven beans with bean-managed transaction demarcation are allowed to access UserTransaction
Планировщик:
@Startup
@Singleton
@AccessTimeout(value = 30, unit = TimeUnit.MINUTES)
public class SnowPollerNew {
@EJB
Scrutiny scrutiny;
@Schedule(hour = "*", minute = "*/1", persistent = false)
@TransactionTimeout(value = 2, unit = TimeUnit.HOURS)
public v
oid runTriggerFetchComputers() {
File trigFileSNOWApplications = new File(TRIGFILE_DIR + TRIGFILE_COMPUTERS);
if (trigFileSNOWApplications.exists()) {
JobStatus jobStatus = scrutiny.insertNewRecord(JobName.COMPUTERS);
Проверка:
@Stateless
public class Scrutiny {
private static final Logger log = Logger.getLogger(Scrutiny.class.getName());
public Scrutiny() {
System.out.println("Scrutiny");
}
@Inject
StatusDao statusDao;
public JobStatus insertNewRecord(JobName jName) {
JobStatus js = new JobStatus(jName, new Date());
js.setStatus(Status.PROGRESS);
try {
statusDao.begin();
statusDao.create(js);
statusDao.flush();
statusDao.commit();;
Вакансия:
@TransactionManagement(javax.ejb.TransactionManagementType.BEAN)
public class JobStatusDaoImpl extends GenericDaoImpl<JobStatus, String> implements StatusDao {
private static final Logger LOG = Logger.getLogger(JobStatusDaoImpl.class.getName());
@Override
public List<JobStatus> checkExistingRecordToday(JobName jName) {
LOG.info("checkExistingRecordToday:" + jName);
return em.createNamedQuery("findByJobNameAndCurrentDate", JobStatus.class)
.setParameter("jobName",jName).getResultList();
}
}
Generi c Дао Impl:
public abstract class GenericDaoImpl<T, PK> implements GenericDao<T, PK> {
private static final Logger LOG = Logger.getLogger(GenericDaoImpl.class.getName());
@PersistenceContext(unitName = "IntegratorMasterdataDS")
protected EntityManager em;
@Resource
private SessionContext sessionContext;
@Override
public void begin() throws IllegalStateException, NotSupportedException, SystemException {
sessionContext.getUserTransaction().begin();
}