These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Forcing JBoss 4.0.4/5 + Hibernate Service to use CGLIB
PostPosted: Wed Nov 01, 2006 5:09 pm 
Beginner
Beginner

Joined: Thu Jan 12, 2006 4:44 pm
Posts: 22
Hello -

I have an application that uses a handful of Hibernate MBeans being deployed on JBoss. In JBoss 4.0.3, the Hibernate Service uses CGLIB as the default bytecode provider and my Hibernate MBeans behave fine.

In JBoss 4.0.4 and 4.0.5, however, the Hibernate Service uses javassist as the default bytecode provider. Unfortunately, javassist does not seem to be doing a smart enough job at classloading, and I suspect that it is filling up my PermGen space with unneccessary objects, ultimately resulting an OutOfMemory error. The only way to really be sure, though, would be to switch back to using CGLIB.

Unfortunately I can't find a straightforward way to do this. I've tried modifying the "persistence.properties" file, putting a hibernate.properties file in my classpath with the "hibernate.bytecode.provider" parameter set, adding a "-Dhibernate.bytecode.provider=cglib" flag to my JBoss startup script, even trying to set the environment option in code, but the Hibernate Service always reports on startup that it is using javassist as the bytecode provider.

There is some documentation that indicate that the bytcode provider for Hibernate 3.2 (deployed with JBoss 4.0.4 and 4.0.5) is pluggable, but this functionality does not seem to extend to the Hibernate Service.

I'm stumped - can anyone tell me how to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 4:01 pm 
Beginner
Beginner

Joined: Thu Jan 12, 2006 4:44 pm
Posts: 22
Well, the solution was for me to rebuild the library containing the JBoss Hibernate MBean. In case this happens to anybody else, here's what to do. I did this for 4.0.5 GA; I imagine this would work for 4.0.4 as well.

1. Download the source.

2. Open up <jboss source>\hibernate-int\src\main\org\jboss\hibernate\jmx\Hibernate.java

3. Edit the createService() function so that it looks like this:

Code:
    protected void createService() throws Exception
    {
        log.trace( "forcing bytecode provider -> cglib" );
        // todo : really need a much better solution for this...
        System.setProperty( Environment.BYTECODE_PROVIDER, "cglib" );
    }


4. Save this revised class and do a build of JBoss - you'll find build scripts in <jboss source>\build\ for your platform, which in my case was XP, so I just ran the build.bat file.

5. When the build is complete, grab <jboss source>\hibernate-int\output\lib\jboss-hibernate.jar and replace the one in <your jboss distro>\server\default\lib with the one you just built.

This will switch all of your Hibernate services to use CGLIB as your bytecode provider. In my case, it cleared up all of the horrendous PermGen OutOfMemory problems I was having with javassist and my application is now happy again. Hopefully, future releases will support a pluggable bytecode provider for Hibernate MBeans.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:05 pm 
Newbie

Joined: Thu Nov 02, 2006 6:20 am
Posts: 2
I think it'd better find out why the -D option did not work.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 11:20 am 
Beginner
Beginner

Joined: Thu Jan 12, 2006 4:44 pm
Posts: 22
Well, I imagine the "-D" option didn't work because the Hibernate Service has hardcoded javassist as its bytecode provider.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.