-
1. Re: JBossCache inside EJB
ben.wang Nov 4, 2004 3:12 PM (in response to javaripper)If you are running inside JBoss, use a JBossCache MBean (and deploy it as a MBean service).
-Ben -
2. Re: JBossCache inside EJB
skotagiri Nov 5, 2004 3:26 PM (in response to javaripper)
If you are running inside JBoss, use a JBossCache MBean (and deploy it as a MBean service).
One issue with using JBossCache MBean in the EJB environment is, you have to keep your CacheLoader outside of the EAR file and place your CacheLoader jar in the server lib directory.
Also, if the backend store is RDBMS, and if you would like to get access to the JDBC DataSource through ENC ( Enterprise Naming Context java:/comp) inside the CacheLoader, then you may have a problem (I did not try this, but since the CacheLoader is invoked within the MBean ClassLoader, I am assuming that the ENC is not available).
Here is how I am using the Cache in my EJB enviroment.
Create TreeCache through a startup servlet (That way I do not have to keep my CacheLoader class outside of the EAR file and I will not get Class Loading errors) and access the JDBC DataSource inside my CacheLoader using through ENC.
Your comments and feedback is welcome.
Thanks. -
3. Re: JBossCache inside EJB
ben.wang Nov 5, 2004 4:38 PM (in response to javaripper)Hi, to follow up your comments:
1. I am not clear why do you need to put the CacheLoader jar file in your ear file? When you deploy JBossCache as a MBean serivce, you typically place the jboss-cache.jar under all/lib directory, for example. After that, you simply drop a, say, replSync-service.xml under the deploy directory. It is not under any J2EE enc scope.
2. For RDBMS cache loader, that's true, you can't access it thru java:/comp. But there is a datasource binding under java:/DefaultDS (for example) as well.
Do I miss anything?
-Ben -
4. Re: JBossCache inside EJB
belaban Nov 7, 2004 7:44 AM (in response to javaripper)"skotagiri" wrote:
Also, if the backend store is RDBMS, and if you would like to get access to the JDBC DataSource through ENC
This is somewhat unrelated, but... I realized that we need to provide a configuration option for JDBCCacheLoader to retrieve the DataSource from JNDI (preconfigured DS), in addition to creating a JDBC connection.
This allows us to be good citizens and participate in the container's connection pooling.
I added this to the roadmap for 1.3.
Bela -
5. Re: JBossCache inside EJB
norbert Nov 7, 2004 8:26 PM (in response to javaripper)If you use JBossCache as MBean-Service and put Objects into it that have been loaded by the EJB-classloader from the ejb-jar, than you'l get a ClassNotFoundException as soon you try to access the previously stored objects after redeployment of your ejb-jar. This is because classes being loaded by the previous deployment are no longer accessible from the new EJB-classloader after redeployment.
If this is an issue for you, you better go with a startupservlet that stops the local cache-instance on undeployment of your EAR.
Or you put the classes in question somewhere in all/lib or system-classpath or so they don't get redeployed.
Or you implement a treecachelistener that is notified by some startupservlet from destroy() so it can remove all Objects in question before shuting down the app.
(I'm still searching for a clean solution of this issue, will be tricky though).