Error EJB:010116 and what's the best fix? - Weblogic

This is a discussion on Error EJB:010116 and what's the best fix? - Weblogic ; I got an EJB:010116 error and need some advice on how to fix it (quickly, I am running out of time). My basic understanding of the problem is: 1. I defined a many2many relationship with a join table, say ProviderEJB ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Error EJB:010116 and what's the best fix?

  1. Error EJB:010116 and what's the best fix?


    I got an EJB:010116 error and need some advice on how to fix it (quickly, I am
    running out of time).

    My basic understanding of the problem is:

    1. I defined a many2many relationship with a join table, say ProviderEJB to ProviderKeyEJB,
    the cmr field for ProviderEJB is providerKeys and a correcponding abstract method
    with default transaction-attribute (not specified):

    abstract public Set getProviderKeys();

    2. generated code with ejbgen 215
    3. deployed to weblogic 8.1 SP1 JDK141_03
    4. at run time, my facade session ejb find a local ejb instance of ProviderEJB,
    call its method getProviderKeys() to get a set of local instance of ProviderKeyEJB.
    all works OK up to this point.
    5. then the facade session ejb try to iterate through this set of object and at
    this point I got an exception from weblogic:

    java.lang.IllegalStateException: [EJB:010116]Attempted to access the collection
    valued cmr field, 'providerKeys' for bean 'ProviderEJB', outside of the scope
    of a transaction. All access to the collection must be performed during the transaction
    in which the collection was initially retrieved.


    6. Very clear message. I can understand the meaning of it. However, the getProviderKeys()
    method was declared abstract and was generated and implemented by ejbgen. So how
    can I access this collection INSIDE of the transaction?

    In general, does that mean I will have to turn off the transactions on my entity
    beans and let the facade session ejbs to manage the transactions? if so, why do
    I need the CMP entity beans in the first place?

    So assume I have to do this way, does that mean I have to add the ejbgen tag "transaction-attribute
    = Supported" for those methods that I do not want to have a transaction?

    On another separate issue, just read weblogic 8.1 doc on ejbs and it recomends
    that do not use facade session beans and DTO (value objects) from the web tie,
    simply access local entity beans directly. Any experience on this, in terms of
    design issues. Obviously I understand it will go faster without a facade, but
    what about clean architect of your software design?


    Many thanks and best regards.


    Charles


  2. Re: Error EJB:010116 and what's the best fix?

    Whenever you access the collection you need to be under a transactionin order to
    ensure that the data you are looking at is consistent. I suggest that you make
    the transaction attribute on your session facade method 'Required'. It is
    needed to make sure the list of objects is consistent. You don't need to turn
    off transactions on your entities at all. In general, if you set your
    transaction attribute to 'Required' you will get what you want. The only time
    that you would have to start a transaction manuall, using the JTA API, would be
    if you wanted to access the collection outside of an EJB, i.e. directly from a
    JSP or something like that.

    Sam

    Charles Chen wrote:
    > I got an EJB:010116 error and need some advice on how to fix it (quickly, I am
    > running out of time).
    >
    > My basic understanding of the problem is:
    >
    > 1. I defined a many2many relationship with a join table, say ProviderEJB to ProviderKeyEJB,
    > the cmr field for ProviderEJB is providerKeys and a correcponding abstract method
    > with default transaction-attribute (not specified):
    >
    > abstract public Set getProviderKeys();
    >
    > 2. generated code with ejbgen 215
    > 3. deployed to weblogic 8.1 SP1 JDK141_03
    > 4. at run time, my facade session ejb find a local ejb instance of ProviderEJB,
    > call its method getProviderKeys() to get a set of local instance of ProviderKeyEJB.
    > all works OK up to this point.
    > 5. then the facade session ejb try to iterate through this set of object and at
    > this point I got an exception from weblogic:
    >
    > java.lang.IllegalStateException: [EJB:010116]Attempted to access the collection
    > valued cmr field, 'providerKeys' for bean 'ProviderEJB', outside of the scope
    > of a transaction. All access to the collection must be performed during the transaction
    > in which the collection was initially retrieved.
    >
    >
    > 6. Very clear message. I can understand the meaning of it. However, the getProviderKeys()
    > method was declared abstract and was generated and implemented by ejbgen. So how
    > can I access this collection INSIDE of the transaction?
    >
    > In general, does that mean I will have to turn off the transactions on my entity
    > beans and let the facade session ejbs to manage the transactions? if so, why do
    > I need the CMP entity beans in the first place?
    >
    > So assume I have to do this way, does that mean I have to add the ejbgen tag "transaction-attribute
    > = Supported" for those methods that I do not want to have a transaction?
    >
    > On another separate issue, just read weblogic 8.1 doc on ejbs and it recomends
    > that do not use facade session beans and DTO (value objects) from the web tie,
    > simply access local entity beans directly. Any experience on this, in terms of
    > design issues. Obviously I understand it will go faster without a facade, but
    > what about clean architect of your software design?
    >
    >
    > Many thanks and best regards.
    >
    >
    > Charles
    >



  3. RE: Re: Error EJB:010116 and what's the best fix?

    I have a similar problem. I have specified @ejb.transaction type="Required" via xdoclet (first for the entire Bean, then when that failed, with the individual methods) to no avail. I checked the value of trans-attribute within the ejb-jar.xml file and verified that the value was indeed Required. Do you have other suggestions how to fix this problem?

+ Reply to Thread