This content has been marked as final.
Show 7 replies
-
1. Re: How to access Seam components in a Filter class?
cptnkirk May 29, 2006 6:01 AM (in response to evanzeng)You're going to have trouble with a stateless component. If you are able to make it stateful you might have a shot. Try...
Contexts.lookupInStatefulContexts("userManager")
Make sure your filter is wrapped by the Seam filter.
-Jim -
2. Re: How to access Seam components in a Filter class?
cptnkirk May 29, 2006 6:13 AM (in response to evanzeng)Might also be able to simply look up via JNDI or @EJB. In which case you may be able to leave your bean @Stateless.
-
3. Re: How to access Seam components in a Filter class?
gavin.king May 29, 2006 12:03 PM (in response to evanzeng)The Seam contexts are not available in a servlet filter.
-
4. Re: How to access Seam components in a Filter class?
cavani May 31, 2006 11:08 AM (in response to evanzeng)I use this with Quartz Servlet:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=83739
like that:@Stateless @Name("agentjob") public class AgentJob implements Serializable, Job { @PersistenceContext private EntityManager em; public void execute() { // ... } }
and this in class that is instantiate for a scheduled job:Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.LocalOnlyContextFactory"); env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces"); Context ctx = new InitialContext(env); Job job = (Job) ctx.lookup("AgentJob/local"); job.execute();
I am using Tomcat / Quartz 1.5.2 / EEJB / Seam CR3... and this is only a test for now...
Cavani -
5. Re: How to access Seam components in a Filter class?
muckwarrior May 31, 2006 12:46 PM (in response to evanzeng)"gavin.king@jboss.com" wrote:
The Seam contexts are not available in a servlet filter.
Is there a work around to this? I would like to use a servlet filter for security but I need to access seam components to get loggedInUser data. -
6. Re: How to access Seam components in a Filter class?
gavin.king May 31, 2006 12:50 PM (in response to evanzeng)There is a JIRA issue:
http://jira.jboss.com/jira/browse/JBSEAM-138 -
7. Re: How to access Seam components in a Filter class?
muckwarrior May 31, 2006 1:10 PM (in response to evanzeng)That issue seems to deal with data being passed from the servlet to seam, it's the opposite that I need. Here's an example of what I'm trying to do:
SecurityManager secMan = (SecurityManager) ctx.lookup("seamapp/SecurityManagerBean/local"); user = secMan.getLoggedInUser();
I then want to evaluate whether user is null or not to decide whether to let them view certain pages.
The problem is I keep getting null pointer exceptions when I try to use the SecurityManager methods. At first I thought It wasn't retreiving the SecurityManager object, but it actually is. I just cant call the methods. The above code has worked fine for me in straight JSPs but not in the servlet.