ColdFusion 9 ORM on Tomcat Gotcha
I am sitting here working through an application that makes use of the new ColdFusion 9 ORM capabilities. I have a simple business object that I created using EntityNew(), then populated it, and attempted to save it using EntitySave(). Nothing fancy and everything straight out of the docs.
The problem was, when I ran this code I would just get a blank screen – no errors, nothing. I started up my application server – Tomcat – in the console and checked the output as I ran the script. Sure enough, there was a slew of Java errors being displayed with the first being …
java.lang.NoClassDefFound: javax/transaction/Synchronization
With a bit of googling, I came across a blog article by Rupesh Kumar which mentioned this issue in the comments. I had heard that Tomcat was not officially supported by ColdFusion which did not make a lot of sense, but apparently this just came back and bit me.
Somewhere in the Hibernate integration with ColdFusion 9, it is expecting a library called jta.jar (part of the Java Transaction support) to be included with the application server. This library is not included by default with Tomcat and thus the error I was seeing, or not seeing.
I did some searching and could not find the jta.jar library to download, but I did find a zip download of all of the classes available on the Java site at http://java.sun.com/javaee/technologies/jta/index.jsp. So, I simply downloaded this and renamed it to jta.jar, then dropped it into my Tomcat /lib folder. With that in place, I restarted Tomcat, fired up my CF template again and everything worked like it should.
I can’t fault Adobe since they don’t support Tomcat. I am curious as to why they don’t support it since it used to be supported, but hopefully this will save somebody a couple of hours digging around when their script fails to show anything.