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 230015 - do not generate beans.xml at all in CDI 1.1 case
Summary: do not generate beans.xml at all in CDI 1.1 case
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: Martin Janicek
URL:
Keywords:
: 234105 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-05-21 03:25 UTC by David Konecny
Modified: 2013-08-08 07:14 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
confusing application (30.93 KB, application/zip)
2013-07-04 12:53 UTC, Sergey Petrov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2013-05-21 03:25:34 UTC
It is not needed.
Comment 1 Petr Jiricka 2013-05-21 07:31:40 UTC
So this includes initial project creation, which now by default contains beans.xml, right?
Comment 2 Martin Janicek 2013-05-21 07:41:11 UTC
What "CDI 1.1 case" means? In Maven we are creating beans.xml by default only when the Java EE 7 archetype is used.
Comment 3 Martin Fousek 2013-05-21 07:44:08 UTC
I'm not sure if I understand that correctly but it seems to me that the beans.xml can be still useful in case that developers doesn't use any scope defining annotation which could be common up to now.

If we wouldn't create beans.xml, we should probably create new CDI hint that the @Named beans without scope definition will not be usable as CDI beans (will not be in bean archive) in case of missing beans.xml file.

And also probably create issue for Named bean wizard creation which should offer scope definitions and probably validation for chosen scope in case of missing beans.xml too.

Please David correct me if I'm wrong, thanks a lot.
Comment 4 David Konecny 2013-05-22 00:31:04 UTC
(In reply to comment #2)
> What "CDI 1.1 case" means? In Maven we are creating beans.xml by default only
> when the Java EE 7 archetype is used.

Yes, EE7 == CDI 1.1.

(In reply to comment #3)
> I'm not sure if I understand that correctly but it seems to me that the
> beans.xml can be still useful in case that developers doesn't use any scope
> defining annotation which could be common up to now.

Note MartinF that beans.xml generated for version 1.1 has by default  bean-discovery-mode="annotated" which makes bean archive behave as implicit one - that is only beans with 'defining annotations' are provided. That means that having beans.xml or not will have the same effect.

> If we wouldn't create beans.xml, we should probably create new CDI hint that
> the @Named beans without scope definition will not be usable as CDI beans (will
> not be in bean archive) in case of missing beans.xml file.

This hint should be created in any case even for archives with beans.xml with bean-discovery-mode="annotated".

> And also probably create issue for Named bean wizard creation which should
> offer scope definitions and probably validation for chosen scope in case of
> missing beans.xml too.

Either that or wizard could automatically add @Dependent annotation - scope will be inherited.
Comment 5 Martin Fousek 2013-05-22 04:38:06 UTC
> Note MartinF that beans.xml generated for version 1.1 has by default 
> bean-discovery-mode="annotated" which makes bean archive behave as implicit one
> - that is only beans with 'defining annotations' are provided. That means that
> having beans.xml or not will have the same effect.

I know, sorry I was improving my CDI knowledges during whole day. ;)

In any case, I agree that the file is not necessary any more in ee7 projects. I wanted to say that together with this issue CDI should come up with some fixes/enhancements to provide better CDI1.1 support related especially to 'implicit bean archives' change.
Comment 6 David Konecny 2013-06-24 20:43:54 UTC
Let's try to fix this for Beta.
Comment 7 Sergey Petrov 2013-06-25 14:07:01 UTC
http://hg.netbeans.org/web-main/rev/1d160860c2ba for ant
Comment 8 David Konecny 2013-06-25 21:47:59 UTC
Re. #1d160860c2ba - feel free to rename "isCDIEnabled" Sergey. It could even be  named "isGenerateBeansXML" and "setGenerateBeansXML".
Comment 9 Quality Engineering 2013-06-26 02:42:54 UTC
Integrated into 'main-golden', will be available in build *201306252301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/1d160860c2ba
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #230015 do not ctreate in ant/ee7
Comment 10 Sergey Petrov 2013-06-26 12:18:14 UTC
for maven, from command line:
mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee7 -DarchetypeVersion=1.0 -DarchetypeRepository=https://nexus.codehaus.org/content/repositories/snapshots/ -DgroupId=org.glassfish -DartifactId=javaee7-sample -Dversion=1.0 -Dpackage=org.glassfish.javaee7-sample -Darchetype.interactive=false --batch-mode --update-snapshots archetype:generate

create an application with beans.xml

David, is it an issue in maven ee7 archetype or somewhere else? If yes, where to file this issue?
Comment 11 Sergey Petrov 2013-06-26 12:30:17 UTC
and ejb-javaee7:1.0 need to be reviewed too.
Comment 12 Martin Janicek 2013-06-26 12:49:13 UTC
(In reply to comment #10)
> is it an issue in maven ee7 archetype or somewhere else?

Yes, it is. The original decision was to create beans.xml by default. I have to update archetype and create newer version to get it fixed.

> If yes, where to file this issue?

This is my job, I guess.. I'll take care of it
Comment 13 Sergey Petrov 2013-06-26 13:55:02 UTC
(In reply to comment #12)
> 
> This is my job, I guess.. I'll take care of it

can it be done for 7.4 beta.
it may have sense to separate maven from ant otherwise and transplant ant fixes at least.
Comment 14 Petr Jiricka 2013-06-26 13:57:37 UTC
No need to transplant Ant fixes for beta - the beta branch was thrown away and will be branched again from trunk. So what is now in trunk will be a part of beta.
Comment 15 Sergey Petrov 2013-07-04 12:53:57 UTC
Created attachment 136715 [details]
confusing application

I have an application and it fail to work without beans.xml and works fine with beans.xml with bean-discovery-mode="annotated", from previous discussion I see it as wrong behavior and the application should work the same in both use-cases, any ideas? I'm still evaluating cdi technology and may miss something.
Comment 16 David Konecny 2013-07-05 01:11:53 UTC
The application you attached does not work even if beans.xml is present and bean-discovery-mode="annotated". But changing it to bean-discovery-mode="all" makes it deployable and works OK. The problem is that injection point in ItemProcessor cannot find bean to inject because DefaultItemDao does not have any scope defining annotations. Annotate DefaultItemDao with @Dependent and everything will work even without beans.xml.
Comment 17 Sergey Petrov 2013-07-05 04:16:31 UTC
ok, I need to reverify what is the difference in gf installations/nb 7.3.1 vs 7.4, I was able to deploy at the office but can't deploy at home. Also if I create at home beans.xml it is created with 1.0 version in 7.3.1. At the office the only requirement to fix the application was to add beans.xml with 1.1 version with annotated option.
Comment 18 Sergey Petrov 2013-07-08 11:43:52 UTC
sorry for mixing up, my gf installation was about 1 month before gf4 release.
Comment 19 Martin Janicek 2013-07-17 10:30:26 UTC
Sergey, just to be sure. Only thing I need to do is to not generate beans.xml at all, right?
Comment 20 Sergey Petrov 2013-07-17 10:33:35 UTC
yes
Comment 21 Martin Janicek 2013-07-18 06:29:20 UTC
Fixed for Maven in: web-main #cc494350006c
Thanks for quick response Sergey! Closing the issue.
Comment 22 Quality Engineering 2013-07-19 02:33:03 UTC
Integrated into 'main-silver', will be available in build *201307182300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/cc494350006c
User: Martin Janicek <mjanicek@netbeans.org>
Log: Using updated Java EE 7 archetypes in version 1.1 - fixing issues: #230015, #231878 and #231479
Comment 23 Martin Janicek 2013-08-08 07:14:11 UTC
*** Bug 234105 has been marked as a duplicate of this bug. ***