jakartaee / cdi-tck

CDI TCK
Apache License 2.0
46 stars 44 forks source link

Core profile CDI tests use archive without beans.xml #603

Closed arjantijms closed 2 weeks ago

arjantijms commented 2 weeks ago

The test ee.jakarta.tck.core.rest.jsonb.cdi.CustomJsonbSerializationIT in the 10.0.3 core profile TCK creates the following archive:

test archive: CustomJsonbSerializationIT.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/ee/
/WEB-INF/classes/ee/jakarta/
/WEB-INF/classes/ee/jakarta/tck/
/WEB-INF/classes/ee/jakarta/tck/core/
/WEB-INF/classes/ee/jakarta/tck/core/rest/
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/ApplicationResource.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/CustomJsonbResolver.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/CustomJsonbResolver$CustomSerializer.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/CustomJsonbResolver$CustomDeserializer.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/KeysProducer.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/SomeMessage.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/jsonb/cdi/Utils.class
/WEB-INF/classes/ee/jakarta/tck/core/rest/JaxRsActivator.class
/WEB-INF/classes/key.pub

According to https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#bean_archive the beans.xml file is required.

Specifically, Weld Servlet in org.jboss.weld.environment.deployment.discovery.AbstractDiscoveryStrategy.performDiscovery() skips scanning completely if there is no beans.xml present as per the following code:

for (ScanResult scanResult : scanner.scan()) { // scanResult is beansXmlResult really
            final String ref = scanResult.getBeanArchiveRef();
            if (processedRefs.contains(ref)) {
                throw CommonLogger.LOG.invalidScanningResult(ref);
            }
            CommonLogger.LOG.processingBeanArchiveReference(ref);
            processedRefs.add(ref);
            BeanArchiveBuilder builder = null;
            for (BeanArchiveHandler handler : beanArchiveHandlers) {
                builder = handler.handle(ref);
                if (builder != null) {
                    CommonLogger.LOG.beanArchiveReferenceHandled(ref, handler);
                    builder.setId(scanResult.getBeanArchiveId());
                    builder.setBeansXml(scanResult.getBeansXml());
                    beanArchiveBuilders.add(builder);
                    break;
                }
            }
            if (builder == null) {
                CommonLogger.LOG.beanArchiveReferenceCannotBeHandled(ref, beanArchiveHandlers);
            }
        }

How are we supposed to pass this?

manovotn commented 2 weeks ago

Shouldn't this issue/challenge be under the Jakarta TCK repo instead of here?

According to https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#bean_archive the beans.xml file is required.

In CDI Lite, that is correct.

How are we supposed to pass this?

I'd say add beans.xml to the test. Is that a problem?

Ladicek commented 2 weeks ago

There's https://github.com/jakartaee/platform-tck/issues/1526 already, so it seems to me this issue should just be closed.

manovotn commented 2 weeks ago

There's jakartaee/platform-tck#1526 already, so it seems to me this issue should just be closed.

I agree, I've added my comment there and we can continue the discussion there.