File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Neded Help in EJB3.0 timers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Neded Help in EJB3.0 timers" Watch "Neded Help in EJB3.0 timers" New topic
Author

Neded Help in EJB3.0 timers

Deepti Guduru
Greenhorn

Joined: May 22, 2008
Posts: 12
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

Joined: Sep 15, 2008
Posts: 10
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


Warm Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Neded Help in EJB3.0 timers