1 Reply Latest reply on Jan 3, 2007 2:50 PM by Tonio Caputo

    Client proxy problem

    Tonio Caputo Newbie

      Strange problem with EJB/Client

      My business logic EJB/Stateless Session Bean (EJB 3.0)
      1 - Users (Authorization/Authentication/Accounting)
      2 - Calculator (add, multiply,etc)
      I'm accessing these EJBs with the BusinessDelegate Pattern.

      My applications running in a Tomcat in different JVM
      1 - Authentication-Application
      Web-Service for authentication (the war includes users-client.jar)
      2 - Calculator-Application
      Web-Service for calculator (add, multiply, etc) (the war includes users-client.jar)

      Tomcat includes in it's shared class-loader all jboss-client
      libraries needed, so they are common for all applications

      When a user wants to call a calculator service he must do:
      1 - Call authentication web-service obtain a ticket
      2 - Call calculator method with the ticket just obtained

      The problem is that when the we call de calculator method
      internally the application calls the UsersEJB to check that the
      ticket is valid, when I call the the Business Delegate I receive
      this error:

      Caused by: java.lang.ClassCastException: isoa.users.bean.UserContext
       at $Proxy9.isUserAuthorized(Unknown Source)
       at isoa.users.bean.UsersServiceBd$5.run(UsersServiceBd.java:127)
       at isoa.commons.bean.AbstractBizDelegate$EjbRun.runWithRetries(AbstractBizDelegate.java:150)
       ... 37 more

      If I wait 60 seconds or more between the call to obtain the ticket, and
      the call to calculator method it works ok !!!!.

      What I suppose is that the proxy clients caches UserContext from
      the first call (the one I used to obtained the ticket), this UserContext
      is loaded by authentication-application class loader.

      When the calculator-application calls the authentication-ejb the proxy returns the UserContext that belongs to the authentication-application class loader, and not the UserContext that belongs to the calculator-application class-loader.

      I've tested as pure RMI/Client, servlet without web-service (all in one), etc
      and in all cases all works ok,

      Anybody can give me an idea if I'm totally missing the point, or
      something like this is happening, and in that case a way to work it out, without sharing user-client in all my applications.

      Thanks in advance