[jboss-user] [JBoss Seam] - AsynchronousMailProcessor doesn't work out when it's called

claudiamunevar2 do-not-reply at jboss.com
Mon Oct 22 19:33:06 EDT 2007


Good morning:

I'm developing an email module for an application. The idea is to manage the whole emails in an asynchronous way. I made a test in the same way as in the seam example which calls the MailExample class directly from the xhtml page; but when I try to call the EmailFunction not from the xhml, but from the Action class, it doesn't work. 

Debug shows the following message:
ERROR [TimerServiceImpl] Cannot create txtimer  
java.lang.IllegalStateException: Unable to persist timer

this is the xhtml code:
<h:commandButton value="Enviar Pregunta" action="enviarPregunta" type="submit" />
this is the pageflow code:
<start-page name="formulaPregunta" view-id="/portal/ayuda/formular_pregunta.xhtml">
        
        
        	        	
        
    </start-page>

the method enviarPregunta from the FormularPreguntaEditor Class includes:
public boolean enviarCorreo() {
        EmailFunction cmp = (EmailFunction) Component.getInstance("emailFunction");
	cmp.sendAsynchronous("/portal/ayuda/correo.xhtml");
	return true;
    }

this is the class declaration for EmailFunction:
@Name("emailFunction")
@Scope(ScopeType.CONVERSATION)
public class EmailFunction {

    @In
    protected AsynchronousMailProcessor asynchronousMailProcessor;
    
    @In
    protected Renderer renderer;

    public AsynchronousMailProcessor getAsynchronousMailProcessor() {
        return asynchronousMailProcessor;
    }

    public void setAsynchronousMailProcessor(AsynchronousMailProcessor   asynchronousMailProcessor) {
        this.asynchronousMailProcessor = asynchronousMailProcessor;
    }

    public Renderer getRenderer() {
        return renderer;
    }

    public void setRenderer(Renderer renderer) {
        this.renderer = renderer;
    }

   public void sendAsynchronous(String archivo) {
	asynchronousMailProcessor.scheduleSend(3000, archivo, parametros);
    }
}

Finally, the declaration of AsynchronousMailProcessor class is as follows:
@Name("asynchronousMailProcessor")
@AutoCreate
public class AsynchronousMailProcessor {
     /** Creates a new instance of AsynchronousMailProcessor */
    public AsynchronousMailProcessor() {
	System.out
		.println("entrando al constructor de AsyncronousMailProcessor");
    }

    @Asynchronous
    public void scheduleSend(@Duration
    long delay, String archivo, List parametros) {
	try {
	    Contexts.getEventContext().set("parametros", parametros);
	    Renderer.instance().render(archivo);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4097661#4097661

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4097661



More information about the jboss-user mailing list