Topic
  • 7 replies
  • Latest Post - ‏2011-04-05T14:48:14Z by bergmark
denisF
denisF
12 Posts

Pinned topic CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

‏2011-04-03T15:51:41Z |
I'm still trying to start the seam-booking sample app with WAS v8 and I receibe this exception at startup


WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container is starting... BeansDeployer E BeansDeployer deploy org.apache.webbeans.exception.definition.DuplicateDefinitionException: PassivationCapable bean id is not unique: PRODUCERFIELD#

interface java.util.List#@javax.enterprise.inject.Any(),@javax.enterprise.inject.Default(), bean:280705842, Name:null,WebBeans Type:PRODUCERFIELD,API Types:[java.util.List,java.util.Collection,java.lang.Iterable,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default] at org.apache.webbeans.container.BeanManagerImpl.addPassivationInfo(BeanManagerImpl.java:366) at org.apache.webbeans.container.BeanManagerImpl.addBean(BeanManagerImpl.java:338) at org.apache.webbeans.util.WebBeansUtil.defineManagedBean(WebBeansUtil.java:3149) at org.apache.webbeans.config.BeansDeployer.defineManagedBean(BeansDeployer.java:881) at org.apache.webbeans.config.BeansDeployer.deploySingleAnnotatedType(BeansDeployer.java:536)   How can I find what beans cause the problem? I also activated some traces (JCDI=all: com.ibm.ws.webbeans*=all: org.apache.webbeans*=all) but didn
't find anything more usefull there
Updated on 2011-04-05T14:48:14Z at 2011-04-05T14:48:14Z by bergmark
  • RohitK
    RohitK
    38 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-03T16:59:03Z  
    Denis,

    Can you please attach the seam-booking sample app ear or war file.

    --Thanks,
    Rohit Kelapure
  • denisF
    denisF
    12 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-03T17:33:32Z  
    Here it is
    If needed you can find Seam 3 source code here http://seamframework.org/Seam3/Downloads
  • denisF
    denisF
    12 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-04T12:06:37Z  
    Oops.
    Tried twice to upload the ear file and even if the post was OK, the file does not appear here. Maybe because it's too big (12M). I will try to find a way to upload it later
    Or maybe is there some place where I could upload it?
    Thx
  • bergmark
    bergmark
    8 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-04T19:25:11Z  
    The error message gives a little bit of helpful information, but doesn't tell us which class this happened inside. I can see:

    1) The PassivationCapable bean id generated conflicts with an id already in the list (the ids should be unique). The id generated in this case is:
    PRODUCERFIELD#interface java.util.List#@javax.enterprise.inject.Any(),@javax.enterprise.inject.Default()

    2) Both the generated ID and the Bean information in the error message indicate this was a Producer Field that returned a List.

    We are still investigating, but it looks like one possibility could be that if you have two different producer fields that return the same type, with the same qualifiers, and both are deemed PassivationCapable you could hit this condition. It also seems likely this condition could lead to an AmbiguousResolutionException if there was an injection point that tried to inject using that same type.
  • bergmark
    bergmark
    8 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-04T21:33:43Z  
    Ok, I think I understand what might be going on here now.

    It appears when generating the PassivationCapable bean id for producer fields, generics are not taken into account. So if you had

    @Produces List<TypeA> list;

    and

    @Produces List<TypeB> list;

    It would generate the same PassivationCapable bean id for both, and you would hit this error.

    I've opened an internal defect to track this problem.
  • denisF
    denisF
    12 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-05T11:50:03Z  
    Is what you describe valid (But I'm not a CDI expert though..)?

    @Produces List<TypeA> list;
    @Produces List<TypeB> list;

    I don't think so as you have 2 beans named "list" in the same scope

    Shouldn't be the name of the bean ("list" here") be taken into account when computing the id?
    Also TypeA and TypeB could be abstract classes too.
  • bergmark
    bergmark
    8 Posts

    Re: CDI: a.w.e.d.DuplicateDefinitionException : How to debug?

    ‏2011-04-05T14:48:14Z  
    • denisF
    • ‏2011-04-05T11:50:03Z
    Is what you describe valid (But I'm not a CDI expert though..)?

    @Produces List<TypeA> list;
    @Produces List<TypeB> list;

    I don't think so as you have 2 beans named "list" in the same scope

    Shouldn't be the name of the bean ("list" here") be taken into account when computing the id?
    Also TypeA and TypeB could be abstract classes too.
    To be fair, what I posted would not compile because you would have 2 local variables with the same name. A more concrete example would be:

    @Produces @SessionScoped List<String> produceList1 = new ArrayList<String>();
    @Produces @SessionScoped List<Integer> produceList2 = new ArrayList<Integer>();

    These are unique producer fields, but would currently generate the same id which could cause the exception you described.