Umar Iqbal
Umar Iqbal

Reputation: 689

EJB 3.x deployment on JBOSS AS 7.1.1

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.

Upvotes: 0

Views: 232

Answers (1)

Nicola
Nicola

Reputation: 2976

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());     
    }
}

Upvotes: 1

Related Questions