Exception with seam mail delivery, not asynchronously!
swenvogel Apr 10, 2009 12:37 PMHi,
i am new to seam, and trying to code a little online survey with email confirmation. I always get the following exception on rendering the email page (emailConfirmation.xhtml).
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ui.facelet.facesContextFactory ... Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
I already googled for this exception and find some related post's. But the majority of the post's refer to
asynchronous mail processing. When i open the mail page from the browser everything works fine.
When i deploy the project the component org.jboss.seam.ui.facelet.facesContextFactory is successfully installed.
[Initialization] Installing components... [Component] Component: org.jboss.seam.ui.facelet.facesContextFactory, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.ui.facelet.RendererFacesContextFactory
Developing environment:
- Seam: 2.1.1.GA
- JBossAs: 5.0.1.GA
Here are the relevant code part's:
The stateless session bean for handling survey actions
I send the email in the finishSurvey() method.
@Stateless
@Name("surveyAction")
@Scope(ScopeType.CONVERSATION)
public class SurveyAction implements SurveyActionLocal {
@PersistenceContext
private EntityManager em;
@In(create = true)
private Renderer renderer;
@DataModel
private List<Survey> surveys;
@DataModelSelection
@In(required = false)
@Out(required = false)
private Survey selectedSurvey;
@Factory(value = "surveys")
public void initSurveys() {
surveys = em.createQuery("from Survey").getResultList();
}
@Begin
public String beginSurvey(String surveyName, String page) {
selectedSurvey = new Survey();
selectedSurvey.setName(surveyName);
return page;
}
public String continueTo(String page) {
return page;
}
@End
public String finishSurvey() {
selectedSurvey.setCreationDate(new Date());
em.persist(selectedSurvey);
// Send a email confirmation
renderer.render("/mail/emailConfirmation.xhtml");
return "/survey_end.xhtml";
}
public String showSurvey() {
return "/admin/show_survey.xhtml";
}
public String saveSurvey() {
selectedSurvey = em.merge(selectedSurvey);
return "saved";
}
public String deleteSurvey() {
selectedSurvey = em.merge(selectedSurvey);
em.remove(selectedSurvey);
selectedSurvey = null;
surveys = null;
return "deleted";
}
}
The test confirmation email (emailConfirmation.xhtml)
<m:message xmlns:m="http://jboss.com/products/seam/mail"> <m:from name="vogel" address="vogel@test.de" /> <m:to name="vogel">vogel@test.de</m:to> <m:subject>Survey email confirmation</m:subject> <m:body type="plain"> test message </m:body> </m:message>
Thank's for your help ...