Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Done
-
None
-
None
Description
Using: org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:jar:2.0.0-alpha-2
The attached test case produces an invalid beans.xml with a duplicate <alternatives/> entry with the code:
BeansDescriptor beansXml = Descriptors.importAs(BeansDescriptor.class) .from(new File("src/main/webapp/WEB-INF/beans.xml")) .getOrCreateAlternatives();
'getOrCreate' is in fact always creating an alternatives entry, so the following beans.xml is produced in the example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> <alternatives> <alternative>com.example.shrinkwraptestskeleton.Production</alternative> </alternatives> <alternatives/> </beans>
The produced beans.xml descriptor fails at deployment time with:
org.jboss.weld.exceptions.DefinitionException: WELD-001203 <alternatives> can only be specified once, but appears multiple times: vfs:/content/demo.jar/META-INF/beans.xml@6
Also: Since there can only ever be one <alternatives/> block, it's not clear what the difference between getOrCreateAlternatives() and createAlternatives() is. Is the latter supposed to replace any existing block?
The API for managing alternatives is in Descriptors 2.0 is IMO difficult to use and understand. Issues with examples pending.