0

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. enter image description here

bergvandenp
  • 186
  • 1
  • 1
  • 8
  • Do you have some examples how you defined your classes and what error you get? – Albert Bos Sep 13 '16 at 09:39
  • I am already getting shivers when I see the word "EAR". You need to specify the structure of your deployment -> per JEE spec, there have to be different class loaders used for different EAR parts and visibility is limited (for instance EJB cannot see stuff located in WAR, but vice versa it works). This oftentimes leads to confusion and CDI not working as expected. Please add more details covering the deployments structure and a sample of code. As for `beans.xml` - you should have it there to enable the detection of beans. – Siliarus Sep 13 '16 at 10:43
  • @Siliarus The project from the screenshot is deployed as an exploded ear with a single jar. The EJB and the pojo are in the same jar. There's also a beans.xml provided. I'll try to create a single ejb jar with the same sources. – bergvandenp Sep 13 '16 at 10:58
  • @Siliarus I also created a single jar module (with beans.xml), but still got the same Null result, so it's not the ear structure that is the cause of this problem. – bergvandenp Sep 13 '16 at 11:14
  • OK! I just figured out that I messed someting up in standalone.xml. I don't know what yet, but overwriting it with the original got things working. – bergvandenp Sep 13 '16 at 11:20

1 Answers1

0

I was missing to following in standalone.xml

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

<subsystem xmlns="urn:jboss:domain:weld:1.0"/>
bergvandenp
  • 186
  • 1
  • 1
  • 8