4 Replies Latest reply on Feb 25, 2011 10:47 AM by jaikiran

    WELD-CDI EAR AND WAR

    jgautier

      Hi,

       

      My problem has to deal with CDI and application packaging in JBoss 6.0.0..Final.

      Furthermore, I've got an ear with the following structure:

       

      my.ear

           |-->mywebapp1.war

                     |-->WEB-INF

                          |-->beans.xml

                          |-->classes

                               |-->mypackage1 containing backing beans.

           |-->mywebapp2.war

                     |-->WEB-INF

                          |-->beans.xml

                          |-->classes

                               |-->mypackage2 containing backing beans.

       

       

      My problem is that even if I don't have any deployment problem with this ear, my backing beans in mywebapp2.war are not visible (deployed ?).

      Indeed, I'm able to retrieve backing beans references from mywebapp1 but not from mywebapp2 (using getReference() from BeanManager).

      Surprisingly, when only one webapp is deployed in my.ear (mywebapp2.war or mywebapp1.war), everything works !

      So my question is: why would WELD scan annotations in only one war and not two or n wars within an ear ?

       

      Jérome

        • 1. WELD-CDI EAR AND WAR
          nickarls

          So you mean war2 beans are not visible from e.g pages within war2 itself? Check the WELD JIRA if there it's a known issues and file a new one if you can't find any matches, please.

          • 2. WELD-CDI EAR AND WAR
            jgautier

            Correct, war2 backing beans are not visible within war2.

            I'm unable to lookup a contextual reference for a mypackage2 bean from a class located in mypackage2.

            JIRA jbas-8683 looks related but does not explain the problem completly, I'm still searching in JIRA

            • 3. Re: WELD-CDI EAR AND WAR
              jgautier

              Downloading jboss6 sources and debugging helped, the problem has to deal with org.jboss.weld.bootstrap.BeanDeployer class.

              Using breakpoints in org.jboss.weld.bootstrap.BeanDeployment confirmed that iterator returned by the loadClasses() method is correct.

              But, when this collection of classes is added to BeanDeployer, the following code snippet throws an exception (addClass method)

               

                    Class<?> clazz = null;

                    try

                    {

                       clazz = resourceLoader.classForName(className);

                    }

                    catch (ResourceLoadingException e)

                    {

                       log.debug(IGNORING_CLASS_DUE_TO_LOADING_ERROR, className);

                       xlog.catching(DEBUG, e);

                    }

               

              Inspecting beanmanager instance properties showed me that the wrong ResourceLoader is in use.

              Surprisingly, the BaseClassLoader of mywebapp1.war is used in a BeanDeployment instance of mywebapp2.war.


              Any idea why one classloder is used for loading classes in BeanDeployment.loadClasses() method and another one in BeanDeployer constructor ?

               

              Jérôme



              • 4. WELD-CDI EAR AND WAR
                jaikiran

                Please file a JIRA for this here https://jira.jboss.org/browse/JBAS