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 230014 - CDI model needs to be updated to reflect CDI 1.1 changes
Summary: CDI model needs to be updated to reflect CDI 1.1 changes
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: CDI (show other bugs)
Version: 7.3.1
Hardware: All All
: P2 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-21 03:23 UTC by David Konecny
Modified: 2013-08-06 09:26 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
prototype for BeanArchiveType detection (17.87 KB, patch)
2013-05-22 08:40 UTC, Martin Fousek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2013-05-21 03:23:20 UTC
CDI model needs to be updated to take into account following changes:

* 'implicit bean archive' - all beans with 'defining annotation' are provided even without presence of beans.xml

* beans.xml with bean-discovery-mode="annotated" (that is default beans.xml generated since NB 7.3.1) - only beans with "defining annotation' are provided - all other beans should be ignored unless bean-discovery-mode="all"

Without this update the internal model of NB CDI support will be broken in some cases and functionality based on top of that module will not work correctly.
Comment 1 David Konecny 2013-05-21 03:29:05 UTC
I'm not sure we can fix this for 7.3.1. Somebody will have to learn how the CDI internal model is built and update it. I'm going to work on some REST issues in next few days.
Comment 2 Petr Jiricka 2013-05-21 08:38:42 UTC
David/Martin, can you please describe in terms of concrete reproducible steps what cases/functionality will not work correctly? Based on that we should decide how serious these are.
Comment 3 Martin Fousek 2013-05-21 15:20:27 UTC
My understanding and summary is following:
- this issue applies only to JavaEE7 projects which use CDI1.1 and beans.xml in version 1.1
- Ant based projects generates beans.xml in version 1.0 (issue #230050 confirms this) which is beans.xml without any version tag so 'explicit bean archive'
- Maven base projects generates beans.xml in version 1.1 without version definition (but the version has implicit value 1.1 by the schema definition) so 'implicit bean archive'

I tried JSF pages from Entities which work well for both cases since all Named beans contains also scope annotations, so works for explicit and also implicit bean archives.

Projects can behave pretty differently now and we should stay on one version of beans.xml for new ee7 projects - and hard to say which kind of it. :/ I think that with the current CDI code base we are closer to explicit behaviour so they should define bean-discovery-mode="all" or use beans.xml in version 1.0? But on the other hand it doesn't look as standard in ee7. :/

Then, I think that most issue will be directly CDI related - you will use something in beans.xml (like bean-discovery-mode="none" or bean-discovery-mode="annotated") or you will not use it at all. Our support doesn't differ between 'explicit bean archive' and 'implicit bean archive' so it can offer in CC or show hint somewhere where it's not suitable and eventually it will not show ie. warning/info in cases of non-scoped beans with 'implicit bean archive' CDI status.

Also our model doesn't support @Vetoed and probably more 1.1 related improvements.

I can take a look into the CDI spec. more deeply and design changes or rather prototype changes which can be necessary to accept the new CDI spec. but I would be wary by placing big pieces of code into 731 since we went thru both NetCAT testings which could catch major of regressions. In any case we can wait for the changeset if I will be able to do it quickly enough. :)
Comment 4 Martin Fousek 2013-05-21 15:59:13 UTC
Sorry, my fault around the issue #230050, it works in the same way in Ant and Maven new project wizard and it generates beans.xml in version 1.1 with 'implicit bean archives'. So paragraph Nr.3 doens't have sense. It means at least that new ee7 projects behave in the same way which is great.
Comment 5 David Konecny 2013-05-21 22:47:23 UTC
(In reply to comment #3)
> - this issue applies only to JavaEE7 projects which use CDI1.1 and beans.xml
> in version 1.1

Yes.

> - Ant based projects generates beans.xml in version 1.0 

This will be fixed for 7.4 - for EE7 we should always generate beans.xml with version 1.1 and bean-discovery-mode="annotated" - the documentation in Beans 1.1 XML Schema suggests to use "annotated" as default choice. That choice means that only beans with 'defining annotations' are visible.

> Our support
> doesn't differ between 'explicit bean archive' and 'implicit bean archive' so
> it can offer in CC or show hint somewhere where it's not suitable and
> eventually it will not show ie. warning/info in cases of non-scoped beans with
> 'implicit bean archive' CDI status.

Yes. I can provide some concrete test project if needed but first I would have to look into it in more detail. The errors which this issue can cause will not be severe - false editor hint/warning, wrong item shown in inspector.

We should not try to fix this for NB 7.3.1.
Comment 6 Martin Fousek 2013-05-22 04:24:26 UTC
(In reply to comment #5)
> > - Ant based projects generates beans.xml in version 1.0 
> 
> This will be fixed for 7.4 - for EE7 we should always generate beans.xml with
> version 1.1 and bean-discovery-mode="annotated" - the documentation in Beans
> 1.1 XML Schema suggests to use "annotated" as default choice. That choice means
> that only beans with 'defining annotations' are visible.

Sorry, that was still my outdated comment since I found out that the beans.xml of new Ant Web project is created correctly at EOB. 

> We should not try to fix this for NB 7.3.1.

I think that we found agreement here, thanks David.
Comment 7 Martin Fousek 2013-05-22 08:40:32 UTC
Created attachment 134717 [details]
prototype for BeanArchiveType detection

I prototyped initial patch for BeanArchiveType detection (the information is not cached yet and also I didn't try it in runtime). But I found out that to leverage this information in model requires knowledge of CDI which I don't have now.

Since we agreed on nb74, I'm at least attaching the initial patch which could use somebody who will study cdi and take care about it into 74.
Comment 8 Petr Jiricka 2013-05-22 09:33:58 UTC
Thanks David and Martin. Adding 731-not-a-stopper. Cc'ing Jirka so he is aware we are waiving this for 7.3.1.
Comment 9 Sergey Petrov 2013-07-12 09:56:36 UTC
Patch looks good to me, may be except getting beans archive type caching, but it depends on how often it's required to get this information. On other hand caching shouldn't be hard to add as I see.

 I'm still looking into nb cdi module and specifications, unfortunately I miss beta target for this task.
Comment 10 Sergey Petrov 2013-07-12 12:34:15 UTC
Some design decision: regarding issue subj. I don't like to update model and for example change it each time user add/delete/change beans.xml, I would like to change only archive type here and use it in number of filters, I'e. main model will remain equal to "all" model (but may be extended to some new elements).
Internal logic already have some filters where all possible subtypes are filtered by annotations or other constraints.
Comment 11 David Konecny 2013-07-15 02:25:12 UTC
Re. "unfortunately I miss beta target for this task" - that's OK. This is going to be non-trivial task I afraid. So take your time. On the other hand try to finish it rather earlier than late so that it can be re-tested in time. We will not want to do many model changes close to code freeze.

Re. "design decision" - I think it sounds like a good approach to try to keep model complete and only filter it. Hopefully it will as easy to implement as it sounds! :-)
Comment 12 Sergey Petrov 2013-07-15 15:18:17 UTC
for testing purpose, I'm going to push from time to time some "milestones" instead of complete solution at once.
http://hg.netbeans.org/web-main/rev/113956002de7
Comment 13 Quality Engineering 2013-07-16 02:38:18 UTC
Integrated into 'main-silver', will be available in build *201307152300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/113956002de7
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #230014 intiial commit, recognize archive type, filter out types in navigation, recognize and use new ns if necessary.  work in progress.
Comment 14 Sergey Petrov 2013-07-26 17:12:33 UTC
now filter should work as expected, changes from annotated to all and back should affect hints(unsatisfied dependency) and injection navigation.
Comment 15 Sergey Petrov 2013-08-06 09:26:04 UTC
I suppose it can be closed as fixed, if there will be found some major issues this one can be reopened, but for minor ones it's much better to open new issues rather then keep this one forever open.