0
votes

I'm trying to create an ejb timer and successful to do so but however unable to deploy it successfully. I'm using ejb timer first time so I might not be doing it right. so kindly if someone guides me in the right direction. Thank you

followed the tutorial from http://www.adam-bien.com/roller/abien/entry/simplest_possible_ejb_3_16

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;

@Stateless
public class ScheduleRoutine {

/**
 * Default constructor. 
 */
public ScheduleRoutine() {
    // TODO Auto-generated constructor stub
}

@Schedule(second="*/1", minute="*",hour="*", persistent=false)
public void scheduledTimeout(final Timer t) {
    System.out.println("@Schedule called at: " + new java.util.Date());     
}
}

This is the code I'm using I think there's no problem with it. I'm using JBoss AS 7.1.1 with eclipse and all I'm doing is 'run on server' it runs but it's unable to display the output as it is supposed to.

EDIT :(Solution)

It didn't work when i tried to run it from eclipse but then i tried exporting the jar manually then it was deployed successfully.

1
so have you checked what is the error message when deploying? we're not mind-readers. you could add info about your deployment module as well, how are you deploying it.eis
Well it didn't work when i tried to run it from eclipse but then i tried exporting the jar manually then it was deployed successfully.Umar Iqbal
did you have JBoss AS7 support (JBoss Tools) installed in your Eclipse?eis
Yes of course, that's why i couldn't figure it out.Umar Iqbal
so what do you see on the logs when you try it?eis

1 Answers

1
votes

I had the same problem with jboss 7.1. To solve the problem I added a stub method to my ejb and annotated it with @Timeout

@Timeout
public void stub(){
   // NOOP
}

Also changed @Stateless to @Singleton and @Startup so your code would look like the following:

import javax.ejb.Schedule;
import javax.ejb.Startup;
import javax.ejb.Timer;
import javax.ejb.Timeout;

@Singleton
@Startup
public class ScheduleRoutine {

    /**
     * Default constructor. 
     */
    public ScheduleRoutine() {
        // TODO Auto-generated constructor stub
    }

    @Timeout
    public void stub() {
       // NOOP
    }

    @Schedule(second="*/1", minute="*",hour="*", persistent=false)
    public void scheduledTimeout(final Timer t) {
        System.out.println("@Schedule called at: " + new java.util.Date());     
    }
}