-
1. Re: No application context active
dhinojosa Apr 5, 2008 6:20 AM (in response to tonylmai)MyComp myComp = (MyComp) Contexts.getApplicationContext().get("myComp");
I haven't done JMS stuff in Seam yet (I will this week). But I know Contexts have a getApplicationContext method
-
2. Re: No application context active
tonylmai Apr 5, 2008 6:43 AM (in response to tonylmai)That too was not available (Contexts.getApplicationContext() returned null).
-
3. Re: No application context active
dhinojosa Apr 5, 2008 7:22 AM (in response to tonylmai)1. What does MyComp look like?
2. Is it installed during deployment or explosion (as seen in the app server console)?
3. If MyComp doesn't have configuration annotations, how are they configured in components.xml? -
4. Re: No application context active
tonylmai Apr 5, 2008 7:33 AM (in response to tonylmai)MyComp is defined as followed:
@Scope(ScopeType.APPLICATION) @Name("myComp") @Startup public class MyComp implements Serializable { ... @Create public void init() { ... }
-
5. Re: No application context active
dhinojosa Apr 5, 2008 7:44 AM (in response to tonylmai)http://jira.jboss.org/jira/browse/JBIDE-1574
Is there room for redesign and see if that works? Supposedly there is a fix for the latest release.
-
6. Re: No application context active
tonylmai Apr 5, 2008 8:46 AM (in response to tonylmai)Refactored and still Contexts.getApplicationContext() returned null and Component.getInstance(
myComp
, true) threwNo application context active
.I think I still need to somehow tap onto Seam's application context. Unfortunately org.jboss.seam.contexts.ApplicationContext does not offer such getInstance() method.
My only reason to create this JMS listener was that I could not get my MDB to work with remote queue (see my other post on
Seam MDB with remote topic
). With plain JMS, I was able to get the messages. Yet my MDB just sit there idling. :(Any idea?
Thanks
-
7. Re: No application context active
mokua Apr 5, 2008 9:17 AM (in response to tonylmai)To get the contexts try:
import org.jboss.seam.contexts.Lifecycle;
boolean createContexts = !Contexts.isEventContextActive() && !Contexts.isApplicationContextActive(); if (createContexts) { Lifecycle.beginCall(); }
-
8. Re: No application context active
dhinojosa Apr 5, 2008 9:28 AM (in response to tonylmai)Something strange, I tried it out and I had to make my MDB as stateless. If it truly is an MDB. So you wouldn't make a lot of sense for an application scope MDB. Without having it as an MDB, all gets injected fine and it works.
The code I used is yours with some necessities.
@Scope(ScopeType.APPLICATION) @Name("myComp") @Startup public class MyComp implements Serializable { @Create public void init() { } }
and this is what I changed, as you can see an application scoped and stateless bean really doesn't make sense.
import org.jboss.seam.Component; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.Startup; import org.jboss.seam.contexts.Contexts; import javax.jms.Message; import javax.jms.MessageListener; import javax.ejb.MessageDriven; import javax.ejb.ActivationConfigProperty; import javax.ejb.Stateless; @Stateless @Scope(ScopeType.APPLICATION) @Name("tdOrdersListener") @Startup(depends = {"myComp"}) @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/tolltag") }) public class OrdersListenerAlt implements MessageListener { @In private MyComp myComp; public MyComp getMyComp() { return myComp; } public void setMyComp(MyComp myComp) { this.myComp = myComp; } @Override public void onMessage(Message msg) { if (myComp == null) { myComp = (MyComp) Contexts.getSessionContext().get("myComp"); //This code threw 'No application context active' myComp = (MyComp) Component.getInstance("myComp", true); // Still won't work } } }