[arquillian-issues] [JBoss JIRA] (ARQ-841) Should not scan for classes in Archive if it contains no beans.xml

Karim de Fombelle (JIRA) jira-events at lists.jboss.org
Mon Jan 21 03:31:22 EST 2013


    [ https://issues.jboss.org/browse/ARQ-841?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12749035#comment-12749035 ] 

Karim de Fombelle edited comment on ARQ-841 at 1/21/13 3:30 AM:
----------------------------------------------------------------

Similar issue observed with Arquillian 1.0.3.Final / arquillian-weld-se-embedded-1.1 1.0.0.CR5 / weld-core 1.1.10.Final / Shrinkwrap 2.0.0-alpha-1

Arquillian performs micro deployment in a CDI container, according the container adapter and the container found in the developer classpath.
The deployed content is built in a test class in the method annotated with @Deployment
CDI specification (JSR-299) mentions that the container will scan for "managed bean" only _bean archives_, and those archives must contain a META-INF/bean.xml file
{quote} 12.1. Bean archives
Bean classes of enabled beans must be deployed in bean archives.
• A library jar, EJB jar, application client jar or rar archive is a bean archive if it has a file named beans.xml in the
META-INF directory.
(...)
The container searches for beans in all bean archives in the application classpath
{quote}
However, as illustrated in the test class below, without adding any descriptor, the content of the archive is scanned and beans are managed.
The injection below is successful whereas it is expected the test throws an "UnsatisfiedResolutionException."

Test case below:
{code}
@RunWith(Arquillian.class)
public class BeanXmlArquillianTest {

    //~ ----------------------------------------------------------------------------------------------------------------
    //~ Instance fields 
    //~ ----------------------------------------------------------------------------------------------------------------

    @Inject
    private Bean1 testBean;

    //~ ----------------------------------------------------------------------------------------------------------------
    //~ Methods 
    //~ ----------------------------------------------------------------------------------------------------------------

    @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class).addClass(Bean1.class);
            //.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");//sounds useless
    }

    @Test
    public void testBeanInjected() {
        assertNotNull(testBean);//test is green whereas it should not be
    }

}
{code}
And bean:
{code}
public class Bean1{
}
{code}

The pom is attached.
                
      was (Author: kdefombelle):
    Similar issue observed with Arquillian 1.0.3.Final / arquillian-weld-se-embedded-1.1 1.0.0.CR5 / weld-core 1.1.10.Final / Shrinkwrap 2.0.0-alpha-1

Arquillian performs micro deployment in a CDI container, according the container adapter and the container found in the developer classpath.
The deployed content is built in a test class in the method annotated with @Deployment
CDI specification (JSR-299) mentions that the container will scan for "managed bean" only _bean archives_, and those archives must contain a META-INF/bean.xml file
{quote} 12.1. Bean archives
Bean classes of enabled beans must be deployed in bean archives.
• A library jar, EJB jar, application client jar or rar archive is a bean archive if it has a file named beans.xml in the
META-INF directory.
(...)
The container searches for beans in all bean archives in the application classpath
{quote}
However, as illustrated in the test class below, without adding any descriptor, the content of the archive is scanned and beans are managed.
The injection below is successful whereas it is expected the test throws an "UnsatisfiedResolutionException."

Test case below:
{code}
@RunWith(Arquillian.class)
public class BeanXmlArquillianTest {

    //~ ----------------------------------------------------------------------------------------------------------------
    //~ Instance fields 
    //~ ----------------------------------------------------------------------------------------------------------------

    @Inject
    private Bean1 testBean;

    //~ ----------------------------------------------------------------------------------------------------------------
    //~ Methods 
    //~ ----------------------------------------------------------------------------------------------------------------

    @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class).addClass(Bean1.class);
            //.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");//sounds useless
    }

    @Test
    public void testBeanInjected() {
        assertNotNull(testBean);
    }

}
{code}
And bean:
{code}
public class Bean1{
}
{code}

The pom is attached.
                  
> Should not scan for classes in Archive if it contains no beans.xml
> ------------------------------------------------------------------
>
>                 Key: ARQ-841
>                 URL: https://issues.jboss.org/browse/ARQ-841
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Weld Containers
>    Affects Versions: weld_1.0.0.CR3
>            Reporter: Aslak Knutsen
>              Labels: starter
>             Fix For: weld_1.1.0.next
>
>         Attachments: pom.xml
>
>
> A deployment with no beans.xml should not result in Beans being registered in the Weld Container. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the arquillian-issues mailing list