Bug 921004

Summary: CDI injection into JAX-RS service does not work when hot-deployed.
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Pavel Macik <pmacik>
Component: CDI/Weld, RESTEasyAssignee: Stuart Douglas <sdouglas>
Status: CLOSED WONTFIX QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.0.1   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-16 05:14:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pavel Macik 2013-03-13 09:59:52 UTC
To reproduce the issue use following steps:
1.) Get the reproducer from git://github.com/pmacik/jaxrs-cdi-reproducer.git
2.) Get out-of-the-box JBoss AS7 (7.1.1.Final)
3.) Start the AS up
4.) Build the reproducer WAR using "mvn package"
5.) Deploy the reproducer WAR - copy the WAR into (JBOSS_HOME)/standalone/deployments directory
6.) Go to http://localhost:8080/JAXRS-CDI-reproducer/rest/bean/getAll -> NPE is thrown (bean was not injected)
7.) Go to http://localhost:8080/JAXRS-CDI-reproducer/BeanServlet -> the bean is properly injected


There is a workaround - deploy WAR before AS start-up.

Comment 1 Stuart Douglas 2013-03-16 04:26:38 UTC
Hot deployment does not actually have anything to do with it. It appears to be a race condition in deployment, sometimes it works and sometimes it does not.

Comment 2 Stuart Douglas 2013-03-16 05:13:23 UTC
This is actually caused by user error. In the reproducer the class should only be returned by Application.getClasses(), not Application.getSingletons(). 

Ideally RESTeasy would detect this case, and would throw an error. I have filed an issue against RESTeasy to detect this problem.

Comment 3 JBoss JIRA Server 2013-03-16 05:14:57 UTC
Stuart Douglas <stuart.w.douglas> updated the status of jira AS7-6723 to Resolved

Comment 4 JBoss JIRA Server 2016-05-11 21:08:37 UTC
Ron Sigal <ron.sigal> updated the status of jira RESTEASY-841 to Resolved

Comment 5 JBoss JIRA Server 2016-08-02 16:15:30 UTC
Alessio Soldano <asoldano> updated the status of jira RESTEASY-841 to Closed