开发者

Netbeans: Weird weld se behavior

开发者 https://www.devze.com 2023-03-09 08:30 出处:网络
Following the official documentation I implemented a very simple Java SE Weld quickstart class. @Singleton

Following the official documentation I implemented a very simple Java SE Weld quickstart class.

@Singleton
public class TesteCDI {

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

My run configuration fi开发者_C百科res org.jboss.weld.environment.se.StartMain

Here is the funny part. If I don't create the Jar file (clicking in "Clean and Build"), my message isn't printed.

54 [main] INFO org.jboss.weld.Version - WELD-000900 1.1.0 (Final)
110 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
388 [main] WARN org.jboss.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
388 [main] WARN org.jboss.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled

If I do create the Jar file, everything runs fine, both from the command line and from Netbeans. So I assumed Netbeans was running the application from the jar.

The problem is... It isn't.

If I update my Test class and run from Netbeans, it picks the changes. If I run the jar from command line it just prints the old message.

If I clean my project, Netbeans launch configuration stops printing the messsage.

Can anyone explain how exactly is Netbeans running my Application? Does this odd behavior make sense or should it be considered a bug?


I think weld doesn't pick up your annotated components if you forget the META-INF/beans.xml, did you check if there is a META-INF/beans.xml in the classpath?

0

精彩评论

暂无评论...
验证码 换一张
取 消