glassfish
  1. glassfish
  2. GLASSFISH-20483

Enable and disable implicit scanning per JAR.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1
    • Component/s: cdi
    • Labels:
      None

      Description

      beans.xml cannot be added to a third-party JAR. Disabling implicit CDI is one option but but it works at the application level.

      This will not work when different third-party JARs make different assumptions about implicit beans. So it would be helpful if GlassFish (or Weld) offered a way to enable or disable implicit scanning per JAR.

        Activity

        jjsnyder83 created issue -
        Hide
        jjsnyder83 added a comment -

        According to 12.1 of CDI spec:
        "For compatibility with Contexts and Dependency 1.0, products must contain an option to cause an archive to be ignored by the container when no beans.xml is present."

        We are probably a little light in our implementation of this as we only allow entire apps to be enabled/disabled for implicit scanning.

        Show
        jjsnyder83 added a comment - According to 12.1 of CDI spec: "For compatibility with Contexts and Dependency 1.0, products must contain an option to cause an archive to be ignored by the container when no beans.xml is present." We are probably a little light in our implementation of this as we only allow entire apps to be enabled/disabled for implicit scanning.
        phil.zampino made changes -
        Field Original Value New Value
        Assignee jjsnyder83 [ jjsnyder83 ] phil.zampino [ phil.zampino ]
        Hide
        aaronjwhiteside added a comment -

        Related to GLASSFISH-20579. It would be good if this was part of the final 4.0.0 release. Perhaps something in glassfish-web.xml?

        Show
        aaronjwhiteside added a comment - Related to GLASSFISH-20579 . It would be good if this was part of the final 4.0.0 release. Perhaps something in glassfish-web.xml?
        Hide
        aaronjwhiteside added a comment -

        http://docs.jboss.org/weld/reference/latest/en-US/html/configure.html

        This doesn't work as far as I can tell.

        Maybe fixing the WELD integration so that this works is the solution?

        Show
        aaronjwhiteside added a comment - http://docs.jboss.org/weld/reference/latest/en-US/html/configure.html This doesn't work as far as I can tell. Maybe fixing the WELD integration so that this works is the solution?
        Hide
        aaronjwhiteside added a comment -

        I can add a beans.xml as per the CDI 1.1 spec, but that does not appear to work either.

        CDI 1.1 Spec, Section 12.1
        bean-discovery-mode="none" should disable an archives contents from being considered by CDI.

        Show
        aaronjwhiteside added a comment - I can add a beans.xml as per the CDI 1.1 spec, but that does not appear to work either. CDI 1.1 Spec, Section 12.1 bean-discovery-mode="none" should disable an archives contents from being considered by CDI.
        Hide
        phil.zampino added a comment -

        The cited beans.xml addition should work. If it is being applied correctly, and Glassfish is not honoring it, then that's a bug. Can you provide an application to reproduce this behavior?

        Additionally, there is a new deployment property that will disable support for implicit bean archives at the application level. (asadmin deploy --property implicitCdiEnabled=false <archive file>)

        Show
        phil.zampino added a comment - The cited beans.xml addition should work. If it is being applied correctly, and Glassfish is not honoring it, then that's a bug. Can you provide an application to reproduce this behavior? Additionally, there is a new deployment property that will disable support for implicit bean archives at the application level. (asadmin deploy --property implicitCdiEnabled=false <archive file>)
        phil.zampino made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        phil.zampino made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Romain Grécourt made changes -
        Fix Version/s 4.1 [ 16387 ]
        Fix Version/s 4.0.1 [ 16061 ]
        Hide
        everett_toews added a comment -

        How exactly was this resolved?

        bean-discovery-mode="none" does work for me but this issue is for disabling implicit scanning per JAR.

        To disable scanning per JAR I tried the following beans.xml and it didn't work for me. I continue to get WELD errors.

        <beans xmlns="http://java.sun.com/xml/ns/javaee" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:weld="http://jboss.org/schema/weld/beans" 
               xsi:schemaLocation="
                  http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
                  http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
            <weld:scan>
                <weld:exclude name="org.jclouds.**" />
            </weld:scan>
        </beans>
        

        Should this beans.xml work with Glassfish 4.1?

        Can someone provide an example of a beans.xml file that excludes per JAR that does work?

        Thanks.

        Show
        everett_toews added a comment - How exactly was this resolved? bean-discovery-mode="none" does work for me but this issue is for disabling implicit scanning per JAR. To disable scanning per JAR I tried the following beans.xml and it didn't work for me. I continue to get WELD errors. <beans xmlns= "http://java.sun.com/xml/ns/javaee" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:weld = "http://jboss.org/schema/weld/beans" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd"> <weld:scan> <weld:exclude name= "org.jclouds.**" /> </weld:scan> </beans> Should this beans.xml work with Glassfish 4.1? Can someone provide an example of a beans.xml file that excludes per JAR that does work? Thanks.
        Hide
        everett_toews added a comment -

        Just to be clear, I put that beans.xml file in the web app WEB-INF dir.

        Show
        everett_toews added a comment - Just to be clear, I put that beans.xml file in the web app WEB-INF dir.

          People

          • Assignee:
            phil.zampino
            Reporter:
            jjsnyder83
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: