Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Neded Help in EJB3.0 timers

 
Deepti Guduru
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Iam writing a simple EJB application.Persisting into the database and listing the values from the database.i am using ejb3 timer service to get to know how it works.Iam getting an error like

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:jar=ejbEntity2.jar,name=ConsumerrStateless,service=EJB3
State: FAILED
Reason: java.lang.RuntimeException: Error creating callback handler for bean C
onsumerrStateless
I Depend On:
persistence.units:jar=ejbEntity2.jar,unitName=ejbEntity2


My stateless bean is:

import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;

import javax.ejb.Stateless;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.SessionContext;


@Stateless
public class ConsumerrStateless implements ConsumerejbEntityBeanInterface {
@PersistenceContext(unitName="ejbEntity2")
private EntityManager em;
int x = 60;
public static final String RemoteJNDIName = ConsumerrStateless.class.getSimpleName() +"/remote";

@Resource
private SessionContext ctx;

public void startTimer() {

ctx.getTimerService().createTimer(2*60*1000, 2*60*1000, null);

System.out.println("Timers set");

}


@Timeout
public void test()
{

Consumer c = new Consumer();
//c.setAge(10);
c.setAge(x);
c.setName("www");
c.setSignupdate(new Date());
System.out.println("EM: " + em);

em.persist(c);
x = x+1;

System.out.println("list some values");
Date Starttime = new Date();
Date EndTime = new Date();
List somevalues = em.createQuery(" from Consumer c where c.signupdate >= :st and c.signupdate <= :et").setParameter("st",Starttime ).setParameter("et", EndTime).getResultList();
for (Iterator iter = somevalues.iterator(); iter.hasNext()
{
Consumer element = (Consumer) iter.next();
System.out.println("age: " + element.getAge() + "NAME:" + element.getName() +"signupdate:"+ element.getSignupdate());
}
}





}


Please help me.


Thanks,
Deepthi.
 
Meiyappan Kannappa
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the Entire Exception stack trace and persistence.xml , Hope the problem might be in persistence.xml file.

For details about TimerService in EJB3.... visit the following link
http://intricatetips.blogspot.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic