4 Replies Latest reply on Oct 4, 2012 5:19 AM by Ales Justin

    visibility of CDI beans between deployment units

    Peter Fry Newbie

      I am using JBoss 7.1.Final and have an ear file with a number of jar files in the lib directory.

       

      One of these jar files in the lib directory has a beans.xml file in the META-INF directory and contains a class that produces beans i.e.

       

      app1.ear/lib/containsproducer.jar

      app1.ear/lib/containsproducer.jar/META-INF/beans.xml

       

      This producer can be resolve injection points in ejb archives of the ear file as well as other jar files in the lib directory of the jar archive i.e.

       

      app1.ear/ejb_archive.jar

      app1.ear/lib/anotherlibrary.jar

       

      I also have a webservices WAR file deployed with a beans.xml file in the WEB-INF directory.

       

      webapp1.war/WEB-INF/beans.xml

       

      The WAR file has a dependency on the EAR file deployment unit via the manifest.mf file in the WAR file.

       

      webapp1.war/META-INF/manifest.mf

       

      My question:

       

      Should I be able to inject beans from the producer located in

       

      app1.ear/lib/containsproducer.jar

       

      into

       

      webapp1.war        ??????

       

      currently this does not work.

       

      Is the recommended work around to simply create a duplicate producer located in the WAR file or is there something fancy I can do in the beans.xml of the WAR file?

        • 1. Re: visibility of CDI beans between deployment units
          Ales Justin Master

          This should work.

           

          But it could be that only today's :-) commit fixed this for good,

          as this was a random/order-dependant bug which slipped by us for a long time.

           

          Can you try latest Weld upstream master?

          * https://github.com/weld/core

           

          (simply build the project = mvn clean install, and replace the weld-core.jar in AS)

          • 2. Re: visibility of CDI beans between deployment units
            Peter Fry Newbie

            [ERROR] COMPILATION ERROR :
            [INFO] -------------------------------------------------------------
            [ERROR] \Projects\OPEN_ACCESS\weld-core-1.1.6.Final-106-g7437a60\weld-core-7437a60\impl\src\main\java\org\jboss\weld\introspector\jlr\WeldClassImpl.java:[604,31] type parameters of <T>T cannot be det
            rmined; no unique maximal instance exists for type variable T with upper bounds S,java.lang.Object

            [ERROR] \Projects\OPEN_ACCESS\weld-core-1.1.6.Final-106-g7437a60\weld-core-7437a60\impl\src\main\java\org\jboss\weld\bean\proxy\DecorationHelper.java:[67,48] type parameters of <T>T cannot be determi
            ed; no unique maximal instance exists for type variable T with upper bounds T,java.lang.Object

            [INFO] 2 errors
            [INFO] -------------------------------------------------------------
            [INFO] ------------------------------------------------------------------------
            [INFO] Reactor Summary:
            [INFO]
            [INFO] Weld: Build Configuration ......................... SUCCESS [2.419s]
            [INFO] Weld Parent ....................................... SUCCESS [1.311s]
            [INFO] Weld Implementation ............................... FAILURE [3.432s]
            [INFO] Weld Integration Tests - JBoss Test Harness (JBoss AS)  SKIPPED
            [INFO] Weld Porting Package for the CDI TCK .............. SKIPPED
            [INFO] Weld Integration Tests (JBoss AS) ................. SKIPPED
            [INFO] AtInject TCK runner for Weld ...................... SKIPPED
            [INFO] CDI TCK runner for Weld (JBoss AS) ................ SKIPPED
            [INFO] Weld SE (Core) .................................... SKIPPED
            [INFO] Weld SE (Uber Jar) ................................ SKIPPED
            [INFO] Weld Servlet Parent ............................... SKIPPED
            [INFO] Weld Servlet Core ................................. SKIPPED
            [INFO] Weld Servlet (Uber Jar) ........................... SKIPPED
            [INFO] Weld Servlet Integration Tests (Base) ............. SKIPPED
            [INFO] Weld Servlet Integration Tests (Tomcat) ........... SKIPPED
            [INFO] Weld Servlet Integration Tests (Tomcat7) .......... SKIPPED
            [INFO] Weld Servlet Integration Tests (Jetty) ............ SKIPPED
            [INFO] Weld Servlet Integration Tests (Jetty7) ........... SKIPPED
            [INFO] ------------------------------------------------------------------------
            [INFO] BUILD FAILURE
            [INFO] ------------------------------------------------------------------------
            [INFO] Total time: 7.817s
            [INFO] Finished at: Thu Sep 27 16:17:17 BST 2012
            [INFO] Final Memory: 26M/63M
            [INFO] ------------------------------------------------------------------------
            [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project weld-core: Compilation failure: Compilation failure:
            [ERROR] \Projects\OPEN_ACCESS\weld-core-1.1.6.Final-106-g7437a60\weld-core-7437a60\impl\src\main\java\org\jboss\weld\introspector\jlr\WeldClassImpl.java:[604,31] type parameters of <T>T cannot be det
            rmined; no unique maximal instance exists for type variable T with upper bounds S,java.lang.Object
            [ERROR]
            [ERROR] \Projects\OPEN_ACCESS\weld-core-1.1.6.Final-106-g7437a60\weld-core-7437a60\impl\src\main\java\org\jboss\weld\bean\proxy\DecorationHelper.java:[67,48] type parameters of <T>T cannot be determi
            ed; no unique maximal instance exists for type variable T with upper bounds T,java.lang.Object
            [ERROR] -> [Help 1]
            [ERROR]
            [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
            [ERROR] Re-run Maven using the -X switch to enable full debug logging.
            [ERROR]
            [ERROR] For more information about the errors and possible solutions, please read the following articles:
            [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
            [ERROR]
            [ERROR] After correcting the problems, you can resume the build with the command
            [ERROR]   mvn <goals> -rf :weld-core

             

            Version of Java is 1.6.0_23, do you have the issue number - I might be able to take a recent binary build?

            • 3. Re: visibility of CDI beans between deployment units
              Peter Fry Newbie

              Ales,

               

              Can you provide the bug number so I can track which build of weld fixes it?

               

              I think my compilation error when trying to build the snap shot is due to a bug in the version of the JDK that I am using.

               

              Peter.

              • 4. Re: visibility of CDI beans between deployment units
                Ales Justin Master

                It's gonna be in next 1.1.10.Final release.