You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 17 Members of 4546 |
| Forum: Seam Users |
07. Jun 2008, 15:00 CET | Link |
Apologies if this is similar to Bernard Hurzeler's MDB mail question, but I felt that this was sufficiently different for its own topic. I'm experiencing the following stack trace when I try to send mail using a Renderer injected into my event-scoped JavaBean:
08:37:05,731 ERROR [STDERR] org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ui.facelet.facesContextFactory 08:37:05,731 ERROR [STDERR] at org.jboss.seam.Component.newInstance(Component.java:2090) 08:37:05,731 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1972) 08:37:05,731 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1951) 08:37:05,731 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1928) 08:37:05,731 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1923) 08:37:05,731 ERROR [STDERR] at org.jboss.seam.ui.facelet.RendererFacesContextFactory.instance(RendererFacesContextFactory.java:72) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.ui.facelet.RendererRequest.init(RendererRequest.java:52) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:81) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43) 08:37:05,732 ERROR [STDERR] at my.pkg.action.Register.sendActivationEmail(Register.java:95) 08:37:05,732 ERROR [STDERR] at my.pkg.action.Register.submit(Register.java:63) 08:37:05,732 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 08:37:05,732 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 08:37:05,732 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08:37:05,732 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08:37:05,732 ERROR [STDERR] at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.util.Work.workInTransaction(Work.java:41) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166) 08:37:05,733 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102) 08:37:05,733 ERROR [STDERR] ... many more (snip) 08:37:05,746 ERROR [STDERR] Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory 08:37:05,746 ERROR [STDERR] at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256) 08:37:05,746 ERROR [STDERR] at org.jboss.seam.ui.facelet.RendererFacesContextFactory.create(RendererFacesContextFactory.java:47) 08:37:05,746 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 08:37:05,746 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 08:37:05,746 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 08:37:05,746 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585) 08:37:05,746 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) 08:37:05,746 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125) 08:37:05,746 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:2195) 08:37:05,747 ERROR [STDERR] at org.jboss.seam.Component.callCreateMethod(Component.java:2118) 08:37:05,747 ERROR [STDERR] at org.jboss.seam.Component.newInstance(Component.java:2078) 08:37:05,747 ERROR [STDERR] ... 90 more
According to the log, I think my components are at least installed OK:
08:36:08,820 INFO [Component] Component: org.jboss.seam.ui.facelet.facesContextFactory, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.ui.facelet.RendererFacesContextFactory 08:36:08,129 INFO [Component] Component: org.jboss.seam.mail.mailSession, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.mail.MailSession
All of my pages are rendering fine, it's just the mail page. Here's my emailing code if you need it (although I don't think it even impacts the problem):
private boolean sendActivationEmail()
{
try
{
code = activation.generateCode(user.getUsername());
renderer.render("WEB-INF/mail/activation.xhtml");
FacesMessages.instance().add(
"An activation email was sent to your address.");
return true;
}
catch (Exception e)
{
FacesMessages.instance().add(
"Activation email sending failed; "
+ "your account is automatically activated "
+ "and ready to log in.");
log.error(e);
e.printStackTrace();
return false;
}
}
Would it matter that the mailing xhtml depends on the event-scoped register
component from which the mail is being sent? Any help would be greatly appreciated.
Yep, just came across this issue the other day. I have to say this in bold.
You cannot render JSF components in an email template asynchronously.That's the current situation, not the permanent one. Basically, when you are doing asynchronous work, the JSF FacesContext is fake. Therefore, we can do things that involve the EL, but we cannot do thing that involve rendering components. What I would like to see is Seam join forces with JSFUnit to setup a real standalone JSF FacesContext so that we can render JSF components in a standalone environment. This would help SeamTest as well.
For now, you have to stick to plain-text e-mails.
Dan Allen | mojavelinux.com | Author of Seam in Action
Oh, and the error is because of a bug in the FaceletsRenderer class. JBSEAM-3085
It does look like real asynchronous rendering is coming in 2.1. Perhaps I spoke to soon. But in 2.0 you definitely can't do it.
Dan Allen | mojavelinux.com | Author of Seam in Action
THX Dan,
you saved my day. I experienced the same problem today. I tried to use JSF-Tags in my Email, wich is generated from an asynchronous call.
THE REF-DOC SHOULD POINT TO THIS PROBLEM