[
https://issues.redhat.com/browse/WFLY-13498?page=com.atlassian.jira.plugi...
]
Matěj Novotný commented on WFLY-13498:
--------------------------------------
[~fearghalom] so I tried to reproduce this within Weld testsuite; [here is the
test|https://github.com/manovotn/core/blob/wfly13498/tests-arquillian/src...]
(I can provide info on how to execute that on wfly if needed).
As you can see from the {{@Deployment}} section of the test, it is a simple WAR with a
library and observers listening for {{(a)Initialized(ApplicationScoped.class)}} in both.
That should be exactly your case. What I am seeing is that both, WAR and its lib, *are
receiving event notifications* for {{Object}} and even for {{ServletContext}}.
I was apparently wrong there and in this scenario, even the lib will receive the
{{ServletContext}} event (with a context path from the web app itself).
Either way, I am unable to reproduce your scenario, can you put together some
reproducer/test where this would manifest?
@ApplicationScoped Bean Not Eagerly Instantiated on Wildfly 16
--------------------------------------------------------------
Key: WFLY-13498
URL:
https://issues.redhat.com/browse/WFLY-13498
Project: WildFly
Issue Type: Bug
Components: CDI / Weld
Affects Versions: 16.0.0.Final
Reporter: Fearghal O Maolcatha
Assignee: Matěj Novotný
Priority: Major
I have an @ApplicationScoped bean that I want to be instantiated on application startup
(see sample code below). I've registered for the servlet context initialization event
but the init method is never invoked. The FactoryLocator is contained in a jar within my
war's WEB-INF/lib directory. This same code was working on Wildfly 9 but no longer
works after upgrading to Wildfly 16.
{code:java}
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Observes;
import javax.servlet.ServletContext;
@ApplicationScoped
public class FactoryLocator {
public FactoryLocator() {
System.out.println("In the constructor.........................");
}
private void init(@Observes @Initialized(ApplicationScoped.class) ServletContext sc)
{
System.out.println("Invoking the event observer
method..................");
}
}
{code}
One workaround I discovered was to extract the contents of the jars in my war's
WEB-INF/lib/ directory to my war's WEB-INF/classes directory. When I did this my
FactorLocator bean was instantiated successfully. I'd prefer not to have to do this.
After debugging through the war's deployment, I noticed that the ServletContext is
initialized before all the beans in the war's lib directory are processed
(org.jboss.weld.bootstrap.BeanDeploymentModules:processBeanDeployments). The war's
module is not aware of all observers until all the beans are processed. However, the
ServletContextEvent is fired before all the observers are known.
Should this happen that ServletContext is created before all observers are known about?
I've debugged one of the Wildfly QuickStart applications and the ServletContext
isn't created until all bean deployments are processed and the code below is executed
successfully. Is the order in which this happens supposed to be guaranteed?
--
This message was sent by Atlassian Jira
(v7.13.8#713008)