2

I use the @Startup annotation to set entry point on the deploying process in EJB, but it does not work. See code example below:

@Singleton
@Startup
public class SchedulerManager {

    private static Logger log = Logger.getLogger(SchedulerManager.class);

    @PostConstruct
    public void atStartup() {
       System.out.println("stutrup!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }
}

I'm using JBoss5.1.0

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

Please, give me suggestion what I'm doing wrong.

Thanks! Artem

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Tioma
  • 2,120
  • 9
  • 35
  • 52

1 Answers1

6

The @Startup annotation is part of ejb 3.1 / jee6 while jboss 5 only implements jee5. You would have to switch to jboss 6 to use it.

Edit: An alternative might be to implement the contextInitialized method of a ServletContextListener, which can be declared in web.xml like this:

<listener>
    <listener-class>package.ListenerClassName</listener-class>
</listener>
Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
  • Thanks to advance. Maybe you know solution how I can call method on startup stage? only plz take into account I have not web part and only ejb project. – Tioma Mar 10 '11 at 12:24
  • Unfortunately I can not use JBoss 6. There are error for my project. And solution for this 6.0.1 version where would fix. – Tioma Mar 10 '11 at 12:26
  • So far, the alternative is working for me. but then Jorn, can you help me at this one: http://stackoverflow.com/questions/8570129/singleton-startup-postconstruct-doesnt-work-on-ejb3-1-and-glassfishv3-0-1 – Mark Joseph Del Rosario Dec 20 '11 at 06:11