-
1. Re: cannot inject event
meetoblivion Jun 12, 2011 2:44 PM (in response to nev)If this is some kind of main program/standard app you need to make sure you're bootstrapping your CDI Container. Understanding a little more about your environment would help as well.
-
2. Re: cannot inject event
nev Jun 12, 2011 4:56 PM (in response to nev)Thank you for your reply. Yes, this is a standalone application. So, if I need to bootstrap the CDI container, what is the overhead? Do you think it is wise to use the seam catch module instead of regular try-catch blocks from standalone app?
Thanks again!
-
3. Re: cannot inject event
meetoblivion Jun 12, 2011 7:13 PM (in response to nev)Overhead of using a CDI container, instead of just running your program? It's probably not a lot. You're talking about the equivalent of running something like spring in your SE application. The effort of actually implementing it may be a little more than you're expecting. Everywhere that you're using new needs to be an injection point in CDI,
-
4. Re: cannot inject event
nev Jun 13, 2011 1:54 PM (in response to nev)I really appreciate for your response. Is there any good site that shows how to integrate seam catch to standalone application or with spring? I am having a hard time finding this information. I saw a lot of documents what is seam catch and how it is used, but not any example how to use it from core Java app or spring. I would really appreciate if you can help me out.
Thanks in advance for your time!
-
5. Re: cannot inject event
lightguard Jun 13, 2011 2:55 PM (in response to nev)You should be doing something like this:
@Inject Event<ExceptionToCatch> catchEvent; ... catchEvent.fire(new ExceptionToCatch(e));
If that is not working then either
- CDI is not bootstrapped or
- The bean you are trying to inject into is not a ManagedBean (as defined by the spec). Basically it needs to have a no args ctor, or a ctor annotated with @Inject and it cannot be final.
- You do not have a beans.xml in the correct location of your archive.
If CDI is running and your bean is a ManagedBean, and you a beans.xml in the correct location then some very odd is going on with your setup. Pasting the code you're using would be very helpful