5 Replies Latest reply on Feb 19, 2011 3:09 PM by Nicklas Karlsson

    Problem with Weld on JBoss6

    Benjamin Seyinbour Expert

      Hello JBoss World,


      Does Weld(CDI)  work in JBoss6? I have had no success.


      Using: Eclipse (helios), JBoss 6 Final, Vaadin(GWT)


      1. When a bean is supposedly [#1 below] Injected or [#2 below] fired, the exception report returns NullPointerException.

      2. Also, [#3 below] @PostContruct does not seem to work.

      3. "beans.xml” is under my /WEB-INF/

      4. Using Vaadin and not JSF


      What am I missing? Please help; and thank you. BTW I am new to Weld.


      Here is some code:




      public class DetailUserModel implements Serializable{

      private static final long serialVersionUID = -5665185499101464321L;




      protected Event<DataConstraintEvent> dataConstraintEvent;

      private UserDetails userDetails;

      public DetailUserModel(){




      public DetailUserModel(UserDetails userDetails){



        this.userDetails = userDetails;



      [#3] @PostConstruct

      protected void initDataConstraint() {


      DataConstraintData dataConstraintData = new DataConstraintData();



      [#2] dataConstraintEvent.fire(new DataConstraintEvent(DataConstraintEvent.FETCH, dataConstraintData));

      } catch (Exception e) {






        • 1. Problem with Weld on JBoss6
          Nicklas Karlsson Master

          Do you see the WELD starup in the logs?

          What is the complete stack trace? I have no idea how the lifecycle of Vaadin works so I don't know when the sessionscontext is bootstrapped but that should be something with BeanStores in the stacktrace (the proxy should still be there)

          • 2. Problem with Weld on JBoss6
            Benjamin Seyinbour Expert

            Hi Nicklas Karlsson,


            Thanks for your response. I need to use @PostConstruct to allow beans and events time to be injected before using them. Now, without using @PostConstruct on initDataConstraint() and instead using initDataConstraint() either in the class constructor -- a futile attempt --, or outside the constructor, I always receive NullPointerException at [#2]. Further dissection revealed the culprit to be "dataConstraintEvent.fire" and not from any of its arguments.


            Vaadin is just Java and I think it is innocent here, as I had no problem with it nor with @PostConstruct prior to using WELD. It seems the problem I am having inside @PostConstruct comes from the fact that no bean or event is injected, hence the NullPointerException. I wonder if Apache openwebbeans has the same problem?


            From what I can see in the server.log, WELD is started. BTW I am now using JBoss-6 latest snapshoot but the outcome is still the same. Thanks and here is the stacktrace:



            Vaadin is running in DEBUG MODE.

            Add productionMode=true to web.xml to disable debug features.

            To show debug window, add ?debug to your application URL.


            09:07:19,242 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/myProjWeb].[MyProj Application]] Servlet.service() for servlet MyProj Application threw exception: java.lang.NullPointerException

            at com.xxxxxx.myProj.web.app.DetailUserModel.init(DetailUserModel.java:91) [:]

            at com.vaadin.Application.start(Application.java:554) [:6.5.1]

            at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1182) [:6.5.1]

            at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:466) [:6.5.1]

            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]

            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:]

            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]

            at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.1.0-SNAPSHOT]

            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:]

            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:]

            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:]

            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:]

            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0-SNAPSHOT]

            at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

            at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0-SNAPSHOT]

            at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0-SNAPSHOT]

            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:]

            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:]

            at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0-SNAPSHOT]

            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:]

            at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0-SNAPSHOT]

            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:]

            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:]

            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:]

            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:]



            • 3. Problem with Weld on JBoss6
              Nicklas Karlsson Master



              @Inject BeanManager bm, it that injected?

              • 4. Problem with Weld on JBoss6
                Benjamin Seyinbour Expert

                Hi Nicklas Karlsson,


                Thanks ago, but as I confessed earlier, I am new to the world of WELD.  I have just realised that there are two BeanManager classes:


                javax.enterprise.inject.spi.BeanManager and




                But I am taking my chances with the former; and I did:


                @Inject BeanManager bm,


                and then:


                bm.notify(); // Just for test


                but again, I received java.lang.NullPointerException.




                • 5. Problem with Weld on JBoss6
                  Nicklas Karlsson Master

                  Hmm. It's just as if it wouldn't recognize it to be a CDI bean archive. And you are 100% sure you have beans.xml in WEB-INF? If you raise the level to debug, can you see Weld list your classes?