This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 226552

Summary: Unsatisfied dependency: no bean matches the injection point - when it's provided by server
Product: javaee Reporter: Martin Fousek <marfous>
Component: CDIAssignee: Sergey Petrov <sj-nb>
Status: VERIFIED FIXED    
Severity: normal CC: chaase3, kganfield, pjiricka
Priority: P3    
Version: 7.3.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: testing bean

Description Martin Fousek 2013-02-22 17:25:41 UTC
Created attachment 131750 [details]
testing bean

Product Version: NetBeans IDE Dev (Build 20130222-4978d080f8dc)
Java: 1.7.0_06; Java HotSpot(TM) 64-Bit Server VM 23.2-b09
Runtime: Java(TM) SE Runtime Environment 1.7.0_06-b24

In the ee7 project will be generated source for sending MDB which is marked with warning 'Unsatisfied dependency: no bean matches the injection point'. It's there probably since the JMXContext is not provided by the project but from the application server. I don't know whether we have a way how to tell the CDI support which injection points will be injected by the server and that it's ok. I'm attaching sample source of the MDB - which will be standard generated one in ee7 projects.
Comment 1 Sergey Petrov 2013-07-09 16:33:46 UTC
Is providing by server defined by @JMSConnectionFactory?
If yes, cdi may need just to skip any injection points with additional JMSConnectionFactory annotation.
Comment 2 Martin Fousek 2013-07-10 05:21:14 UTC
(In reply to comment #1)
> Is providing by server defined by @JMSConnectionFactory?
> If yes, cdi may need just to skip any injection points with additional
> JMSConnectionFactory annotation.

I'm afraid that the @JMSConnectionFactory is only optional information since the Java EE 7 specification guarantees default connection factory provided by the Java EE 7 compliant server. It means that probably all injections of JMSContext should be probably excluded from the hints check.

See https://jms-spec.java.net/2.0/apidocs/javax/jms/JMSContext.html:
"Applications running in the Java EE web and EJB containers may alternatively inject a JMSContext into their application using the @Inject annotation. A JMSContext that is created in this way is described as being container-managed. A container-managed JMSContext will be closed automatically by the container."
Comment 3 Sergey Petrov 2013-07-10 06:52:56 UTC
ok, in this case either there should be no warning for javax.jms.JMSContext or for javax.jms.*. Especially if default implementation should be always provided by ee7 server. If there is any case when it may fail it's possible to introduce separate info-warning.
Comment 4 oswald 2013-11-10 18:52:30 UTC
The bug is even wider than that with the above mentioned JMSContext. Netbeans is saying exactly the same when encountering injections which are explicitly stated as predefined beans in Java EE 7: http://docs.oracle.com/javaee/7/tutorial/doc/cdi-adv004.htm#CJGHGDBA

In my case it's HttpSession.
Comment 5 Martin Fousek 2013-11-11 06:42:43 UTC
Good point Oswald. All these classes should be excluded from the validation as well (at least in case of Java EE 7).
Comment 6 Sergey Petrov 2013-12-10 16:25:08 UTC
http://hg.netbeans.org/web-main/rev/89d0e9a4381d
Comment 7 Quality Engineering 2013-12-11 02:59:24 UTC
Integrated into 'main-silver', will be available in build *201312110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/89d0e9a4381d
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #226552 handle context and servlets predefined injections, refactor #234279
Comment 8 Martin Fousek 2013-12-11 09:00:03 UTC
Thanks, works well.