3 Replies Latest reply on Sep 16, 2010 8:55 AM by marcelkolsteren

    Extensions not loaded from War file inside EAR

      I have verified the following behavior by creating a simple project.


      I have a war project with following content:




      • empty /WEB-INF/beans.xml




      • /WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension with:



      de.feo.tests.TestExtension





      • class file de.feo.test.TestExtension with:



      package de.feo.tests;
      
      import javax.enterprise.event.Observes;
      import javax.enterprise.inject.spi.AfterBeanDiscovery;
      import javax.enterprise.inject.spi.Extension;
      
      public class TestExtension implements Extension {
          static{
              System.out.println("XXXX CLASS LOADED XXXX");
          }
          public void test(@Observes AfterBeanDiscovery abd) {
              System.out.println("XXXX WORKING XXXX");
          }
      }



      When I deploy this war file on its own, I see the messages.
      When I deploy this project inside an ear, I don't see the messages.


      Is this normal? What is the expected behavior.


      I'm running this in glassfish v3


       

        • 1. Re: Extensions not loaded from War file inside EAR
          marcelkolsteren

          The problem you're experiencing seems to be related to the classloading problems described in JBAS-8355.

          • 2. Re: Extensions not loaded from War file inside EAR

            I believe it is. I have indeed the same problem with interceptors in one of my other tests. Atm, the only part that I can use in war-file embedded in an ear-file is @Inject/@Produces/@Observers.


            Whenever I use @Instance I am limited to what is in that one war/jar/... finding something in an external jar fails
            Whenever I use something that needs configuration in beans.xml it blows up in my face.


            I lost some time developing something in a standalone web project and then finding out that other rules apply when using the same code in an enterprise project.


            In an earfile, CDI is nothing more that an advanced replacement for JSF @ManagedBean and @ManagedProperty.


            I doesn't make me mad as much as it makes me sad to see so much potential go unused. :(


            • 3. Re: Extensions not loaded from War file inside EAR
              marcelkolsteren

              I hope that my reply on your other thread might cheer you up a bit. In fact, when you take into account the visibility rules, CDI in an earfile is just as powerful as it is in the context of a war deployment. Or at least it will be as soon as that JIRA issue is solved. Suggestion: vote for it :-).