I find that whenever I redeploy an EJB-JAR, any web apps that had already been using those EJBs also need to be redeployed. I don't know the true technical reasons for it but it seems pretty consistent to me.
If it's true, the reason why it all seems to work after restarting the JBoss server is that restarting undeploys and redeploys everything.
Maybe you could try redeploying the EAR with the EJBs, try a web app that fails, redeploy that one web app to see if it begins working and then you'll have your answer.
There might be some way to deal with this problem without redeploying the web apps but I haven't found one yet.
This is the classical classloading problem disccused in JBoss Admin Guide under section.
220.127.116.11. ClassCastExceptions - I'm Not Your Type
It says and solution is provided.
This type of error is common when redeploying an application to which other applications are holding references to classes from the redeployed application. For example, a standalone WAR accessing an EJB. If you are redeploying an application, all dependent applications must flush their class references. Typically this requires that the dependent applications themselves be redeployed.
An alternate means of allowing independent deployments to interact in the presence of redeployment would be to isolate the deployments by configuring the EJB layer to use the standard call-by-value semantics rather than the call-by-reference JBoss will default to for components collocated in the same VM. An example of how to enable call-by-value semantics is presented in Chapter 5, EJBs on JBoss
I hope this helps.
Nice work, Vishal. I will give that a try. Just like everything else in J2EE, there's probably some downside to going this route. I'll check out the doc but do you know of anything 'bad' about using this technique?