[
https://issues.jboss.org/browse/WFLY-10029?page=com.atlassian.jira.plugin...
]
Ralph Soika commented on WFLY-10029:
------------------------------------
This is an example plugin:
https://github.com/imixs/imixs-jsf-example/blob/master/src/main/java/org/...
But you can turn around the szenario to simplify it. Just try to inject the
'SomeClass' into a EJB.
{code:java}
@Stateless
@LocalBean
public class SomeService {
@inject
SomeClass someClass; // will be null on Glassfish when beans.xml uses
bean-discovery-mode=annotated
...
}
{code}
This will work in Wildfly out of the box independent if the beans.xml attribute
bean-discovery-mode is set to "_annotated_" or "_all_". So there is no
problem for wildfly. It works and this is great on the first look :-).
But if you use "_annotated_", which is the recommended setting, it does not
work in Glassfish/Payara. There it will be always null because "SomeClass" is
not recognized as a CDI bean.
To be clear: you can not reproduce an error in WIldfly. I only think it should not work in
WIldfly too. And maybe a warning in the log during the deployment would be sufficient.
Something like:
_.... Bean "SomeClass" has no scope annotation but will be treated as an CDI
bean. You should use bean-discovery-mode "all" instead of
"annotated"._
bean-discovery-mode="annotated" is not working like
described in the spec
-------------------------------------------------------------------------
Key: WFLY-10029
URL:
https://issues.jboss.org/browse/WFLY-10029
Project: WildFly
Issue Type: Bug
Components: CDI / Weld
Affects Versions: 10.1.0.Final
Reporter: Ralph Soika
Assignee: Martin Kouba
Priority: Minor
Labels: beans.xml
I think we have a problem in Wildfly 10 concerning scanning of CDI Beans. Take a look at
the following example:
{code:java}
@Stateless
@LocalBean
public class SomeService {
...
}
public class SomeClass {
@EJB
SomeService someService;
....
}
{code}
We have a stateless session ejb an a bean which is not annotated with a scope but is
injecting the service EJB. If you use a beans.xml with the tag:
{noformat}
bean-discovery-mode="annotated"
{noformat}
this works in wildfly 10 - the _someService_ is injected into the _someClass_ which is
treated as a CDI bean. But this is not a correct behavior as stated in the specification.
It says, that in this case only beans with a scope annotation should be treated as CDI
which is not the case for SomeClass. Normally, as a developer, you would not complain much
about this. So this is only a minor issue.
I recognized this after I tried to run my application on Glassfish/Payara4 which did no
longer work until I changed the beans.xml tag to:
{noformat}
bean-discovery-mode="all"
{noformat}
Now it works in both application servers. I think in wildfly we are misinterpreting the
attribute "bean-discovery-mode". I think this should be changed in the next
versions for EE8. I don't know if this behavior is a known issue and maybe it is still
under development.
I know also that with such a change some projects (also my own ones) will break. So maybe
a new configuration switch like "strict-cdi-scanning" is helpful. What do you
think?
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)