简体   繁体   中英

JBoss EAP 6.2 CDI beans.xml

I've got a simple question about getting cdi running in JBoss EAP 6.2 Pojos that are injected with @inject (from javax.annotation) are always null.

The only thing I can find is that I need to add a beans.xml. I added that in de META-INF folder of my jar (inside an ear). Still I don't see any cdi/weld logging, so I'm wondering if weld is enabled at all.

We are using a custom standalone.xml and jboss-deployment-structure.xml I tried adding the weld module in those files, but the result is the same: no weld logging and no injected beans.

I created a sample project with an ejb that is loaded @Startup and tries to inject a pojo. When I deploy this project in the same container, the bean initialized, but the injected field is null. 在此处输入图片说明

I was missing to following in standalone.xml

<extensions>
    <extension module="org.jboss.as.weld"/>
</extensions>

<subsystem xmlns="urn:jboss:domain:weld:1.0"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM