[GLASSFISH-20639] Default scoped bean cannot be injected Created: 17/Jun/13  Updated: 07/Jul/13  Resolved: 03/Jul/13

Status: Resolved
Project: glassfish
Component/s: cdi
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: b_faissal Assignee: jjsnyder83
Resolution: Works as designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: adoptajsr


I've just created a simple project with a servlet (MyServlet) and a bean ( MyService), when I try to inject the bean into the servlet I got an exception teling me :

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyService] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject com.mycompany.mavenjavaee7.MyServlet.myService]

This works fine on previous promoted build ( eg b_77 )

Attached is a maven project to test this issue

Comment by jjsnyder83 [ 03/Jul/13 ]

Please attach the application and source code.

Comment by b_faissal [ 03/Jul/13 ]

I'm not allowed to attach file here,

I've put the projet on drive : https://docs.google.com/file/d/0B-VFW86XwkF3LVhRUXhxODdzY3M/edit?usp=sharing

ps : it's a simple project created by Netbeans 3.1

Comment by jjsnyder83 [ 03/Jul/13 ]

In beans.xml the bean-discovery-mode is set to "annotated". This means that only beans identified by a bean-defining annotation will be managed by CDI. There are 2 ways to fix this in the application:
1) change "annoated" to "all"
2) Add @Dependent to the MyService class.

Comment by b_faissal [ 07/Jul/13 ]

Thank you,

Didn't notice it as I'was testing netbeans support of JAVA EE 7 , and bean.xml was generated by netbeans.

I'll fill a bug on netbeans side.

Generated at Sun Sep 25 07:39:33 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.