Upgrading Hibernate to 3.4.0 and AppFuse for Tapestry 5
Last night I spent an hour upgrading AppFuse to Hibernate 3.4.0.GA. I tried the same thing a week ago, but failed miserably. When Hibernate Core Modules (3.3) (a Maven dependency howto) showed up on the Hibernate blog, I was re-inspired. I discovered some interesting things along the way (at least in my setup).
You need to use JBoss's Maven Repository
The latest Hibernate releases aren't in the central Maven repo yet. If they're not in there two weeks after the release, I doubt they'll be there anytime soon. Best to plan on adding http://repository.jboss.com/maven2 as a permanent repository. As a bonus, you can remove http://download.java.net/maven/2 since JTA is in JBoss's repo.
Javassist is not an optional dependency
If I remove the Javassist dependency, here's the error I get:
java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
Seems reasonable right? What if I add in the dependency on Hibernate's cglib instead?
java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
OK, so apparently you can't switch between Javassist and hibernate-cglib-repack as stated in Hibernate's Maven dependency howto. Of course, I do believe their instructions are correct, they just don't work in my setup. Versions I'm using: hibernate-core-3.3.1.GA and hibernate-annotations-3.4.0.GA.
Not including SLF4J is a bad idea
If you don't include a dependency on SLF4J (and you're using Spring), you get a nice cryptic error message.
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877) ... 48 more Caused by: java.lang.NoClassDefFoundError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.class$(LocalSessionFactoryBean.java:174) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.(LocalSessionFactoryBean.java:174) at org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean. (AnnotationSessionFactoryBean.java:64) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
Hibernate's JPA now uses PersistenceException instead of EntityExistsException
In previous releases, Hibernate's ConstraintViolationException
was wrapped in a javax.persistence.EntityExistsException
. In Hibernate's EntityManager 3.4.0.GA, it's wrapped in a javax.persistence.PersistenceException
.
Of course, these errors could be caused by Spring or Maven, but my hunch is they're more related to Hibernate and it's new more modular dependencies. You can view the full changeset for upgrading Hibernate 3.2.6.ga to 3.3.1.GA via FishEye.
Tapestry 5 version of AppFuse
In other AppFuse-related news, Serge Eby has created a Tapestry 5 version of AppFuse. You can see his alpha-level work in Google Code's tapestry5-appfuse project. I haven't had a chance to take a look at Serge's work yet, but I'm eager to do so. Hopefully we can get it back into the main project sooner than later. As far as Wicket and Stripes support, I haven't forgot about those - just having trouble finding the time and motivation to do the work.
Posted by Marcos de Sousa on September 17, 2008 at 06:48 PM MDT #
Posted by Matt Raible on September 17, 2008 at 07:06 PM MDT #
Posted by Marcos de Sousa on September 18, 2008 at 07:54 AM MDT #
Posted by Ignacio Coloma on September 18, 2008 at 10:21 AM MDT #
Posted by Emmanuel Bernard on September 18, 2008 at 03:19 PM MDT #
Posted by Emmanuel Bernard on September 18, 2008 at 03:31 PM MDT #
Are you using Hibernate EntityManager?
In the instance where I'm getting the Javassist/Cglib error, I'm not using EntityManager, just Annotations.
You can view the project in FishEye at or check it out from SVN (user/pass: guest/(blank)).
Posted by Matt Raible on September 18, 2008 at 03:38 PM MDT #
WRT swapping cglib and javassist did you set the appropriate setting ('hibernate.bytecode.provider')? That's in addition to swapping the dependencies.
We could add logic to detect this situation and attempt to fallback to the other library. Enter a RFE if you wish.
Longer term the desire is to make each bytecode provider its own module, and perhaps have selection of either bytecode-provider module be the trigger to use that bytecode-provider (much like slf4j adapters).
Posted by Steve Ebersole on September 25, 2008 at 07:08 PM MDT #
Hey Matt, I think the whole EntityExistsException is due to a change they made to fix another issue that I reported:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-349
They were wrapping all ConstraintViolationExceptions in an EntityExistsException, but now it looks like they've swung the other way and aren't even trying to check the returned SQL Code to see. Sigh.
Derek
Posted by Derek Chen-Becker on October 14, 2008 at 12:04 PM MDT #
Posted by Diego Ballve on October 22, 2008 at 03:47 PM MDT #
Hi Matt,
We recently decided to use AppFuse in our project and used the maven archetype command to get ourselves a JSF/EJB3.0 project but are having major problems with the EntityManager when deploying the war to JBOSS5.0.
It looks like a compatibility issue between the libs that JBOSS has and the ones that are getting wrapped into the war. Any ideas on where I should be looking would be much appreciated.
Thanks & Regards,
John
Posted by John Page on March 07, 2009 at 05:43 AM MST #
Posted by Matt Raible on March 10, 2009 at 12:01 AM MDT #