Sunday, March 28, 2010

Hibernate with Tomcat

I followed the release note steps for configuring Tomcat to use LCDS: I added JTA as specified in http://labs.adobe.com/wiki/index.php/LiveCycle_Data_Services_3. However, when I start Tomcat I get the following error in the logs:

[LCDS][ERROR] Error instantiating application scoped instance of type 'flex.data.assemblers.HibernateAssembler' for destination 'hibernate-contact'.

java.lang.NoClassDefFoundError: javax/transaction/Synchronization

?at org.hibernate.impl.SessionFactoryImpl.buildCurrentSessionContext(SessionFactory Impl.java:999)

?at org.hibernate.impl.SessionFactoryImpl.%26lt;init%26gt;(SessionFactoryImpl.java:334)

?at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)

Hibernate with Tomcat

The hibernate jars required with LCDS 3 are included in lcds.war and lcds-samples.war in WEB-INF/lib:

hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate3.jar

The 'hibernate-contact' destination is setup in the data-management-config.xml in lcds-samples, but not the lcds.war template.?In lcds-samples the destination:

?%26lt;destination id=''hibernate-contact''%26gt;
?%26lt;properties%26gt;
?%26lt;use-transactions%26gt;true%26lt;/use-transactions%26gt;
?%26lt;source%26gt;flex.data.assemblers.HibernateAssembler%26lt;/source%26gt;
?%26lt;item-class%26gt;flex.samples.contact.Contact%26lt;/item-class%26gt;
?%26lt;scope%26gt;application%26lt;/scope%26gt;
?%26lt;network%26gt;
?%26lt;paging enabled=''false'' pageSize=''10'' /%26gt;
?%26lt;/network%26gt;
?%26lt;server%26gt;
?%26lt;fill-configuration%26gt;
?%26lt;use-query-cache%26gt;false%26lt;/use-query-cache%26gt;
?%26lt;allow-hql-queries%26gt;true%26lt;/allow-hql-queries%26gt;
?%26lt;/fill-configuration%26gt;
?%26lt;/server%26gt;
?%26lt;/properties%26gt;
?%26lt;/destination%26gt;

It points to the class 'flex.samples.contact.Contact', which is located in lcds-samples/WEB-INF/classes.?If you are the template LCDS war, you would need to update both data-management-config.xml with the destination and place the Contact class and hibernate file under the WEB-INF classes directory as it is in lcds-samples.

Hibernate with Tomcat

It turns out that there are a variety of issues to consider.?Some are not mentioned in the existing docs, and some often-repeated properties are actually undesirable.?Hibernate issues have not changed between v2.6.1 and v3.0 beta.?I just added the writeup to the book, and I provide working Eclipse projects to download.?A new PDF with the latest manuscript will be available this weekend.

Mike

''Eclipse Data Services, Hibernate and Eclipse''

http://slinnbooks.com

No comments:

Post a Comment