Skip to main content

[FishCAT] CDI 1.1: How to exclude an archive from scanning?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
Anonymous

Does GlassFish 4.0 or Weld 2.0 offer an option to prevent an archive
from being scanned for managed beans?

CDI 1.1 section 12.1 only states:

"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."

I'm having problems with a web app containing guava-14.0.jar in
WEB-INF/lib which has a class annotated with javax.inject.Singleton, so
it gets treated as an implicit bean archive, which causes an exception.

Best regards,
Harald

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Harald Wellmann

Digging in the sources, I found this new setting for domain.xml that
seems to be doing the trick:

Best regards,
Harald

Am 05.05.2013 22:02, schrieb Harald Wellmann:
> Does GlassFish 4.0 or Weld 2.0 offer an option to prevent an archive
> from being scanned for managed beans?
>
> CDI 1.1 section 12.1 only states:
>
> "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."
>
> I'm having problems with a web app containing guava-14.0.jar in
> WEB-INF/lib which has a class annotated with javax.inject.Singleton, so
> it gets treated as an implicit bean archive, which causes an exception.
>
> Best regards,
> Harald
>
>

Tom Snyder

Hi Harald,

Please be aware the enable-implicit-cdi config setting turns off implicit scanning for all archives in the entire server. If you want to do it per archive, you can add a beans.xml with a bean-discovery-mode of none.

Hope this helps,

- Tom

On May 6, 2013, at 1:00 PM, Harald Wellmann wrote:

> Digging in the sources, I found this new setting for domain.xml that seems to be doing the trick:
>
>
>
> Best regards,
> Harald
>
>
> Am 05.05.2013 22:02, schrieb Harald Wellmann:
>> Does GlassFish 4.0 or Weld 2.0 offer an option to prevent an archive
>> from being scanned for managed beans?
>>
>> CDI 1.1 section 12.1 only states:
>>
>> "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."
>>
>> I'm having problems with a web app containing guava-14.0.jar in
>> WEB-INF/lib which has a class annotated with javax.inject.Singleton, so
>> it gets treated as an implicit bean archive, which causes an exception.
>>
>> Best regards,
>> Harald
>>
>>
>

Harald Wellmann

Tom, I can't add a beans.xml to a third-party JAR. That's why I use the
global switch, which works fine in my case.

Of course 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.

Best regards,
Harald

2013/5/6 Tom Snyder

> Hi Harald,
>
> Please be aware the *enable-implicit-cdi* config setting turns off
> implicit scanning for all archives in the entire server. If you want to do
> it per archive, you can add a beans.xml with a bean-discovery-mode of none.
>
> Hope this helps,
>
> - Tom
>
> On May 6, 2013, at 1:00 PM, Harald Wellmann
> wrote:
>
> Digging in the sources, I found this new setting for domain.xml that seems
> to be doing the trick:
>
>
>
> Best regards,
> Harald
>
>
> Am 05.05.2013 22:02, schrieb Harald Wellmann:
>
> Does GlassFish 4.0 or Weld 2.0 offer an option to prevent an archive
> from being scanned for managed beans?
>
> CDI 1.1 section 12.1 only states:
>
> "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."
>
> I'm having problems with a web app containing guava-14.0.jar in
> WEB-INF/lib which has a class annotated with javax.inject.Singleton, so
> it gets treated as an implicit bean archive, which causes an exception.
>
> Best regards,
> Harald
>
>
>
>
>