[WFLY-9443] Random deploy error with @Startup @Singleton EJB Created: 13/Oct/17 Updated: 17/Oct/17 Resolved: 17/Oct/17
|Component/s:||CDI / Weld, Class Loading, EJB|
|Reporter:||Juan Martin Runge||Assignee:||Martin Kouba|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
Wildfly 11.0CR1 + Vaadin 8.1.4
|Attachments:||error.log success.log wftest-ear-0.1.0.ear.tar.gz wftest.tar.gz|
|Steps to Reproduce:||
|Release Notes Text:||Packaging error.|
Simple EAR project with an EJB Module and a WAR Module. War uses Vaadin (think is not relevant but mention it anyway). On the EJB Module I have a @Singleton @Startup bean which has injected a@LocalBean @Stateless bean via @Inject annotation (tested with @EJB annotation with same results). The UI on the WAR side also calls this @LocalBean @Stateless bean. Randomly, when I deploy, redeploy or restart the server, the EAR refuses to deploy do java.lang.IllegalStateException because it cannot inject the @Stateless bean inside the @Startup bean.
Attached sample app, project, log with error and log with success.
If you check the success log, you will see the @Startup @Singleton bean gets instanciated twice.. Quite strange.
Also, this didnt happened with Wildfly 9 (same app deployed perfectly)
|Comment by Martin Kouba [ 16/Oct/17 ]|
Hi Juan, I think this is a packaging/class loading problem. wftest-ejb.jar is a top-level EJB jar but can be also found in wftest-vaadin.war/WEB-INF/lib. By default, the classes in war can access the classes belonging to ejb jars (see also EAR Class Loading) and so when performing injection on ar.com.zir.wftest.ejb.config.InitialConfig the container does not know which ar.com.zir.wftest.ejb.services.MovimientoService should be used.
I'm not sure about EJB but in CDI this is non-portable and often problematic: "If a bean class is deployed in two different bean archives, non-portable behavior results. Portable applications must deploy each bean class in no more than one bean archive." (see also 12.1. Bean archives)
So I think you should either try to change the scope of wftest-ejb dependency in war pom.xml to provided or change the <ear-subdeployments-isolated> value to true.
|Comment by Juan Martin Runge [ 17/Oct/17 ]|
Hi Martin, you were completely right. Changingto on pom.xml for the ejb jar dependency did the trick. My pom was autogenerated by netbeans, I never thougth it could be wrong. 10 deployments in a row and no a single fail.
Many thanks! I think we may close this issue now...