Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

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 in Java at Sep 17 2008, 09:35:45 AM MDT 12 Comments
Comments:

I would like to invite you to take an look at http://www.zkoss.org/community/ext/ZKWorkshop_wstage.pdf since you like to compare web framework. Hope it not be an spam :-) Regards

Posted by Marcos de Sousa on September 17, 2008 at 06:48 PM MDT #

Marcos - unfortunately, I do consider this somewhat like spam. Whenever I post something about web frameworks, you (or other ZK users) post a comment about ZK that provides nothing related to the topic except that you think I should evaluate it and include it in my comparisons. I am impressed to see there's a couple of books on it, but there doesn't seem to be much demand job-wise.

Posted by Matt Raible on September 17, 2008 at 07:06 PM MDT #

Matt, Sorry, really it provides nothing related to the topic. It was not good to post it here.

Posted by Marcos de Sousa on September 18, 2008 at 07:54 AM MDT #

My opinion on ZK is that it's a similar idea to Aptana Jaxer, but with a much worse design. ZK seems like something aimed at the clueless boss (hey, look at this page, ain't it pretty) instead of actual developers. This is in the hope this stops them from spamming your blog. Astroturfing is so 99. (Disclaimer: No, I don't work for Aptana)

Posted by Ignacio Coloma on September 18, 2008 at 10:21 AM MDT #

Hey Matt The EntityExistsException is a mistake on our side http://opensource.atlassian.com/projects/hibernate/browse/EJB-382 I will talk with Steve about the bytecode dependency hoopla.

Posted by Emmanuel Bernard on September 18, 2008 at 03:19 PM MDT #

Are you using Hibernate EntityManager. This component requires Javassist, It reads annotations wo loading classes when parsing your archives and needs Javassist for that. That could explain why you cannot switch to cglib. It is worth a better explanation in the docs :)

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 #

Hi Matt, have you noticed any substantial changes in memory consumption after the upgrade? I bumped into your post when googling for the javassist issue (thanks for sharing!). My upgrade involved trying a new (beta1) version of hibernate-search as well, but initial numbers showed 25 to 50% more memory needed on my load test. It's case specific, so don't take that for granted as a new hibernate feature.. but did it happen for you as well? I'm staying with 3.2.6.ga for a while..

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.

The main error is
javax.persistence.PersistenceException: [PersistenceUnit: ApplicationEntityManager] Unable to build EntityManagerFactory

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 #

@John - I would suggest searching the mailing list archives or posting to the mailing list to get this issue resolved. I believe others have encountered similar issues - usually solved by somehow excluding JBoss JARs from the classpath.

Posted by Matt Raible on March 10, 2009 at 12:01 AM MDT #

Post a Comment:
  • HTML Syntax: Allowed