-
1. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
ranophoenix Dec 22, 2010 9:27 PM (in response to kernstock)Do you have a file named beans.xml in your classpath? (It's basic but sometimes happens)
-
2. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
kernstock Dec 23, 2010 2:18 AM (in response to kernstock)Yes, I have. I'm using CDI all over different classes and this works correctly.
-
3. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
jharting Dec 23, 2010 8:07 AM (in response to kernstock)How do you throw the exception?
-
4. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
cernicb Dec 23, 2010 9:06 AM (in response to kernstock)In your concrete class you don't have default or @Inject constructor, so you can't inject your exception service into ejb bean or whether it's supposed to be injected. So I guess you obtain exception instance via new. Is that a reason why postconstruct is never called?
-
5. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
kernstock Dec 23, 2010 12:21 PM (in response to kernstock)@Josef and @Branislav,
thank you very much for your reply. And of course you're right - I coded
throw new ConcreteException(id)
- since I'm used to do that since ages :-)I now inject the ConcreteException into my service and throw the injected field instead and this works perfectly.
Thanx again - you saved my day.
Thomas
-
6. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
kapitanpetko Dec 23, 2010 9:13 PM (in response to kernstock)
Thomas Kernstock wrote on Dec 23, 2010 12:21:
@Josef and @Branislav,
thank you very much for your reply. And of course you're right - I codedthrow new ConcreteException(id)
- since I'm used to do that since ages :-)
I now inject the ConcreteException into my service and throw the injected field instead and this works perfectly.The question now is: is it a good idea to make your exception all that smart? Exceptions are basic classes and you may get errors all over the place when logging, dumping, etc., since practically no library you use is aware of CDI, @Inject, etc. Might be a better idea to have an ExceptionFactory or whatever, that injects LocaleHandler and produces simple, dumb exception instances that have the correct message stored.
-
7. Re: JEE6 - @ApplicationException - @Inject and @PostConstruct not called
kernstock Dec 24, 2010 9:21 AM (in response to kernstock)Nikolay,
thank you for your post. I will think about that.
regards
Thomas