ApplicationContext confusion
appendix Mar 28, 2008 12:41 PMHi,
I'm exposing an action method which sends out email through a WebService from a Seam application (using annotations - great stuff!).
Everything is working properly, if the application has been accessed from a web browser before the SOAP request takes place.
But if a SOAP request occurs right after a server restart, I'm facing a No application context active
IllegalStateException despite a call to Contexts.isApplicationContextActive() in my action method returns true.
The following is the snippet of my action method:
log.debug("Application context #0", Contexts.isApplicationContextActive()?"is active":"ISN'T ACTIVE"); //indicates an active application context in the log renderer.render(viewId); //instance of type org.jboss.seam.faces.Renderer
when renderer.render(viewId) is hit, the following exception is thrown:
java.lang.IllegalStateException: No application context active at org.jboss.seam.Component.forName(Component.java:1812) at org.jboss.seam.Component.getInstance(Component.java:1862) at org.jboss.seam.Component.getInstance(Component.java:1845) at org.jboss.seam.Component.getInstance(Component.java:1824) at org.jboss.seam.Component.getInstance(Component.java:1819) at org.jboss.seam.mail.MailSession.instance(MailSession.java:279) at org.jboss.seam.mail.ui.UIMessage.getMailSession(UIMessage.java:62) at org.jboss.seam.mail.ui.UIMessage.getMimeMessage(UIMessage.java:77) at org.jboss.seam.mail.ui.MailComponent.findMimeMessage(MailComponent.java:94) at org.jboss.seam.mail.ui.UIFrom.encodeBegin(UIFrom.java:23) at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:172) at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163) at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:165) at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175) at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163) at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet(FaceletsRenderer.java:206)
I debugged the application and a call to Contexts.isApplicationContextActive() from org.jboss.seam.mail.MailSession.instance() returns indeed false.
Could anyone explain why a previously active application context is not active in the MailSession?
Is there a way to initialize the application context from the code (not by hitting the application from a browser)?
Any help greatly appreciated!
Best regards, Kurt