glassfish
  1. glassfish
  2. GLASSFISH-11528

toString() not called in a JSR316 Managed Bean

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: V3
    • Fix Version/s: 3.1_ms07
    • Component/s: ejb_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      11,528

      Description

      Create a simple servlet that uses the @Resource annotation to inject a managed
      bean. The managed bean class should have the @ManagedBean annotation applied at
      the class level and a public String toString() method.

      I expected to be able to call (directly or indirectly) the toString method on
      the injected managed bean. Instead I get something like:

      com.sun.ejb.containers.interceptors.InterceptorInvocationHandler@1a64949

      Also of note is that if I call toString on a managed bean without an overridden
      toString method I get something like:

      com.example._EJB31_GeneratedMyPojoIntf__Bean_@45fe1a

      So the behavior is changing when I add in a toString method however it looks
      like sometype of interceptor is always added for each method and it is not
      forwarding calls to toString.

      Please note that this is with a plain JSR316 managed bean. Adding a beans.xml to
      the project to activate CDI causes the toString method to behave properly so
      this seems to be a flaw in the vanilla JSR316 managed bean implementation.

        Activity

        Hide
        Alexis MP added a comment -

        cc

        Show
        Alexis MP added a comment - cc
        Hide
        Alexis MP added a comment -

        fixed handle for Ken

        Show
        Alexis MP added a comment - fixed handle for Ken
        Hide
        ksak added a comment -

        Reassign to me.

        Show
        ksak added a comment - Reassign to me.
        Hide
        marina vatkina added a comment -

        Siva, please evaluate.

        Show
        marina vatkina added a comment - Siva, please evaluate.
        Hide
        Sivakumar Thyagarajan added a comment -

        I was able to reproduce the issue and as the submitter indicates this is a pure
        managed bean issue. In the presence of beans.xml, CDI handles Managed Beans and
        this issue doesn't appear.

        An InstantiationException is thrown in
        ManagedBeanManagerImpl.createManagedBean:494 and needs to be investigated.
        Targetted for MS6

        Show
        Sivakumar Thyagarajan added a comment - I was able to reproduce the issue and as the submitter indicates this is a pure managed bean issue. In the presence of beans.xml, CDI handles Managed Beans and this issue doesn't appear. An InstantiationException is thrown in ManagedBeanManagerImpl.createManagedBean:494 and needs to be investigated. Targetted for MS6
        Hide
        Sivakumar Thyagarajan added a comment -

        This issues appears to be in InterceptorInvocationHandler. The Invocation
        handler channels all method invocations for methods that are declared in Object
        (such as toString) to InvocationHandlerUtil.invokeJavaObjectMethod and
        invokeJavaObjectMethod returns the handler's toString.

        InterceptorInvocationHandler probably needs to handle the case where a
        ManagedBean has an overridden toString implementation. This was introduced as
        part of the initial checkin for ManagedBean support. I don't see a requirement
        in the ManagedBean or EE6 spec which doesn't allow a ManagedBean to have an
        overridden implementation of methods defined in Object.

        Requesting the ejb container team to look into this.

        Show
        Sivakumar Thyagarajan added a comment - This issues appears to be in InterceptorInvocationHandler. The Invocation handler channels all method invocations for methods that are declared in Object (such as toString) to InvocationHandlerUtil.invokeJavaObjectMethod and invokeJavaObjectMethod returns the handler's toString. InterceptorInvocationHandler probably needs to handle the case where a ManagedBean has an overridden toString implementation. This was introduced as part of the initial checkin for ManagedBean support. I don't see a requirement in the ManagedBean or EE6 spec which doesn't allow a ManagedBean to have an overridden implementation of methods defined in Object. Requesting the ejb container team to look into this.
        Hide
        marina vatkina added a comment -

        the fix is coming...

        Show
        marina vatkina added a comment - the fix is coming...
        Hide
        marina vatkina added a comment -

        Fixed with rev 42282

        Show
        marina vatkina added a comment - Fixed with rev 42282

          People

          • Assignee:
            marina vatkina
            Reporter:
            chasetec
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: