简体   繁体   中英

@Startup annotation does not work

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM