views:

29

answers:

1

Hey all,

I am using Seam 2.2.1.CR1 on Weblogic 10.3.2 and JSF 1.2.

I have an ear application with 2 war files. The first war is a JSF / Seam application, the second one does have JSF / Seam, but also has some Servlets pages as well.

When I set things in the Session context in the first web application:

Contexts.getSessionContext().set("pimUser", pimUser);

I can inject it normally in Seam components in the second war. However, if I try to get the outjected pimUser from a Servlet, I cannot access it:

PimUser user1 = (PimUser) Contexts.getSessionContext().get("pimUser");

The Contexts.getSessionContext() is null. I noticed that the Javadoc of the

org.jboss.seam.contexts.Contexts

Says:

Provides access to the current contexts associated with the thread.

Author(s): Gavin King Thomas Heute

Does this mean that the 2 war files are supposed to have different Contexts.getSessionScope()?

I found a way which does allow me to access it through the Session like this:

PimUser user2 = (PimUser) httpRequest.getSession().getAttribute("pimUser");

The latter way, however does not seem to be a correct one. I would like to access Seam session context through Seam.

I found that there used (?) to be issues with Seam and multi-war applications (link), however, these are supposed to have been resolved by 2.2.0.GA.

+3  A: 

A regular servlet does not get access to the Seam contexts by default: Replacing servlets with Seam resources. You need to integrate it first by either wrapping the call in Seam Contexts or replacing the servlet with a Seam AbstractResource.

I used both ways before and they work perfectly. Personally, I prefer the AbstractResource because you can get rid of the corresponding web.xml configuration.

kraftan