-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert #5157 #5457
Comments
@BalusC I do not think we should revert this. In his comment, Mark has a similar notion to what I arrived to in my original issue - the spec isn't explicit on what exactly are all the valid values for the bean class in case of synth. beans. The specification section on From the little that you can find, I'd point out the following javadocs.
So even producers do not return the class of the actual bean, but that of its declaring bean. Furthermore, looking at
This explicitly says that not setting the class results in extension class being used as a default and that such setting is valid. My PR changes weren't based solely on Weld behavior but on what I could find in the CDI specification to be a workable default for any implementation. Yes, both Weld and OWB use the As a side note, you could also draw quite a few similarities between declaring a producer and declaring a synth bean - in both cases you control/declare the creation login, bean types, qualifiers and so on. Neither producers nor synth. beans necessarily have a backing class behind them and it therefore seems logical to me that the |
I agree with Mark, most of the spec, including the Indeed it is only relevant for proxied classes - ignored in all other cases - where it must be used as a base proxy class to avoid a random algorithm based on So current API usage is likely the promise of issues and shouldn't be nor promoted but be considered as a bug and API misusage IMHO. |
@manovotn the definition of the producer method shows exactly what I claimed: It is the class of the bean type, except for producer methods where it is the bean class of the owner bean. The term "bean class" is mentioned 135 times in the CDI 2.0 spec. Almost all of those rather point to the interpretation that it represents the 'thing to be injected'. Note that the other quote from the API (default method) stems from a much later version of the spec and still does not say anything about what the beanClass actually should be. Just for understanding the Weld position: what does Weld do if Bean#getTypes() return a Set of 7 unrelated interfaces but no concrete class? Do you create different interface proxies for each injection point? And what is the benefit of having the Extension class returned in getBeanClass()? Where in the spec can I find that getBeanClass() is used for any visibility rules like it seems is - also not covered by the spec - assumed and even requested by Weld. |
@struberg weld does a subclass of the runtime instance and uses the parent class of getTypes() ( |
Much older being literally the first commit adding that API which can be seen here.
I guess we won't agree here because you can impose an equally valid assumption that synth. beans should be viewed as produced bean and the bean class should be that of declaring extension 🤷
My previous comment didn't mention anything about visibility rules; I intentionally used arguments and a default value defined by the specification. You could delve deeper into the WFLY related issues and PR to see what Weld does but that's not really relevant to the discussion here. But, speaking of visibility in the specification, I can add another slightly related quote. This one is from enabling alternatives per bean archive:
Based on this, the Nonetheless, the essence of this issue seems to be that the CDI specification is not really clear on valid values for I am sorry but with the above in mind, I don't think that claims such as the default value being a clear abuse of the specification hold any water. |
This is true and we all agreed it can be the extension class...when there is no runtime constraint after and there there is the issue since it needs a proxy so the doc is right and the bug report as well.
This is true but also means mojarra does not support CDI, it does support some Weld version so it is worth fixing.
As an implementation you know it and it would be insane if the extension can change its module definition so think it is a counter example.
What is obvious is that:
So whatever the details the revert makes sense if mojarra intend to not run only on weld. |
From my point of view, this is a CDI (spec) discussion atm between OWB and Weld both dealing with unclarity of the spec. From a user perspective, I would love to see a working Mojarra 4 given it just breaks OWB-based containers in a minor version update atm, i.e. it works with 4.0.0 and suddendly breaks. The original Wildfly issue was merly about a warning, right? So why breaking (non-Weld) users for the sake of resolving a warning based upon spec unclarity. Could we add a workaround in Mojarra like a (system) property to conditionally add the bean class, so it doesn't break users until the ambiquity ist actually resolved in the spec itself? |
That got introduced for 2.0, that was in 2016. This is literally 8 years after all that other work we've done and the original definition of the Bean class - including the discussed method! I really consider this LATE - and it kind of contradicts the previous work, which is against EE rules.
The linked ticket does!
Not quite sure what I should think about it, because your interpretation directly contradicts the 12.1 Bean archives definition: You claim
But the spec actually says:
Well, there IS an Extension in this JAR and there is NO beans.xml file. I do agree though, that the spec is not really clear. But otoh this is not a new discussion. We had this topic a few times in the EG, mostly in the context of visibility in the (now mostly obsolete) EAR deployment scenario: https://issues.redhat.com/browse/CDI-456 |
I am not sure this will be easily solvable on spec level given existing different approaches, interpretations and the above disagreements. |
Yes, the config option could e.g. also look up for some defaults depending on a Class.forName on key classes for OWB and Weld. |
That's doable. There's already something in place in Mojarra which detects if Weld is being used. We could reuse that. On the other hand, I'm wondering how this all works out when MyFaces is used. Do the Faces artifact producers work irrespective of the CDI impl being used? If so then we should probably take a look at its approach (cc: @arjantijms @tandraschko). |
Okay, for the record, this is what happens when I try to use
PR #5458 fixes that. |
Describe the bug
The issue #5157 changed a behaviour of Mojarra which was there since 10 years++ to a new version which breaks Apache OpenWebBeans and thus TomEE and other containers. Thus I'd kindly ask to revert to the old implementation.
See #5157
To Reproduce
See https://issues.apache.org/jira/browse/TOMEE-4355 on how to reproduce
Expected behavior
The CDI spec is not very outspoken about what a custom Bean should return for the
getBeanClass()
method. JBoss Weld and Apache OpenWebBeans use this information in subtly different ways. It also seems that something did change in behaviour in late 2022 in either Weld or Wildfly resulting in a visibility issue in Wildfly.In section "3.5. Bean constructors" the bean class is defined as the class the constructor is called for. If you e.g. have a custom
Bean<UIViewRoot>
then you want the constructor of UIViewRoot to be invoked, not the one of the Extension class registering that bean. In OWB this information is used to determine which proxy to be created for the contextual references of that bean. There are also other points in the spec which underline the OWB interpretation. Further note that it would be rather easy to store away the information about the CDI Extension which registers a bean with the variousaddBean()
methods as the CDI container always exactly knows which CDI Extension.3rd note: visibility in CDI was broken from the beginning for more complex cases like EAR deployments. This started with the famous CDI-18 and CDI-129 tickets and went on to this day. To fix this the spec would need to introduce a HierarchicBeanManager to correspond with the hierarchic ClassLoaders. I had a long discussion with Bill, Linda, Pete et al back then. Some findings made it to a blog post https://struberg.wordpress.com/2015/02/18/cdi-in-ears/
All this might not get enough traction as the importance of EARs mostly faded over the last decade.
Note that this is a well known topic in the CDI spec and has been discussed since the CDI-1.0 days with no decision in either direction.
The text was updated successfully, but these errors were encountered: