data class ExeEvent(val id: Long)
@Stateless
open class ExeManagerBean : IExeManagerBean {
@Inject
open val events: Event<ExeEvent>? = null
override fun listenTo(@Observes(during = TransactionPhase.AFTER_SUCCESS) exeEvent: ExeEvent) {
try {
//doWork
} catch (ex: Exception) {
logger.error("Fail. ex:$ex")
}
}
在部署应用上:
16:38:56,060 ERROR [org.jboss.msc.service.fail](MSC服务主题1-4)MSC000001:无法启动服务jboss.deployment.unit。“pay.ear”.WeldStartService:org。服务jboss.deployment.unit中的jboss.msc.service.StartException。“bisys-pay-ear-worker.ear”.WeldStartService:无法启动服务 at org.jboss.msc.service.ServiceControllerImpl $ StartTask.run(ServiceControllerImpl.java:1904) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 引起:org.jboss.weld.exceptions.DefinitionException:WELD-000810:无法在最终字段上放置限定符:[EnhancedAnnotatedFieldImpl] @Inject private final ExeManagerBean.exeEvent
答案 0 :(得分:0)
由于events
关键字并且已设置为val
,您已将变量null
定义为最终版。
将val
更改为&#39; var&#39;:
@注入 open var events:事件? = null
使用延迟初始化,events
将是非可空类型:
@注入 open lateinit var events:Event