Return-Path: Delivered-To: apmail-jakarta-hivemind-user-archive@www.apache.org Received: (qmail 55178 invoked from network); 11 Jul 2005 08:21:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2005 08:21:53 -0000 Received: (qmail 6324 invoked by uid 500); 11 Jul 2005 08:21:51 -0000 Delivered-To: apmail-jakarta-hivemind-user-archive@jakarta.apache.org Received: (qmail 6307 invoked by uid 500); 11 Jul 2005 08:21:51 -0000 Mailing-List: contact hivemind-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: hivemind-user@jakarta.apache.org List-Id: Delivered-To: mailing list hivemind-user@jakarta.apache.org Received: (qmail 6292 invoked by uid 99); 11 Jul 2005 08:21:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2005 01:21:51 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.55.195.90] (HELO groundhog.init7.net) (212.55.195.90) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2005 01:21:48 -0700 Received: from mail.bedag.ch (mail.bedag.ch [159.144.64.45]) by groundhog.init7.net (8.13.4/8.13.4/Debian-3) with ESMTP id j6B8LLce012365; Mon, 11 Jul 2005 10:21:21 +0200 Received: from A99A-EMS-01VS1.ad.bedag.ch (ZWINGLER [159.144.15.43]) by mail.bedag.ch with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id NPPJKW7L; Mon, 11 Jul 2005 10:12:16 +0200 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: RE: New Issue when using Hivemind with OC4J Date: Mon, 11 Jul 2005 10:21:34 +0200 Message-ID: <088B4F5B1FAFA445B9401140A673D0A813EAE7@A99A-EMS-01VS1.ad.bedag.ch> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: New Issue when using Hivemind with OC4J Thread-Index: AcWD7zlA+3yBahe6SHK8sQwQamxclACAV0rg From: To: , X-Virus-Scanned: ClamAV 0.84/974/Fri Jul 8 23:09:18 2005 on groundhog.init7.net X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, I had the same problem and fixed it with almost exactly the same code but in a slightly different way - by writing my own, very slightly modified, version of BuilderFactory (can't subclass because it is final) and of XmlModuleDescriptorProvider, and getting them to generate an OracleResource (which contains the jndi --> jar code) when the prefix is jndi. The advantage of this for me is that I don't have to hack the hivemind sources every time I update. Irritating, like much Oracle stuff, unfortunately. Best wishes John -----Original Message----- From: Travis Klotz [mailto:travis.klotz@gmail.com]=20 Sent: Friday, July 08, 2005 8:59 PM To: hivemind-user@jakarta.apache.org Subject: New Issue when using Hivemind with OC4J 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. (http://mail-archives.apache.org/mod_mbox/jakarta-hivemind-user/200410.m box/%3Ce78ffed40410231214268da168@mail.gmail.com%3E) 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" prefix.) 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.=20 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/uti l/TestURLResource.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- C:/workspace/jakarta-hivemind/framework/src/test/org/apache/hivemind/uti l/TestURLResource.java (revision 0) +++ C:/workspace/jakarta-hivemind/framework/src/test/org/apache/hivemind/uti l/TestURLResource.java (revision 0) @@ -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 =3D new URLResource("jndi:C:\\jdev1012\\jakarta-struts\\lib\\struts.jar/org/apac he/struts/action/Action.class"); + Resource l2 =3D l1.getRelativeResource("test/test.class"); + =20 + assertEquals("Error generating OC4J safe resource URL", "jar:file:///C:\\jdev1012\\jakarta-struts\\lib\\struts.jar!/org/apache/s truts/action/test/test.class" ,l2.getPath()); + } +=09 + public void testNormalUrl() { + Resource l1 =3D new URLResource("http://jakarta.apache.org/"); + Resource l2 =3D l1.getRelativeResource("hivemind"); + =20 + assertEquals("Incorrect relative URL generated", "http://jakarta.apache.org/hivemind", l2.getPath()); + } +} Index: C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/uti l/URLResource.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/uti l/URLResource.java (revision 209772) +++ C:/workspace/jakarta-hivemind/framework/src/java/org/apache/hivemind/uti l/URLResource.java (working copy) @@ -50,6 +50,19 @@ =20 protected Resource newResource( String path ) { + //begin hack to work with OC4J <=3D 10.1.2 + //change jndi:PATH_TO_ARCHIVE/PATH_IN_ARCHIVE to jar:file:///PATH_TO_ARCHIVE!/PATH_IN_ARCHIVE + if(path.startsWith("jndi:")) { + //change prefix + path =3D "jar:file:///" + path.substring(5); + =09 + int endOfJar =3D path.indexOf(".jar") + 4; + =09 + //insert "!" between jar file and path to resource + path =3D path.substring(0, endOfJar) + "!" + path.substring(endOfJar) ; + } + //end hack + =09 return new URLResource( path ); } Travis Klotz Project Architect ACT Inc. --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-user-help@jakarta.apache.org