Flex Data Services 2: "Unable to access UserTransaction in DataService" error
Issue
When running Flex Data Services 2 deployed on Tomcat, the message "Unable to access UserTransaction in DataService" generally indicates that your transaction services are not properly set up. This TechNote provides some general guidelines and recommendations to diagnose the issue.
Solution
To use the DataService feature in Flex Data Services 2 on Tomcat, you need to install the Java Open Transaction Manager (JOTM) package and configure Tomcat to use the JOTM.
First, check to make sure that the JOTM package has been installed properly. There are several different ways to install and configure the Tomcat server. The steps listed below provide one approach but are not the exclusive solution. These steps are based on the latest version of Tomcat (5.5.17) and JOTM (2.0.10).
- Drop the JOTM JAR files into<tomcat>/common/lib
- Add the following lines to your application configuration file (for example,<tomcat>/conf/Catalina/localhost/samples.xml), with the paths updated to match your filesystem.
<Context docBase="c:/tomcat/webapps/samples" privileged="true" antiResourceLocking="false" antiJARLocking="false"> ....<Transaction factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> ....</Context>
- Restart the server and check the localhost-xxxx.log and catalina-xxx.log files to be sure that everything started correctly.
The following link provides more installation details for all versions of Tomcat - http://static.raibledesigns.com/downloads/howto-tomcat-jotm.html under "Configuring Tomcat".
Second, verify that transactions are working correctly with the following test JSP page. Drop the JSP page into your web application and access from a browser.
<%@ page import="javax.naming.*,javax.transaction.*" %><% Context ctx = new InitialContext(); UserTransaction tx = (UserTransaction)ctx.lookup("java:comp/UserTransaction"); tx.begin(); tx.commit(); %> success!
If you see an exception, go back to the JOTM setup. If you see 'success', then proceed with the Contact Manager sample application.
Last, run the Contact Manager sample application and try to update a contact. If you see the "Unable to access UserTransaction in DataService" error, then check the server console and server logs for errors and/or exceptions.
Also, during development, get in the habit of running the server in debug mode and check for errors in the server console and logs frequently, especially when you encounter errors on the client. For Flex Data Services 2, you'll want to set debug level logging in enterprise-services.xml. Restart the server after making changes. The debug output will give you more clues and hints about what might be wrong.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
