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>
精彩评论