A fix for Seam mail
[Logo]
Forums for ICEfaces and ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
A fix for Seam mail  XML
Forum Index -> JBoss Seam Integration Go to Page: 1, 2, 3 Next 
Author Message
gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


Hi all,

Like more than a few others I have been wanting to use Seam mail alongside IceFaces for a while now, but it doesn't work. There is a workaround now apparently by using just-ice.jar but I created my own fix before I came across this. Anyway, I thought I'd share my fix.

What I have done is take the AsynchronousMailProcessor class from the mail example from the Seam examples and added a workaround for the IceFaces compatibility issue.

The workaround involves messing with the FacesContext and its viewroot (it resets them when the email is done) so unfortunately it can't access your Seam contexts directly. I get around this by passing the emailer a hashmap of context items I want in the new context.

To send an email is pretty simple. First inject the mailProcessor component then call scheduleEmailSend.

e.g. from the forgotPassword handler in my current project
@In
private AsynchronousIceFacesMailProcessor asynchronousMailProcessor;
...

private void sendForgotEmail()
{
String template = "/templates/emails/forgotpassword.xhtml";
User user = getUser();

HashMap<String, Object> contextMap = new HashMap<String, Object>();
contextMap.put("user", user);
contextMap.put("password", user.resetPassword());

// schedule the email to be sent 5000ms from now
asynchronousMailProcessor.scheduleEmailSend(5000, template, contextMap);

}


Feel free to use this however you like. It's been working well for me for a while now but I only abstracted it to the point that it was divorced my my clients code (allowing me to share it) today. I won't offer any support for it but if you have issues you can certainly send me an email and I'll take a look when I can. If anyone wants to modify / improve upon it also feel free, just let me know so I can reap the benefits too.

Enjoy.
 Filename AsynchronousIceFacesMailProcessor.java [Disk] Download
 Description
 Filesize 5 Kbytes
 Downloaded:  186 time(s)

gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


Whoops!

My aplogies to anyone who downloaded the code over the last couple of days. I just realized that I posted an old version. Sorry, my bad. I was working on a released branch of my own project rather than the trunk and didn't think about that when I uploaded the file.

The version I uploaded previously was my first attempt, which did get Seam mail working and you could do basic EL expressions but faces tags would not work due to an instanceof check in the IceFaces renderer. i.e. you could do Dear #{person.firstname} but not Dear <h:outputText value="#{person.firstname}"/>

Anyway, the version attached here fixes that. You still can't do Icefaces tags but basic faces tags should work fine, at least the ones I've tested.

Again, sorry for the confusion.
 Filename AsynchronousIceFacesMailProcessor.java [Disk] Download
 Description
 Filesize 13 Kbytes
 Downloaded:  247 time(s)

yocasper

Joined: 02/06/2007 00:00:00
Messages: 2
Offline


Hi,

I have some trouble getting your solution to run. Whenever the mail processor is called I get a java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory.

Do I have to deploy some additional jars?
gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


I actually saw that exception the first time I tested this, but it disappeared the next time I deployed and I haven't seen it since. If you can reproduce it let me know and post some details and I'll see if I can figure it out.
yocasper

Joined: 02/06/2007 00:00:00
Messages: 2
Offline


I am running your example without any changes using Seam 2.0.1 and ICEfaces 1.7 on JBoss 4.2.2.

My components.xml looks like:
Code:
 <components ...>
    <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
      
    <component scope="APPLICATION" auto-create="true" name="renderManager" class="com.icesoft.faces.async.render.RenderManager" />
 
    <core:manager concurrent-request-timeout="500" 
                  conversation-timeout="120000" 
                  conversation-id-parameter="cid"/>
     
    <persistence:managed-persistence-context name="entityManager"
                                      auto-create="true"
                       persistence-unit-jndi-name="java:/mjunetiEntityManagerFactory"/>
 
    <drools:rule-base name="securityRules">
        <drools:rule-files>
            <value>/security.drl</value>
        </drools:rule-files>
    </drools:rule-base>
 
    <security:identity authenticate-method="#{authenticator.authenticate}"
                            security-rules="#{securityRules}"/>
    
    <event type="org.jboss.seam.security.notLoggedIn">
        <action execute="#{redirect.captureCurrentView}"/>
    </event>
    
    <event type="org.jboss.seam.security.loginSuccessful">
        <action execute="#{redirect.returnToCapturedView}"/>
    </event>
    
    <!-- Install the QuartzDispatcher -->
    <async:quartz-dispatcher/>
    
    <!-- Configure Mail -->
    <mail:mail-session host="localhost" port="2525" username="yocasper" password="*******" />
    
    <!-- uncomment this one and set the host attribute to the name or IP address of your SMTP gateway-->
    <!-- <mail:mail-session host="smtp.foo.com" />-->
    
    <!-- Configure meldware -->
    <mail:meldware>
    	<mail:users>
    		<value>#{meldwareUser.yocasper}</value>
 	</mail:users>
    </mail:meldware>
    
    <!-- Meldware users -->
    
    <mail:meldware-user name="meldwareUser.yocasper" username="yocasper" password="********" />  
       
 </components>
 


and web.xml:
Code:
 <web-app version="2.5"
          xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     
     <!-- Seam (using Icefaces) generated project-->
     
     <!-- listeners required for this application --> 
     <listener>
         <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
     </listener>
 
     <listener>
         <listener-class>com.icesoft.faces.util.event.servlet.ContextEventRepeater</listener-class>
     </listener>
 
     
     <!-- filters -->
     <filter>
         <filter-name>Seam Filter</filter-name>
         <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
     </filter>
     
     <filter-mapping>
         <filter-name>Seam Filter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
     
      <filter>
         <filter-name>UrlRewriteFilter</filter-name>
         <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
 
  		 <!-- set the amount of seconds the conf file will be checked for reload
         can be a valid integer (0 denotes check every time,
         -1 denotes no reload check, default -1) -->
         <init-param>
             <param-name>confReloadCheckInterval</param-name>
             <param-value>0</param-value>
         </init-param>
  		      
         <init-param>
             <param-name>logLevel</param-name>
             <param-value>WARN</param-value>
         </init-param>
          <!--
         <init-param>
             <param-name>statusPath</param-name>
             <param-value>/status</param-value>
         </init-param>
         -->
         
     </filter>
     
     <filter-mapping>
         <filter-name>UrlRewriteFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
      
     <context-param>
         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
         <param-value>server</param-value>
     </context-param>
     
     <!-- Facelets development mode (disable in production) -->
     <context-param>
         <param-name>facelets.DEVELOPMENT</param-name>
         <param-value>true</param-value>
     </context-param>
     
     <context-param>
         <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
         <param-value>.xhtml</param-value>
     </context-param>
     
     <context-param>
         <param-name>com.icesoft.faces.actionURLSuffix</param-name>
         <param-value>.seam</param-value>
     </context-param>
     
     <context-param>
         <param-name>com.icesoft.faces.synchronousUpdate</param-name>
         <param-value>false</param-value>
     </context-param>
 
     <context-param> 
         <param-name>com.icesoft.faces.doJSFStateManagement</param-name>
 	<param-value>true</param-value>
     </context-param> 
 
     <context-param>
         <param-name>org.icesoft.examples.serverClock</param-name>
         <param-value>false</param-value>
     </context-param>
 
     <context-param>
         <param-name>com.icesoft.faces.standardRequestScope</param-name>
         <param-value>true</param-value>
     </context-param>
     
     <!-- servlets -->
     <servlet>
         <servlet-name>Faces Servlet</servlet-name>
         <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
     </servlet>
     
     <servlet>
         <servlet-name>Seam Resource Servlet</servlet-name>
         <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
     </servlet>
     
     <servlet>
         <servlet-name>Persistent Faces Servlet</servlet-name>
         <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
         <load-on-startup> 1 </load-on-startup>
     </servlet>
     <servlet>
         <servlet-name>Blocking Servlet</servlet-name>
         <servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
         <load-on-startup> 1 </load-on-startup>
     </servlet>  
     
 
     <!-- servlet mappings -->
     <servlet-mapping>
         <servlet-name>Persistent Faces Servlet</servlet-name>
         <url-pattern>*.seam</url-pattern>
     </servlet-mapping>
     
      <servlet-mapping>
         <servlet-name>Persistent Faces Servlet</servlet-name>
         <url-pattern>/xmlhttp/*</url-pattern>
     </servlet-mapping>
     
     <!-- Blocking Servlet Mapping -->
     <servlet-mapping>
         <servlet-name>Blocking Servlet</servlet-name>
         <url-pattern>/block/*</url-pattern>
     </servlet-mapping>
              
     <servlet-mapping>
         <servlet-name>Seam Resource Servlet</servlet-name>
         <url-pattern>/seam/resource/*</url-pattern>
     </servlet-mapping>
     
     <security-constraint> 
         <display-name>Restrict raw XHTML Documents</display-name>
         <web-resource-collection>
             <web-resource-name>XHTML</web-resource-name>
             <url-pattern>*.xhtml</url-pattern>
         </web-resource-collection>
         <auth-constraint>
             <role-name>NONE</role-name>
         </auth-constraint>
     </security-constraint>
     
 </web-app>
 


My faces-config.xml looks like:
Code:
 <faces-config>
 
    <application>
       <message-bundle>messages</message-bundle>
       <locale-config>
          <default-locale>de_DE</default-locale>
          <supported-locale>de_DE</supported-locale>
          <supported-locale>de_AT</supported-locale>
          <supported-locale>de_CH</supported-locale>
       </locale-config>
       <view-handler>com.icesoft.faces.facelets.D2DSeamFaceletViewHandler</view-handler>
    </application>
 
 </faces-config>
 


I call the scheduleEmailSend method from the class you provided like this:
Code:
 Map<String, Object> context = new HashMap<String, Object>();
 context.put("registeredUser", body);
 asynchronousMailProcessor.scheduleEmailSend(300, "/WEB-INF/mailtemplates/confirmationRegistration.xhtml", context);
 


After a moment the stack trace gets noisy:
07:10:08,184 ERROR [JobRunShell] Job DEFAULT.22bc6e12:119e0adfd98:-7fbd threw an unhandled Exception:
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
at com.icesoft.faces.context.BridgeFacesContext.<init>(BridgeFacesContext.java:99)
at com.mjuneti.core.mail.AsynchronousMailProcessor$MockBridgeFacesContext.<init>(AsynchronousMailProcessor.java:170)
at com.mjuneti.core.mail.AsynchronousMailProcessor$Context.wrap(AsynchronousMailProcessor.java:123)
at com.mjuneti.core.mail.AsynchronousMailProcessor.scheduleEmailSend(AsynchronousMailProcessor.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
at com.mjuneti.core.mail.AsynchronousMailProcessor_$$_javassist_4.scheduleEmailSend(AsynchronousMailProcessor_$$_javassist_4.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:240)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
07:10:08,185 ERROR [ErrorLogger] Job (DEFAULT.22bc6e12:119e0adfd98:-7fbd threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory]
at org.quartz.core.JobRunShell.run(JobRunShell.java:214)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
* Nested Exception (Underlying Cause) ---------------
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
at com.icesoft.faces.context.BridgeFacesContext.<init>(BridgeFacesContext.java:99)
at com.mjuneti.core.mail.AsynchronousMailProcessor$MockBridgeFacesContext.<init>(AsynchronousMailProcessor.java:170)
at com.mjuneti.core.mail.AsynchronousMailProcessor$Context.wrap(AsynchronousMailProcessor.java:123)
at com.mjuneti.core.mail.AsynchronousMailProcessor.scheduleEmailSend(AsynchronousMailProcessor.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
at com.mjuneti.core.mail.AsynchronousMailProcessor_$$_javassist_4.scheduleEmailSend(AsynchronousMailProcessor_$$_javassist_4.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52)
at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:240)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)


I tried deploying it a couple times but the error didn't disappear. I tried several other things too without any success.
I would really appreciate your help on this.

gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


I haven't had much time to look at this due to a tight deadline at work. I did some quick tests but couldn't duplicate the error. I would think something like this would fix it though:

In the wrap method right before the MockBridgeFacesContext is created, try setting the application factory.

The code would look like this:

if (PersistentFacesState.getInstance() != null) {
...
}
else {
try {
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY));
} catch (IllegalStateException ex) {
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
"com.sun.faces.mock.MockApplicationFactory");
}

BridgeFacesContext bfc = new MockBridgeFacesContext(viewId); bfc.setCurrentInstance();
}

Let me know if that works for you. If it does I will add it to the code. If not I will try to get some time to investigate it this week.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 953
Offline


I have tried @gstacey's fix and it worked great for Seam-2.0.0.GA, but requires some modification for 2.0.1.GA and 2.0.2.GA.

Working with the seam trunk (this is not backwards-compatible and required some change to seam to get working--Thanks to Pete Muir), we now have an example of how to use jsf-delegation with seam-mail to get it working. There is an attachment to jira ICE-2321 that you can drop into a recent download of seam trunk (2.1.0) that works using jsf-delegation and ICEfaces. You will need to set icefaces.home to your local icefaces installation as it uses just-ice.jar instead of icefaces.jar.
gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


I finally got some time to investigate this issue, sorry for the slow response.

It looks like there is some issue with Seam and Quartz involved. The code works fine for me with the default scheduler but not with Quartz. I found mention of a similar Quartz issue on the Seam forums
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116377&postdays=0&postorder=asc&start=0

Anyway, I worked out a solution for this also and have attached it. This has been tested in Seam2.0.2SP1 and JBoss 4.2.2
 Filename AsynchronousIceFacesMailProcessor.java [Disk] Download
 Description
 Filesize 13 Kbytes
 Downloaded:  0 time(s)

judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 953
Offline


@gstacey...why don't you attach this class with a comment to the jira? That way, depending on the version of Seam, we will have (most) of it covered. (ICE-2321). They can either use your Class (for the pre jboss-seam-2.1.0) or jsf-delegation like in the example attached to the jira.
Thanks for your efforts!
gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


I've attached my workaround for this issuein the JIRA
Newlukai

Joined: 29/11/2006 00:00:00
Messages: 125
Offline


Hi gstacey,

first I want to thank you for this solution. I was astonished that the only workaround to use Seam mailing was to use an unreleased Seam version and just-ice.jar. But you showed that there's another way.

I've modified your version this way:
Code:
@Asynchronous
 	public void scheduleEmailSend(@Duration
 	long delay, String template, HashMap<String, Object> contextMap) {
 		// emailSend(template, contextMap);
 		// }
 		//	
 		// public void emailSend(String template, HashMap<String, Object>
 		// contextMap) {
 //.....
 			
 		}
 		catch (IOException e) {
 			log.error("AsynchronousMailProcessor::emailSend exception - " + e.getMessage());
 			throw new RuntimeException(e);
 		}
 		finally {
 			context.unwrap();
 		}
 	}


Code:
@Asynchronous
 	public void scheduleEmailSend(@Duration
 	long delay, String template, HashMap<String, Object> contextMap) {
 		// emailSend(template, contextMap);
 		// }
 		//	
 		// public void emailSend(String template, HashMap<String, Object>
 		// contextMap) {
 //.....
 			
 		}
 		catch (Exception e) {
 			log.error("AsynchronousMailProcessor::emailSend exception - " + e.getMessage());
 			throw new RuntimeException(e);
 		}
 		finally {
 			context.unwrap();
 		}
 	}


I catch every exception since I had a mistake in my EL this code just did nothing. Neither do anything useful nor show an error.

After fixing my EL, I got this:

log wrote:
AsynchronousMailProcessor::emailSend exception - ICEfaces requires the PersistentFacesServlet. Please check your web.xml servlet mappings 


What could have caused this exception? I use JBoss AS 4.2.2 with Seam 2.0.1 and ICEfaces 1.7.1.
Here's my components.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
 <components
 	xmlns="http://jboss.com/products/seam/components"
 	xmlns:core="http://jboss.com/products/seam/core"
 	xmlns:mail="http://jboss.com/products/seam/mail"
 	xmlns:persistence="http://jboss.com/products/seam/persistence"
 	xmlns:security="http://jboss.com/products/seam/security"
 	xmlns:transaction="http://jboss.com/products/seam/transaction"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="
 		http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
 		http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
 		http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
 		http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
 		http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd">
 		<core:init 	jndi-pattern="Ares-ear/#{ejbName}/local"
 					transaction-management-enabled="true"
 					debug="false"
 					/>
 		
 		<core:manager	concurrent-request-timeout="500"
 						conversation-id-parameter="cid"
 						conversation-timeout="120000"
 						/>
 		
 		<core:resource-loader>
 			<core:bundle-names>
 				<value>com.idsscheer.ares.resources.ares_messages</value>
 			</core:bundle-names>
 		</core:resource-loader>	
 		
 		<transaction:ejb-transaction />
 		
 		<persistence:managed-persistence-context name="em" auto-create="true" persistence-unit-jndi-name="java:/entityManagerFactories/aresData"/>
 		
 		<security:identity authenticate-method="#{login.authenticate}" remember-me="false"/>
 		
 		<mail:mail-session host="mailhost.companydomaingoeshere.com" />
 </components>


The web.xml:
Code:
<?xml version="1.0"?>
 	<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 		xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 		
  	<!-- Facelets development mode (disable in production) -->
  	<context-param>
   		<param-name>facelets.DEVELOPMENT</param-name>
   		<param-value>false</param-value>
  	</context-param>
  	
  	<!-- JSF -->
  	<context-param>
  		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  		<param-value>server</param-value>
  	</context-param>
 
  	<context-param>
   		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
   		<param-value>.xhtml</param-value>
  	</context-param>
  	
  	<context-param>
   		<param-name>com.icesoft.faces.actionURLSuffix</param-name>
   		<param-value>.seam</param-value>
  	</context-param>
  	<context-param>
  		<param-name>com.icesoft.faces.synchronousUpdate</param-name>
  		<param-value>false</param-value>
  	</context-param>
  	<context-param>
  		<param-name>com.icesoft.faces.doJSFStateManagement</param-name>
  		<param-value>true</param-value>
  	</context-param>
  	<context-param>
  		<param-name>com.icesoft.faces.standardRequestScope</param-name>
  		<param-value>true</param-value>
  	</context-param>
  	
  	<context-param>
  		<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
  		<param-value>false</param-value><!-- TODO: Was true before -->
  	</context-param>
  	
  	<filter>
  		<filter-name>Seam Filter</filter-name>
  		<filter-class>org.jboss.seam.web.SeamFilter</filter-class>
  	</filter>
  	<filter-mapping>
  		<filter-name>Seam Filter</filter-name>
  		<url-pattern>/*</url-pattern>
  	</filter-mapping>
  	
  	<listener>
  		<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
  	</listener>
  	
  	<listener>
  		<listener-class>com.icesoft.faces.util.event.servlet.ContextEventRepeater</listener-class>
  	</listener>
  	
  	<!-- <servlet>
  		<servlet-name>Seam Resource Servlet</servlet-name>
  		<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
  	</servlet>
  	<servlet-mapping>
  		<servlet-name>Seam Resource Servlet</servlet-name>
  		<url-pattern>/seam/resource/*</url-pattern>
  	</servlet-mapping> -->
  	
  	<servlet>
  		<servlet-name>Faces Servlet</servlet-name>
  		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  		<load-on-startup>1</load-on-startup>
  	</servlet>
  	
  	<servlet>
  		<servlet-name>Persistent Faces Servlet</servlet-name>
  		<servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
  		<load-on-startup>1</load-on-startup>
  	</servlet>
  	<servlet-mapping>
  		<servlet-name>Persistent Faces Servlet</servlet-name>
  		<url-pattern>*.seam</url-pattern>
  	</servlet-mapping>
  	<servlet-mapping>
  		<servlet-name>Persistent Faces Servlet</servlet-name>
  		<url-pattern>/inc/mail_developerAndValidator.xhtml</url-pattern>
  	</servlet-mapping>
  	<servlet-mapping>
  		<servlet-name>Persistent Faces Servlet</servlet-name>
  		<url-pattern>/xmlhttp/*</url-pattern>
  	</servlet-mapping>
  	
  	<servlet>
  		<servlet-name>Blocking Servlet</servlet-name>
  		<servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
  		<load-on-startup>1</load-on-startup>
  	</servlet>
  	<servlet-mapping>
  		<servlet-name>Blocking Servlet</servlet-name>
  		<url-pattern>/block/*</url-pattern>
  	</servlet-mapping>
  	
  	<servlet>
  		<servlet-name>uploadServlet</servlet-name>
  		<servlet-class>com.icesoft.faces.component.inputfile.FileUploadServlet</servlet-class>
  		<load-on-startup>1</load-on-startup>
  	</servlet>
  	<servlet-mapping>
  		<servlet-name>uploadServlet</servlet-name>
  		<url-pattern>/uploadHtml</url-pattern>
  	</servlet-mapping>
 
  	<servlet>
 		<servlet-name>fileServlet</servlet-name>
 		<servlet-class>com.idsscheer.ares.FileServlet</servlet-class>
 		<load-on-startup>1</load-on-startup>
 	</servlet>
 	<servlet-mapping>
 		<servlet-name>fileServlet</servlet-name>
 		<url-pattern>/downloadFile</url-pattern>
 	</servlet-mapping>
  	
  	<session-config>
  		<session-timeout>5</session-timeout>
  	</session-config>
  </web-app>


As you can see, I already tried to map the Persistent Faces Servlet to the mail template. The mail template is here:

Code:
<ui:repeat value="#{statisticsToMail}" var="statistics_var"
 		xmlns="http://www.w3.org/1999/xhtml"
     	xmlns:m="http://jboss.com/products/seam/mail"
     	xmlns:ui="http://java.sun.com/jsf/facelets"
 		xmlns:h="http://java.sun.com/jsf/html"
 		xmlns:f="http://java.sun.com/jsf/core">
 	<m:message importance="high">
   
     	<m:from name="#{user.name}" address="#{user.email}" />
     	<m:to name="#{statistics_var.user.name}">#{statistics_var.user.email}</m:to>
     	<m:subject>Ares validates/errors are available for you</m:subject>
     
 	    <m:body>
     	    <p><h:outputText value="Hello #{statistics_var.user.name}," /></p>
     	    
     	    <p>
     	    	<h:outputText value="Ares shows that there are some" />
     	    	<h:outputText value=" validates " rendered="#{statistics_var.sendVaildatorMail and !statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value=" errors " rendered="#{!statistics_var.sendVaildatorMail and statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value=" validates and errors " rendered="#{statistics_var.sendVaildatorMail and !statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value="you have to do:" />
     	    </p>
     	    
     	    <ul>
     	    	<li>
     	    		<h:outputText value="#{statistics_var.testactionsToValidate}" />
     	    		<h:outputText value=" validates" />
     	    	</li>
     	    	<li>
     	    		<h:outputText value="#{statistics_var.errorsToBugfix}" />
     	    		<h:outputText value=" errors" />
     	    	</li>
     	    </ul>
     	    
         	<p><h:outputText value="Please check Ares." /></p>
         	 
         	<p><h:outputText value="Regards" /></p>
         	<p><h:outputText value="Hello #{statistics_var.user.name}," /></p>
         
         	<f:facet name="alternative">
         		<h:outputText value="Hello #{statistics_var.user.name}," />
         		
     	    	<h:outputText value="Ares shows that there are some" />
     	    	<h:outputText value=" validates " rendered="#{statistics_var.sendVaildatorMail and !statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value=" errors " rendered="#{!statistics_var.sendVaildatorMail and statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value=" validates and errors " rendered="#{statistics_var.sendVaildatorMail and !statistics_var.sendDeveloperMail}" />
     	    	<h:outputText value="you have to do:" />
     	    
     	    	<h:outputText value="- #{statistics_var.testactionsToValidate}" rendered="#{statistics_var.sendVaildatorMail}" />
    	    		<h:outputText value=" validates" rendered="#{statistics_var.sendVaildatorMail}" />
    	    		<h:outputText value="#{statistics_var.errorsToBugfix}" rendered="#{statistics_var.sendDeveloperMail}" />
    	    		<h:outputText value=" errors" rendered="#{statistics_var.sendDeveloperMail}" />
     	    
         		<h:outputText value="Please check Ares." />
         	 
         		<h:outputText value="Regards" />
         		<h:outputText value="Hello #{statistics_var.user.name}," />
 			</f:facet>
     	</m:body>
 	</m:message>
 </ui:repeat>


Thank you
Newlukai
Newlukai

Joined: 29/11/2006 00:00:00
Messages: 125
Offline


The reason for my problem is simple. DOMResponseWriter tries to cast the context to a BridgeFacesContext, which fails, since the context is a MailFacesContextImpl.

Code:
public DOMResponseWriter(FacesContext context, DOMSerializer serializer, Configuration configuration, Collection jsCode, Collection cssCode) {
         this.serializer = serializer;
         this.configuration = configuration;
         this.jsCode = jsCode;
         this.cssCode = cssCode;
         try {
             this.context = (BridgeFacesContext) context;
         } catch (ClassCastException e) {
             throw new IllegalStateException(
                     "ICEfaces requires the PersistentFacesServlet. " +
                             "Please check your web.xml servlet mappings");
         }
         boolean streamWritingParam = configuration.getAttributeAsBoolean("streamWriting", false);
         isStreamWritingFlag = Beans.isDesignTime() || streamWritingParam;
     }


I'll see if I can figure out, what I'm doing wrong. Anyone using the AsynchronousIceFacesMailProcessor should get this error ... :S
Newlukai

Joined: 29/11/2006 00:00:00
Messages: 125
Offline


Ahhh. I got it. As soon as I introduce an <h:outputText /> I get this error. Is it possible to fix this?
gstacey

Joined: 11/07/2007 00:00:00
Messages: 18
Offline


Did you download the latest version (about halfway down this page)? One of the earlier versions had a bug like you are describing...
Newlukai

Joined: 29/11/2006 00:00:00
Messages: 125
Offline


I downloaded the version from JIRA attached to the mentioned issue. Is it possible to use <h:outputText>? I would really like to use the render attributes.
 
Forum Index -> JBoss Seam Integration Go to Page: 1, 2, 3 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team