3 Replies Latest reply on Jan 9, 2003 8:56 AM by Adrian Brock

    Scheduling and hot-deployment

    Jon S Bratseth Newbie

      Hi! I'm trying to make a scheduling service which runs hot-deployed tasks.

      My take on this is to create a non-hot-deployed
      org.jboss.varia.scheduler.Schedulable which makes calls to a hot-deployed session-bean which forwards to the actual scheduling mechanics. Obviously the Schedulable makes the session-bean call without any static bindings to the hot-deployed codebase.

      Now, this works fint up until I hot-deploy. When I do, I get the following exception when the session-bean call is made from the Scheduler:

      Caused by: java.rmi.ServerException: EJBException:; nested exception is:
      javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract the.sessionbean.RemoteInterface the.sessionbean.HomeInterface.create() throws at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome(StatelessSessionContainer.java:597)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:206)
      at org.jboss.ejb.plugins.TxInterceptorBMT.invokeHome(TxInterceptorBMT.java:54)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:57)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
      ... 22 more

      Looks like there's some caching going on which messes things up. Does anybody know a solution to this? Or perhaps another way to achieve what I want to do?

        • 1. Re: Scheduling and hot-deployment
          Adrian Brock Master

          The caching is probably in your Schedulable,
          I cannot tell since you have shown the code.

          If you have this

          InitialContext ctx = new InitialContext();
          StatelessHome home = (StatelessHome) ctx.lookup(jndiName);
          Stateless bean = home.create();

          you've got a problem because your class holds
          references to StatelessHome and Stateless
          from the original deployment.

          Using reflection you can do this.
          Your class no longer holds a direct reference
          to the redeployed classes.

          InitialContext ctx = new InitialContext();
          EJBHome home = (EJBHome) ctx.lookup(jndiName);
          Method create = home.getClass().getMethod("create", new Class[0]);
          EJBObject obj = (EJBObject) create.invoke(home, new Object[0]);
          Method method = obj.getClass().getMethod("methodName", new Class[0]);
          method.invoke(obj, new Object[0]);

          Alternatively, you can use the following to recycle
          the schedulable when the ejb is redeployed.



          • 2. Re: Scheduling and hot-deployment
            Jon S Bratseth Newbie

            Yes, I'm using reflection more or less as you describe.

            But the problem is that the original UnifiedClassLoader still holds on to the old interfaces when new ones are deployed. This causes StatelessSessionContainer to fail, because it makes a lookup in an internal Map (homeMapping) with the called Method as key. After redeployment, the Map contains Methods loaded with the new loader, while I'm calling a Method loaded with the old loader. I suspect it would work nicely if the container had just indexed on the method toString() instead of the Method itself, but I would like to solve this without forking JBoss.

            I tried your depends suggestion, but it doesn't seem to help, it is unclear to me why it would. However, it removed a dependency check startup error message I could figure out, so thanks anyway :-)

            If I could somehow get hold of the new UnifiedClassLoader from the Schedulable I could reload the classes with it.

            • 3. Re: Scheduling and hot-deployment
              Adrian Brock Master

              Which version of jboss/jdk are you using?

              It works for me with jboss-3.0.5RC2 (latest CVS, due for release next week)
              and j2se1.4.1_01 from Sun.