-
1. Re: JBossCache with Hibernate on Glassfish v2
genman Nov 19, 2007 3:20 PM (in response to eric.hubert)I must admire your chutzpah coming on to the JBoss message boards asking how to port your EJB3 application to Glassfish.
In any case, I would start by getting your application to work on JSE, then port it to Glassfish. You can read information on Hibernate's website on this. Then, add the appropriate cache provider configuration information for TreeCache. -
2. Re: JBossCache with Hibernate on Glassfish v2
eric.hubert Nov 19, 2007 7:26 PM (in response to eric.hubert)"genman" wrote:
I must admire your chutzpah coming on to the JBoss message boards asking how to port your EJB3 application to Glassfish.
genman, thanks for your quick reply. Although unfortunately it doesn't help me much. I could succesfully deploy the application to Glassfish using hibernate and ehcache. I only would like to replace ehcache with JBoss Cache on Glassfish. That's why I decided to ask in the JBoss Cache forum.
I also must admit I can't see any chutzpah on my side. I know the JBoss people as very open-minded and technical interessted. From my point of view Hibernate and JBoss Cache are application server independend projects and should be treated as such. Am I wrong?
My aim is to get our JEE applications independent of the application server used - at least were it is technical feasible with a reasonalbe expenditure. Personally, I like JBoss AS very much and would like to use Glassfish v2 only during the development process as a reference implementation to doublecheck compliance to the spec. In some areas JBoss offers some non-standard temperings which decrease portability if one makes happily use of them. It could also be very practical to help isolating issues.
So again I see no problem asking the JBoss folks for their support and hope that they will have a similar view on this topic than I do.
Regards,
Eric -
3. Re: JBossCache with Hibernate on Glassfish v2
manik Nov 20, 2007 4:55 AM (in response to eric.hubert)Hi Eric
I presume what genman meant was that you'd need pretty much the same configuration as you would for Java SE as you would for Glassfish. The only difference when using the setup in JBoss AS is that the AS provides additional stuff (such as an already-running cache) that you could use.
The Hibernate docs provide a lot of info on configuring the 2nd-level cache, as does this wiki page: http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHibernate
In terms of a sample configuration, I suggest using the configurations in JBoss AS as a reference point:
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/branches/Branch_4_2/ejb3/src/resources/ejb3-entity-cache-service.xml?view=markup
And we have no problems helping people run JBoss Cache on Glassfish - we are app server agnostic and do help people run on WebLogic, WebSphere, etc. :-)
Cheers,
Manik -
4. Re: JBossCache with Hibernate on Glassfish v2
eric.hubert Nov 20, 2007 6:42 AM (in response to eric.hubert)"manik.surtani@jboss.com" wrote:
The only difference when using the setup in JBoss AS is that the AS provides additional stuff (such as an already-running cache) that you could use.
Hi Manik,
thanks for your feedback! What do you mean by an already-running cache? Do you only mean that JBoss Cache is preconfigured and ready to use in JBoss AS? That would be clear to me."manik.surtani@jboss.com" wrote:
In terms of a sample configuration, I suggest using the configurations in JBoss AS as a reference point:
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/branches/Branch_4_2/ejb3/src/resources/ejb3-entity-cache-service.xml?view=markup
I already use this configuration inside JBoss. The problem is that I don't know which places I have to adjust to make it working in Glassfish. Could you please assist!
Glassfish currently logs the following:
[#|2007-11-20T11:59:37.891+0100|INFO|sun-appserver9.1|org.hibernate.transaction.TransactionFactoryFactory|_ThreadID=15;_ThreadName=Timer-6;|Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory|#]
[#|2007-11-20T11:59:37.907+0100|INFO|sun-appserver9.1|org.hibernate.transaction.TransactionManagerLookupFactory|_ThreadID=15;_ThreadName=Timer-6;|instantiating TransactionManagerLookup: org.hibernate.transaction.SunONETransactionManagerLookup|#]
[#|2007-11-20T11:59:37.907+0100|INFO|sun-appserver9.1|org.hibernate.transaction.TransactionManagerLookupFactory|_ThreadID=15;_ThreadName=Timer-6;|instantiated TransactionManagerLookup|#]
[...]
[#|2007-11-20T11:59:37.907+0100|INFO|sun-appserver9.1|org.hibernate.cfg.SettingsFactory|_ThreadID=15;_ThreadName=Timer-6;|Cache provider: org.jboss.ejb3.entity.TreeCacheProviderHook|#]
[...]
[#|2007-11-20T11:59:38.000+0100|WARNING|sun-appserver9.1|javax.enterprise.system.core.classloading|_ThreadID=15;_ThreadName=Timer-6;_RequestID=e98e7c13-4d36-4e82-a6e2-a0bf50b26146;|org.hibernate.cache.CacheException: java.lang.IllegalStateException: No 'jboss' MBeanServer found!
javax.persistence.PersistenceException: org.hibernate.cache.CacheException: java.lang.IllegalStateException: No 'jboss' MBeanServer found!
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
So it seems to me that an MBean-Lookup does not find the TreeCacheMBean. The problem is my lack of understanding of the background. Maybe the root cause is that I can't use "org.jboss.ejb3.entity.TreeCacheProviderHook" as Cache provider?"manik.surtani@jboss.com" wrote:
And we have no problems helping people run JBoss Cache on Glassfish - we are app server agnostic and do help people run on WebLogic, WebSphere, etc. :-)
Hey, I'm quite happy to hear that.
Regards,
Eric -
5. Re: JBossCache with Hibernate on Glassfish v2
manik Nov 20, 2007 6:57 AM (in response to eric.hubert)"eric.hubert" wrote:
What do you mean by an already-running cache? Do you only mean that JBoss Cache is preconfigured and ready to use in JBoss AS? That would be clear to me.
That, and JBoss AS ships with configurations for JBoss Cache that is tuned and configured."eric.hubert" wrote:
I already use this configuration inside JBoss. The problem is that I don't know which places I have to adjust to make it working in Glassfish. Could you please assist!
TBH, I've never used this in Glassfish so anything I say is purely theoretical. :-)
In fact, we have wiki pages on running JBC on WebLogic and on WebSphere. I'm sure a lot of people would appreciate your contributing your findings, tips and tricks for Glassfish as well.
The TreeCacheProvider hook looks up the JBoss Cache instance in JMX, bound under a specific name. You may want to write your own hook - this is a pretty simple class, have a look a Hibernate docs - which will look up a JBC instance in JMX (or JNDI) and if it doesn't exist, create it from a cache cfg file (and probably bind to JMX/JNDI again).
Cheers,
Manik -
6. Re: JBossCache with Hibernate on Glassfish v2
genman Nov 21, 2007 1:00 AM (in response to eric.hubert)"eric.hubert" wrote:
I also must admit I can't see any chutzpah on my side. I know the JBoss people as very open-minded and technical interessted. From my point of view Hibernate and JBoss Cache are application server independend projects and should be treated as such. Am I wrong?
I don't personally have a problem with wanting to know about these things in general, I know the guys at JBoss, at least the ones here don't either. But always I'm impressed with people like yourself who come in and ask questions like yours which require quite detailed answers. And not only that but who, unapologetically, assert they are porting to a competitor's solution. Additionally, a fair bit of information already exists on this topic, so it also seemed you hadn't bothered to RTFM. Or if you did, you couldn't be bothered to say what you have read and tried. And, there are a lot of stupid or lazy people who post on this forum so it's easy for people like you to be confused with either.
So, that's basically where I'm coming from.
To sort of repeat Manik's advice: My advice is to get your EJB3 app running in Java SE under Hibernate EntityManager using JBoss Cache. You should do this anyway so you have an environment that is easy to test your configuration with. Then, it should be trivial to port it to Glassfish by copying whatever persistence.xml and .jar files you are using.
I would also read the code that comes with Hibernate to figure out how Hibernate finds TreeCache, because this would be the place application server integration differences would appear:
TreeCacheProvider.java - source:
http://www.koders.com/java/fidC3D6379D1A1393672FFBF648FA69D06F8730C2D6.aspx -
7. Re: JBossCache with Hibernate on Glassfish v2
eric.hubert Nov 21, 2007 6:56 AM (in response to eric.hubert)"genman" wrote:
I don't personally have a problem with wanting to know about these things
With due respect I wouldn't care much about you having those problems. ;)
I read through the official JBoss Cache documentation as well as some outdated wiki entries which did help me to get a starting point but which were not sufficient to solve my problems in a timely manner. That's why I kindly asked for some help and pointers into the right direction.
Nobody can really be sure that he hadn't overseen some "obvious" source of information. At least that's what I thought might be the case. Ideally one only had to pick a couple of libraries (jbosscache.jar) as well as a very few dependencies and change some configuration properties to use JBossCache on a specific application server. That's exactly the information I was looking for. I see inspecting the source of an open source project I would like to use as a kind of last resort, as this may require a tremendous effort. You can't be sure beforehand.
That doesn't mean that I'm not willing to do so if there is no other way. Of course I'm also happy to provide my findings for later reuse. Personally I don't see anything wrong with this approach. But back to topic!
So in this case I ended up inspecting the source of JBoss AS and JBoss Cache 2.0. I started with Hibernate's CacheProvider interface following it's concrete implementations of TreeCacheProviderHook as well as DeployedTreeCacheProvider.
In JBoss AS the Cache is wrapped in a MBean which is registered with the MBeanServer. In recent code the actual mbean server lookup was moved from concrete CacheProvider to a TransactionCacheFactory. Since JBoss Cache 2.0 this is JBCCacheFactory. It is responsible for connecting with the MBeanServer, retrieving an MBeanProxy of the Cache (in this case CacheJmxWrapperBean), read the caches configuration and evaluate the locking strategie and build the Cache appropriately.
I'm not quite sure if I can oversee anything from my first glance at the code, but the only obvious thing which is application server dependent is the way the MBeanServer is located. Unfortunately there was no standard way of doing this before JSE 5.0. Since then the preferred way is by using java.lang.management.ManagementFactory.getPlatformMBeanServer().
JBoss uses a utility class MBeanServerLocator to retrieve it's MBeanServer.
So at the moment I have to think about how to solve my problem best. I could write my own implementation of the CacheProvider interface. But would that be clever? It seems to be a good idea to also use the underlying logic of the CacheFactory.
If I got it right I had to register the CacheJmxWrapperBean with Glassfish's MBean-Server and change the way how the MBeanServer is located. Seems pretty simple, If that would be all. Well, I guess I'll see.
It might be a good idea to make the MBeanLookup-Code exchangeable.
Unfortunately at the moment I have no time to experiment on the code level. I will take some time at the weekend. If one of you had any further suggestions it will be more than welcome. :-)
Isolating issues in a non container environment is generally a good idea, but it doesn't seem practical for me in this special case. On the one hand I have a full blown JEE application and on the other hand my problems are not related to the cache and it's configuration but to container integration. Anyhow, genman, I thank you for your suggestions and pointers. Any assistance is greatly appreciated.
Regards,
Eric -
8. Re: JBossCache with Hibernate on Glassfish v2
mirko27 Nov 25, 2007 7:47 AM (in response to eric.hubert)Any progress on this part?
JBoss subprojects claim to be application server independent but somehow they never work out-of-box:(
Unfortunately JBoss Cache is quite only cluster-supportive cache for hibernate. -
9. Re: JBossCache with Hibernate on Glassfish v2
eric.hubert Nov 27, 2007 4:49 AM (in response to eric.hubert)"mirko27" wrote:
Any progress on this part?
JBoss subprojects claim to be application server independent but somehow they never work out-of-box:(
Welcome in J(2)EE land. ;-) Sorry, I could find any freetime at the weekend, but it is still on my todo-list and postponed to the next weekend which is rather deallocated. So if anyone could beat me to do it I wouldn't be too sad. ;-)
Regards,
Eric -
10. Re: JBossCache with Hibernate on Glassfish v2
manik Nov 27, 2007 8:16 AM (in response to eric.hubert)"eric.hubert" wrote:
"genman" wrote:
I don't personally have a problem with wanting to know about these things
With due respect I wouldn't care much about you having those problems. ;)
lol!"eric.hubert" wrote:
So at the moment I have to think about how to solve my problem best. I could write my own implementation of the CacheProvider interface. But would that be clever? It seems to be a good idea to also use the underlying logic of the CacheFactory.
If I got it right I had to register the CacheJmxWrapperBean with Glassfish's MBean-Server and change the way how the MBeanServer is located. Seems pretty simple, If that would be all. Well, I guess I'll see.
It might be a good idea to make the MBeanLookup-Code exchangeable.
I haven't looked into it much, but if you can write a CacheProvider that *does* in fact use a generic lookup - perhaps try a JBoss-specific lookup as in the current provider, and if that fails, fall back to a generic getPlatformMBeanServer(), and failing that as well, perhaps look in a "known location" in JNDI.
This is a part of the Hibernate codebase though, and it may be a good idea to make suggestions there as well. -
11. Re: JBossCache with Hibernate on Glassfish v2
manik Nov 27, 2007 8:19 AM (in response to eric.hubert)"mirko27" wrote:
Any progress on this part?
JBoss subprojects claim to be application server independent but somehow they never work out-of-box:(
Unfortunately JBoss Cache is quite only cluster-supportive cache for hibernate.
JBoss Cache works out of the box, as does Hibernate. It all depends on how you use it. Looking up a cache instance in JMX, unfortunately, as Eric pointed out, has only become standardised in Java 5. If we can do this generically, great. If not, the effort to write a cache provider that creates a cache and puts it *somewhere* to be looked up at a later point in time is trivial.