-
1. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
pmuir Feb 17, 2010 1:26 PM (in response to hirowla.ian.rowlands.three.com.au)The exception handler is definitely not managed, and doesn't support injection (probably should, please file a JSF spec bug for that). The EJB class should be injected, but you don't provide enough info to say for sure (environment, code, deployment structure etc.)
-
2. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
hirowla.ian.rowlands.three.com.au Feb 18, 2010 4:45 AM (in response to hirowla.ian.rowlands.three.com.au)I've had another look at the JSF Exception handler, and I think it is debatable. Even if it was managed, it wouldn't help me. The class being instantiated is a factory, so the important part is what the factory produces. As that is in my control and can't be managed by CDI (as I have no idea how often the factory method is called and why it is), I'll compromise and simply force
injection
of the coming classes. Or simply force a new instance each time. So the JSF thing probably isn't a big issue.In terms of the EJB fault interceptor:
- I'm running in JBoss 6.0.0 M2 with Weld 1.0.1 CR2 updated as per one of the blogs.
- The EJB is running in its own EJB jar (not as part of a war file).
- The EJB jar (and web module plus the rest) is packaged as a EAR.
- The actual fault interceptor is packaged in a utility jar file. This jar is in the lib/ directory of the EAR file.
The basic code of the interceptor is:
public class FaultBarrierInterceptor { @Inject private Logger log; @AroundInvoke public Object intercept(final InvocationContext invocationContext) throws Exception { try { return invocationContext.proceed(); } catch (RuntimeException e) { log.error("An uncaught exception was caught: \n-METHOD: " + invocationContext.getMethod() + "\n-PARAMS: " + Arrays.toString(invocationContext.getParameters())); throw new MyUncaughtException(e); } } }
The code for the EJB has a local interface (it's an EJB 3.0 structure, not 3.1). The interceptor definition is:
@Stateless @Interceptors( {FaultBarrierInterceptor.class}) public class OptinServiceBean implements OptinService { }
I can provide more information - just let me know what else is relevant!
Thanks,
Ian
-
3. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
hirowla.ian.rowlands.three.com.au Mar 3, 2010 8:26 AM (in response to hirowla.ian.rowlands.three.com.au)Pete, is there any other information you need? I've just tried this with JBoss 6.0.0 M2 upgraded with Weld 1.0.1 Final and am still getting the same error. I can give you lots of information - just tell me what else is useful!
-
4. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
nickarls Mar 3, 2010 10:15 AM (in response to hirowla.ian.rowlands.three.com.au)So the interceptor is found and hit but it doesn't have any injections (log is null)? And you have lots of beans.xml files everywhere? ;-)
-
5. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
hirowla.ian.rowlands.three.com.au Mar 4, 2010 1:17 AM (in response to hirowla.ian.rowlands.three.com.au)Yep, you've got it in one Nicklas - log is null.
And beans.xml files are everywhere (every single one of them blank!). You may not remember, but a few months ago I forgot to put my beans.xml files in my projects and asked for help - I'm not making that mistake again! (besides, it's the same set of projects which I fixed after that).
-
6. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
hirowla.ian.rowlands.three.com.au Mar 8, 2010 1:30 AM (in response to hirowla.ian.rowlands.three.com.au)Should I file a JIRA? I wasn't sure which project it belongs under - is it WELD itself or the integration project with JBoss?
-
7. Re: Injection into EJB interceptors and custom JSF ExceptionHandler classes
nickarls Mar 8, 2010 8:31 AM (in response to hirowla.ian.rowlands.three.com.au)File it under WELD, thanks.