I used Seam 2 (also started learning Java EE 6) in my web applications, and a couple of days ago I found out that Seam CDI can be used in an SE application with Weld. According to the Weld documentation page for Weld SE, the setup is trivial. So I tried to set up an Eclipse project using one HelloWeld class, weld-se.jar and log4j cans.
@Singleton public class HelloWeld { public void printHello(@Observes ContainerInitialized event, @Parameters List<String> parameters) { System.out.println("Hello Weld!"); } }
I created a new configuration for starting Java applications and designated org.jboss.weld.environment.se.StartMain as the main class. When I started the project, I found out, without any surprise, anything that HelloWeld was never called. All I had was a few log entries as an indication of the correct loading of Weld:
11:54:39,397 INFO [weld.Version] WELD-000900 1.0.1 (Final) 11:54:39,428 INFO [weld.Bootstrap] WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously. 11:54:39,944 WARN [model.InterceptionTypeRegistry] Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled 11:54:39,944 WARN [model.InterceptionTypeRegistry] Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
So what am I missing?
source share