[jboss-user] [JBoss Seam] - injecting async method seams to fail ?

dreuzel do-not-reply at jboss.com
Tue Oct 23 08:15:49 EDT 2007


'im sure to do something wrong  but I can not  inject  an async method 
for  one reason or another 
neither  injection does work:

@In(create = true) ProcessingAction processingAction;//Fails

@In("#{processingAction}") ProcessingAction processingAction;/Fails javax.ejb.EJBException: java.lang.IllegalArgumentException: could not set field value: startupManager.#{processingAction}
 @In(create = true) ProcessingAction processingAction;//Fails

The create  method  is successfull as  long as the values are  not injected 



  | 
  | @Startup
  | @Stateful
  | @Scope(ScopeType.APPLICATION)  //application required for  startup
  | @Name("startupManager")        //Name 
  | public class StartupManager implements StartupManagerINTF{ // create Interface
  | 
  | 	@Logger private Log log;
  | 	@In("#{processingAction}") ProcessingAction processingAction;/Fails javax.ejb.EJBException: java.lang.IllegalArgumentException: could not set field value: startupManager.#{processingAction}
  | //    @In(create = true) ProcessingAction processingAction;//Fails
  | 
  | 	private QuartzTriggerHandle handle = null;
  | 
  | 	@Create
  | 	public void create() {
  | 		log.info("create(): called");
  | 		// init
  | 		int delay = 20; // in seconds
  | 		long interval = 1000 * delay;
  | 		Calendar cal = Calendar.getInstance();
  | 		cal.setTime(new Date());
  | 		cal.add(Calendar.SECOND, delay);
  | 		// create Processing
  | 		long processingId=-1;
  | 		if (processingAction!=null)
  | 		{	
  | 		 processingId = processingAction.createProcessing("serverJob");
  | 		// schedule job and save handler
  | 		 this.handle = processingAction.doServerJob(processingId, cal.getTime(), interval);
  | 		}
  | 		log.info("create(): id: #0", processingId);
  | 	}
  | 	
  | 	public QuartzTriggerHandle getHandle() {return this.handle ;}
  | 
  | 	@Remove public void destroy() {
  | 	}
  | }
  | 

injected code :

I tried  starting 
using different scopes  but all remain unsuccessfull

  | @Stateful
  | @Name("processingAction")
  | @Scope(ScopeType.APPLICATION)
  | public class ProcessingAction implements ProcessingActionINTF { // create Interface
  | 
  | 	@Logger private Log log;
  | 
  | 	@In     private EntityManager entityManager;
  |     public ProcessingAction()
  |     {String  Procesaction="Processing action";}
  |     public ProcessingAction ProcessingAction()
  |     {return this;}
  | 	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  | 	public long createProcessing(String string) {
  | 		// create Processing
  | 		ShedJobStatusDB processing = new ShedJobStatusDB();
  | 		String JobId=""+(new Date()).toString()+":"+string;
  | 
  | 		processing.setHandle(JobId);
  | 		processing.setDescription("Startup stared");
  | 		processing.setEnd(new Date());
  | 		processing.setGrp("Startup");
  | 		processing.setId(1);
  | 		processing.setUsr("Nobody");
  | 		processing.setLastReturnValue(string);
  | 		processing.setRun(new Date());
  | 		processing.setStats("Status");
  | 		processing.setRunning(new Date());
  | 		processing.setName("processingAction");
  | 		// managed context
  | 		if (entityManager!=null)
  | 		{
  | 		  entityManager.persist(processing);
  | 		  entityManager.flush();
  | 	    }
  | 		processing.setName("serverJob");
  | 		// return id
  | 		return processing.getId();
  | 	}
  | 
  | 	@Asynchronous
  | 	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  | 	public QuartzTriggerHandle doServerJob(long processingId, @Expiration Date date, @IntervalDuration Long interval)
  | 	{
  | 		log.info("doServerJob(): called");
  | 		// get bean
  | 		ShedJobStatusDB processing = entityManager.find(ShedJobStatusDB.class, processingId);
  | 		// if exists remove
  | 		if (processing != null) {
  | 			entityManager.remove(processing);
  | 			log.info("doServerJob(): removed: id: #0", processingId);
  | 		} else {
  | 			// else stop server job
  | 			try {
  | //	nolink		startupManager.getHandle().cancel();
  | 			} catch (Exception e) {
  | 				log.error("", e);
  | 			}
  | 			log.info("doServerJob(): stopped: id: #0", processingId);
  | 		}
  | 		// return new handle
  | 		return new QuartzTriggerHandle("serverJob");
  | 	}
  | 	
  | 	@Remove
  | 	public void destroy() {
  | 	}
  | }
  | 	




  | import org.jboss.annotation.*;
  | import org.jboss.seam.annotations.datamodel.*;//DataModel;DataModelSelection;
  | import org.jboss.seam.*;
  | import org.jboss.seam.annotations.*;//Factory,Name,In,Out,Scope,Logger,Destroy
  | import org.jboss.seam.contexts.*;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.log.Log;
  | import org.jboss.seam.faces.*;
  | 
  | import javax.persistence.*; //EntityManager;PersistenceContext;
  | import javax.ejb.*;//stateless;stateful,remove
  | 
  | import static javax.persistence.PersistenceContextType.*;
  | import static org.jboss.seam.ScopeType.*;//session
  | 
  | import org.hibernate.validator.*;
  | 
  | 
  | import org.jboss.seam.annotations.Transactional;
  | import org.jboss.seam.annotations.async.*;
  | import org.jboss.seam.annotations.async.Asynchronous;
  | import org.jboss.seam.async.*;
  | import org.quartz.*;
  | import org.jboss.seam.ejb.SeamInterceptor;
  | 
  | 
  | import lib.cyclus.String.*;
  | import com.cycluspro.*;
  | import com.cycluspro.ejb.*;
  | import com.cycluspro.ejb.beurs.*;
  | import com.cycluspro.ejb.common.jobs.*;
  | import com.cycluspro.ejb.common.*;//db 
  | import lib.cycluspro.webaccess.*;
  | import lib.cycluspro.Hibernate.HibernateEntity;
  | import lib.cycluspro.string.*;
  | import lib.cycluspro.string.DateInOut;
  | 
  | import com.cycluspro.beurs.*;
  | import com.cycluspro.beurs.user.AandelenINTF;
  | 
  | import java.util.*; //List;Date;
  | import java.io.*;//Serializable;
  | import java.util.Properties;
  | 
  | 
  | @Local
  | public interface ProcessingActionINTF 
  | {	public ProcessingAction ProcessingAction();
  | 	public long createProcessing(String string);
  | 
  | 	@Asynchronous
  | 	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  | 	public QuartzTriggerHandle doServerJob(long processingId, @Expiration Date date, @IntervalDuration 
  | Long interval) ;
  | 	
  | 	@Remove	public void destroy();
  | }
  | 	



Component async  is set  as well...


please can anyone help

Using seam 2.0.0 CR1
Using  jbos 4.2.1GA

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

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



More information about the jboss-user mailing list