Please see section, 5.1.1 specifies that "if bean class listed in beans.xml
file  and it is not an alternative bean (means that it is not annotated with
@Alternative), it throws exception".

Therefore if you listed bean class in "beans.xml", please remove it.



2010/2/9 YING WANG (JIRA) <[email protected]>

> Given class is not annotated with @Alternative Exception when try to enable
> alternative producer/producer field beans
>
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: OWB-273
>                 URL: https://issues.apache.org/jira/browse/OWB-273
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Injection and Lookup
>    Affects Versions: M3
>            Reporter: YING WANG
>            Assignee: Gurkan Erdogdu
>            Priority: Minor
>
>
> I have an alternative producer bean as follow. It seems that the
> AlternativesManager.addClazzAlternative( ) requires @Alternative to be
> annotated at the class level even if it is an alternative producer and
> throws the following exception.
>
> It is not necessary to add @Alternative at both class level and method
> level for a producer/producer field beans, right?
>
>
> =====EXCEPTION=======================================================================================
>
> org.apache.webbeans.exception.WebBeansConfigurationException: Given class :
> com.jcdi.test.alternative.producerbased.AlternativeBeanProducer2 is not
> annotated with @Alternative
>        at
> org.apache.webbeans.inject.AlternativesManager.addClazzAlternative(AlternativesManager.java:89)
>        at
> org.apache.webbeans.xml.WebBeansXMLConfigurator.addAlternative(WebBeansXMLConfigurator.java:622)
>        at
> org.apache.webbeans.xml.WebBeansXMLConfigurator.configureAlternativesElement(WebBeansXMLConfigurator.java:587)
>        at
> org.apache.webbeans.xml.WebBeansXMLConfigurator.configureSpecSpecific(WebBeansXMLConfigurator.java:323)
>        at
> org.apache.webbeans.xml.WebBeansXMLConfigurator.configureSpecSpecific(WebBeansXMLConfigurator.java:221)
>        at
> org.apache.webbeans.xml.WebBeansXMLConfigurator.configure(WebBeansXMLConfigurator.java:157)
>        at
> org.apache.webbeans.config.BeansDeployer.deployFromXML(BeansDeployer.java:384)
>        at
> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:139)
>        at
> org.apache.webbeans.lifecycle.WebApplicationLifeCycle.applicationStarted(WebApplicationLifeCycle.java:196)
>        at
> org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:60)
>
> ===THE ALTERNATIVE PRODUCER
> BEAN===============================================================
>
> public class AlternativeBeanProducer2 {
>
>        public @Produces @Alternative @QualifierProducerBased IProducedBean
>                generateBean2(@New AlternativeBeanClass1 beanClass) {
>                        return new AbstractProducedBean(beanClass, this);
>        }
> /*
>        public void dumpBean2(
>                        @Disposes @QualifierProducer IProducedBean bean,
> ILog log) {
>                        log.log(bean + " is dumped by
> AlternativeBeanProducer2");
>        }
> */
>
> }
> ========================================================================
>
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
Gurkan Erdogdu
http://gurkanerdogdu.blogspot.com

Reply via email to