EJB 3.1 spec, section 4.8.1:
"If the Startup annotation appears on the Singleton bean class or if the Singleton has been designated via the deployment descriptor as requiring eager initialization, the container must initialize the Singleton bean instance during the application startup sequence. The container must initialize all such startup-time Singletons before any external client requests (that is, client requests originating outside of the application) are delivered to any enterprise bean components in the application.
EAP does not implement this correctly, and allows calls to other EJBs before a @Startup @Singleton finishes its @PostConstruct call.
Attached test case, test.zip.
Deploy both singleton.jar and client.war.
The @Singleton's @PostConstruct will log to stdout "starting pause" and sleep.
Hit client.war -- http://localhost:8080/client/ which accesses another bean in single
Expected: EJB call waits until @PostConstruct finishes.
Actual: EJB call completes immediately (logs to stdout "Singleton TestBean").
Created attachment 1129567 [details]
Workaround: Add @DependsOn("SingletonEJBName"), or @DependsOn("ejb.jar#SingletonEJBName") for separate modules in an ear, to each EJB for each singleton it needs to wait on.
Created attachment 1137443 [details]
auto-test-reproducer.zip - just deploy jars and it will log an error and stacktrace if issue occurs
Fedor Gavrilov <fgavrilo> updated the status of jira WFLY-6402 to Coding In Progress
Fedor Gavrilov <fgavrilo> updated the status of jira WFLY-6402 to Open
Fedor Gavrilov <fgavrilo> updated the status of jira WFLY-6402 to Resolved
Fedor Gavrilov <fgavrilo> updated the status of jira WFLY-6402 to Reopened
auto-test-reproducer.zip does not work (https://bugzilla.redhat.com/show_bug.cgi?id=1350355)
Verified with EAP 6.4.9.CP.CR2
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.