This content has been marked as final.
Show 1 reply
-
1. Re: Optional @Resource Elements
jaikiran Feb 27, 2018 2:22 AM (in response to walkerca)A @Resource injection is a hard dependency and there's no construct to make it optional in Java EE.
You could probably do away with the injection and instead do a manual JNDI Context.lookup(...) yourself in the lifecycle startup method (like a @PostConstruct) of the component and catch the NameNotFoundException and ignore it, to make the resource "optional" within your application.