Running a very simple Weld SE project in Eclipse
Asked Answered
T

1

5

I've been using Seam 2 (also started looking into Java EE 6) in my web apps and a couple of days ago I found out that Seam's CDI can be leveraged in an SE application with Weld. According to Weld's Documentation page for Weld SE the setup is trivial. So I tried to setup an Eclipse project with a single class HelloWeld, weld-se.jar and the log4j jars.

@Singleton
public class HelloWeld
{
    public void printHello(@Observes ContainerInitialized event, @Parameters List<String> parameters)
    {
        System.out.println("Hello Weld!");
    }
}

I created a new Java Application Run Configuration and indicated org.jboss.weld.environment.se.StartMain as the main class. When I ran the project I found out, without any surprise what-so-ever, that HelloWeld was never called. All I got was a few log entries as an indication that Weld booted correctly:

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?

Tranquillize answered 10/8, 2010 at 16:1 Comment(0)
B
7

You need to make it a bean archive. Add an empty META-INF/beans.xml to your classpath.

Brainard answered 10/8, 2010 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.