Hi, me again.

Phew. That was a long day digging into James, Avalon and Phoenix :(.
First tried to use my
own ClassLoader, without luck. After half of the day, I decided to get
to the root cause of
the problem - not just trying to work around it.

Please find attached the patch for the version I found in the README:

https://svn.apache.org/repos/asf/avalon/cvs-migration-snapshot/avalon-phoenix/

It fixes the File-to-URL handling in the phoenix Classloader classes.
Maybe someone
with more internal knowledge can validate this. It works for me though.
Spaces
are now supported.

Veit


Am 15.12.2011 08:58, schrieb Veit Guna:
> Hi guys.
>
> We're using Apache James 2.3.0 in a project that calls EJBs from a
> Mailet. Until now we installed
> it under linux with a fixed, non-space-containing path. So far no problems.
>
> Now, we support Windows as well and the user should be able to choose
> the installation directory.
> So we installed to e.g. c:\Program Files\James. When we call an EJB on
> JBoss (5.1.0), that fails with a MalformedURL
> Exception. We looked deeper into the problem and found out, that the
> classpath that is generated by
> James/Phoenix (e.g. pointing to SAR-INF/classes, james-54355354/lib)
> contains unescaped spaces that
> will kill the jndi ctx.lookup. It looks like that the phoenix
> classloader magic won't escape spaces properly.
> Is there anything we can do to fix this? Workaround I'll try to do is:
> get the current classloader, fix the urls
> and replace it with a fixed version during runtime. But that is ugly.
>
> We start James with the tanuki wrapper from a windows service. So
> run.bat or similar is not an option. Also
> to put James in a non-space-containing path is not an option.
>
> Thanks for your help.
>
> Veit
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
Index: 
src/java/org/apache/avalon/phoenix/components/classloader/DefaultLoaderResolver.java
===================================================================
--- 
src/java/org/apache/avalon/phoenix/components/classloader/DefaultLoaderResolver.java
        (revision 1214776)
+++ 
src/java/org/apache/avalon/phoenix/components/classloader/DefaultLoaderResolver.java
        (working copy)
@@ -175,7 +175,7 @@
                 {
                     try
                     {
-                        urls.add( file.toURL() );
+                        urls.add( toURL(file) );
                     }
                     catch ( final MalformedURLException mue )
                     {
Index: 
src/java/org/apache/avalon/phoenix/components/classloader/SarLoaderResolver.java
===================================================================
--- 
src/java/org/apache/avalon/phoenix/components/classloader/SarLoaderResolver.java
    (revision 1214776)
+++ 
src/java/org/apache/avalon/phoenix/components/classloader/SarLoaderResolver.java
    (working copy)
@@ -148,7 +148,7 @@
             ResourceUtil.getFileForResource( location,
                                              getBaseDirectory(),
                                              m_workDirectory );
-        return file.toURL();
+        return toURL(file);
     }
 
     /**
Index: 
src/java/org/apache/avalon/phoenix/components/classloader/SimpleLoaderResolver.java
===================================================================
--- 
src/java/org/apache/avalon/phoenix/components/classloader/SimpleLoaderResolver.java
 (revision 1214776)
+++ 
src/java/org/apache/avalon/phoenix/components/classloader/SimpleLoaderResolver.java
 (working copy)
@@ -52,6 +52,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.JarURLConnection;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
@@ -134,7 +135,7 @@
         }
         final OptionalPackage optionalPackage =
             getManager().getOptionalPackage( extension );
-        return optionalPackage.getFile().toURL();
+        return toURL(optionalPackage.getFile());
     }
 
     /**
@@ -148,7 +149,7 @@
         throws Exception
     {
         final File file = getFileFor( location );
-        String url = file.toURL().toString();
+        String url = toURL(file).toString();
         if( file.isDirectory() )
         {
             url += "/";
@@ -234,7 +235,7 @@
         for( int i = 0; i < files.length; i++ )
         {
             final File file = files[ i ];
-            classpathSet.add( file.toURL() );
+            classpathSet.add( toURL(file) );
         }
 
         //Define final classpath with all dependencies added
@@ -453,4 +454,8 @@
 
         return (Manifest[])manifests.toArray( new Manifest[ 0 ] );
     }
+    
+    protected URL toURL(File file) throws MalformedURLException {
+       return file.toURI().toURL();
+    }
 }
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to