-
1. Re: How to use a seam component in an other one?
mail.micke Jul 24, 2008 4:39 PM (in response to mikool)Hi
Seam looks up objects to inject via the name of the property,
processManager
in you case.Since you named it
ProcessManager
it won't find it.To fix that use
@In("#{ProcessManager}")
You might want to add a
create=true
to the injection as well so it is created if doesn't
already exist.Cheers,
micke -
2. Re: How to use a seam component in an other one?
mikool Jul 24, 2008 5:52 PM (in response to mikool)Thanks, it works so far.
But I cannot addcreate=true
Can you give me an example how to use@In("#{ProcessManager}")
and addcreate=true
?
Thanks. -
3. Re: How to use a seam component in an other one?
mikool Jul 24, 2008 6:11 PM (in response to mikool)I also would like to know if it is possible to solve this problem without using EL in the annotation @In?
-
4. Re: How to use a seam component in an other one?
mail.micke Jul 24, 2008 6:43 PM (in response to mikool)Seems like you don't have to use EL, looks like just using context variable name should work documentation.
Example:
@Name("testing") public class Test { @In(value="ProcessManager", required=false) // or I wouldn't use @In(value="#{ProcessManager}", required=false) // or @In(value="ProcessManager", create=true) ProcessManagerInterface processManager; public void dosth() { processManager.dosth(); } }
-
5. Re: How to use a seam component in an other one?
mikool Jul 24, 2008 7:16 PM (in response to mikool)If I use
@In(value="ProcessManager", required=false)
without EL then I get an NullPointerException. -
6. Re: How to use a seam component in an other one?
gjeudy Jul 24, 2008 8:34 PM (in response to mikool)It is a mistake to try to give a Seam scope to a stateless session bean. Seam does not manage the lifecycle of the stateless session bean. Moreover I don't think the @Startup annotation works on an EJB for the same reason. Check the seam sourcecode you will see @Startup is only used on POJOs which makes sense.
I would try removing @Stateless from your example.
@Name("ProcessManager") @Startup @Scope(ScopeType.APPLICATION) public class ProcessManager implements ProcessManagerInterface{ public void dosth(){ System.out.println("=====Hello World====="); } }
public interface ProcessManagerInterface { public void dosth(); }
@Name("testing") public class Test { @In(value="ProcessManager") ProcessManagerInterface processManager; public void dosth() { processManager.dosth(); } }
You could rename your
@Name("processManager")
and then just:@In processManager
should work.
If you require a @Stateless EJB then remove @Startup and @Scope and just use:
@In(value="ProcessManager", create=true)
-
7. Re: How to use a seam component in an other one?
mikool Jul 24, 2008 11:01 PM (in response to mikool)Thanks!
Now it works very well!
But when I don't use@In(create=true)
I get a null Pointer Exception.