Hi,


currently it is not possible to use ResourceLinks to bind a UserTransaction in the java:comp context of a web application because the way it is implemented ResourceLinks are always bound in the java:comp/env context. I stumbled across this because I thought it would make sense to configure my transaction manager only in one place and have all my webapps access it via ResourceLinks instead of copying the configuration for each webapp, which did not work. The current behaviour is not documented and a little hard to understand. It is only a minor thing (therefore I'm not filing a bug) but I would be grateful if you could make that little change to make the behaviour a little more consistent. I have attached a patch that does this which you may use if you agree with the (rather simple) way I fixed it.

Thanks in advance and regards,

Robert


-- ________________________ Robert Krüger Signal7 GmbH Brüder Knauss Str. 79 64285 Darmstadt Germany

Index: catalina/src/share/org/apache/catalina/core/NamingContextListener.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
retrieving revision 1.4
diff --unified -r1.4 NamingContextListener.java
--- catalina/src/share/org/apache/catalina/core/NamingContextListener.java      2 Sep 
2003 21:22:04 -0000       1.4
+++ catalina/src/share/org/apache/catalina/core/NamingContextListener.java      22 Jan 
2004 09:46:03 -0000
@@ -939,10 +939,14 @@
         addAdditionalParameters(resourceLink.getNamingResources(), ref, 
                                 resourceLink.getName());
         try {
+            javax.naming.Context ctx = envCtx;
+            if("javax.transaction.UserTransaction".equals(resourceLink.getType())){
+                ctx = compCtx;
+            }
             if (debug >= 2)
                 log("  Adding resource link " + resourceLink.getName());
-            createSubcontexts(envCtx, resourceLink.getName());
-            envCtx.bind(resourceLink.getName(), ref);
+            createSubcontexts(ctx, resourceLink.getName());
+            ctx.bind(resourceLink.getName(), ref);
         } catch (NamingException e) {
             log(sm.getString("naming.bindFailed", e));
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to