Upon deploying an application to Payara 4.1.2.174, Weld produces a warning log entry saying that
@Initialized and @Destroyed events for ApplicationScoped may be fired twice
No warning should occur, as is the case with Payara 4.1.2.173 and before. If the potential consequence described in the log message can actually occur, this could for example lead to problems with the eager initialization pattern based on @Observes @Initialized(ApplicationScoped.class) (cf. https://stackoverflow.com/questions/3600534/how-do-i-force-an-application-scoped-bean-to-instantiate-at-application-startup/32520226#32520226).
The exact log message is:
WARN: WELD-000718: No EEModuleDescriptor defined for bean archive with ID: AsyncJaxRsTest.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
Deploy any module with a beans.xml.
Minimal example: deploy a module with only a beans.xml like this (no further source code required):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
It looks like "EE Modules" is a new feature in Weld, as described here: http://docs.jboss.org/weld/reference/latest/en-US/html/ri-spi.html#_ee_modules.
I'm not sure, but the wording "... the integrator should create an instance of the EEModuleDescriptor ..." sounds to me like the container is meant, i.e. Payara in this case...? I tried to get rid of this by following the instructions at http://docs.jboss.org/weld/reference/latest/en-US/html/ri-spi.html#_registering_services, i.e. creating a file META-INF/services/org.jboss.weld.bootstrap.api.Service with a single line containing the FQN of a class implementing EEModuleDescriptor like this:
@Override
public void cleanup()
{}
@Override
public String getId()
{
return "ModuleId";
}
@Override
public ModuleType getType()
{
return ModuleType.WEB;
}
This indeed makes the log entry go away. So it seems to me that, according to the Weld documentation, Payara should be generating such implementations dynamically (with an ID based on the module name).
When I searched for the log message, I found at least one other recent post that exhibits the same problem (https://stackoverflow.com/questions/48074073/how-to-use-omnifaces-eager-annotation-with-primefaces#comment83254600_48074073).
This is internal issue PAYARA-2310
Not a problem in Payara 5
I saw this message with 181 build, too. How can this be fixed?
The fix needs to be backported to 4.x
Thanks once again!
Most helpful comment
The fix needs to be backported to 4.x