hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis Klotz <>
Subject New Issue when using Hivemind with OC4J
Date Fri, 08 Jul 2005 18:58:47 GMT
Last October I posted a message about a problem I had getting hivemind
to work with OC4J 9.0.4.  and a simple code change to fix it.


That issue was fixed long ago and everything I did with hivemind has
worked great, however when I fired up Tapestry 4.0 on OC4J last week I
discovered a similar problem that does not have as nice of a solution.

The issue occurs when hivemind tries to create a sub module defined in
a jar file (like Tapestry 4 does.)   To create the sub module,
hivemind creates a resource relative to the parent module to retrieve
the module descriptor.  In the URLResource class this is done by
converting the internal URL object to a string, removing the parent
file name, appending the relative resource path, and creating a new
URL object with the new path.  This is exactly the same kind of issue
that my original post talked about.  Except this time I can't come up
with a "nice" solution.  URL objects don't have a method to create
relative URLs, so converting to a string is the only real option.

The two not nice solutions I can come up with are:

1)	Don't support OC4J 10.1.2 and below.  I have tried hivemind 1.1
with the latest developer preview of OC4J and the jndi urls go away
and everything works great as is. So sub modules will work on OC4J
after its next major release.

2)	Put a hack in URLResource to explicitly check for "jndi" urls in
URLResource.newResource.  The path can transformed to a "jar" url with
a minimal amount of code.  The only real problem with this is that it
muddies the code up a bit with an OC4J specific fix, but it shouldn't
affect any other containers (unless something else also uses a "jndi"

I have actually implemented option 2(along with a couple of unit
tests) just to see if anything else would break on OC4J 10.1.2. 
Everything appears to work once this chunk of code is added, however I
haven't tried it on anything other than Windows with Sun's JDK.

I'm attaching that patch to this post, but I'm really hoping someone
can come up with a better solution.

Index: C:/workspace/jakarta-hivemind/framework/src/test/org/apache/hivemind/util/
--- C:/workspace/jakarta-hivemind/framework/src/test/org/apache/hivemind/util/
+++ C:/workspace/jakarta-hivemind/framework/src/test/org/apache/hivemind/util/
@@ -0,0 +1,23 @@
+package org.apache.hivemind.util;
+import org.apache.hivemind.Resource;
+import org.apache.hivemind.util.URLResource;
+import hivemind.test.FrameworkTestCase;
+public class TestURLResource extends FrameworkTestCase {
+	public void testOC4JHack()
+    {
+        Resource l1 = new
+        Resource l2 = l1.getRelativeResource("test/test.class");
+        assertEquals("Error generating OC4J safe resource URL",
+    }
+	public void testNormalUrl() {
+		Resource l1 = new URLResource("");
+        Resource l2 = l1.getRelativeResource("hivemind");
+        assertEquals("Incorrect relative URL generated",
"", l2.getPath());
+	}
Index: C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/util/
--- C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/util/
+++ C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/util/
@@ -50,6 +50,19 @@
     protected Resource newResource( String path )
+    	//begin hack to work with OC4J <= 10.1.2
+    	//change jndi:PATH_TO_ARCHIVE/PATH_IN_ARCHIVE to
+    	if(path.startsWith("jndi:")) {
+    		//change prefix
+    		path = "jar:file:///" + path.substring(5);
+    		int endOfJar = path.indexOf(".jar") + 4;
+    		//insert "!" between jar file and path to resource
+    		path = path.substring(0, endOfJar) + "!" + path.substring(endOfJar) ;
+    	}
+    	//end hack
         return new URLResource( path );

Travis Klotz
Project Architect
ACT Inc.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message