[WFLY-9443] Random deploy error with @Startup @Singleton EJB Created: 13/Oct/17  Updated: 17/Oct/17  Resolved: 17/Oct/17

Status: Closed
Project: WildFly
Component/s: CDI / Weld, Class Loading, EJB
Affects Version/s: 11.0.0.CR1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Juan Martin Runge Assignee: Martin Kouba
Resolution: Rejected Votes: 0
Labels: regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Wildfly 11.0CR1 + Vaadin 8.1.4
Tested on Debian 9.1 and Windows 10

Attachments: File error.log     File success.log     File wftest-ear-0.1.0.ear.tar.gz     File wftest.tar.gz    
Steps to Reproduce:
  • Use provided app
  • Deploy to Wildfly 11 CR1
  • If success, deploy again and so on until it fails (should not be more than 5 or 6 times)
Forum Reference: https://developer.jboss.org/message/976488#976488
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. Changing






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...

Kind Regards,

Juan Martin

Generated at Sun Nov 18 04:22:07 EST 2018 using Jira 7.12.1#712002-sha1:609a50578ba6bc73dbf8b05dddd7c04a04b6807c.