-
1. Re: Scheduling and hot-deployment
adrian.brock Jan 9, 2003 6:58 AM (in response to bratseth)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();
bean.methodName();
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.
jboss.j2ee:service=EJB,jndiName=whatever
...
Regards,
Adrian -
2. Re: Scheduling and hot-deployment
bratseth Jan 9, 2003 7:34 AM (in response to bratseth)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 Jan 9, 2003 8:56 AM (in response to bratseth)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.
Regards,
Adrian