maven-surefire-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davis Ford" <davisf...@gmail.com>
Subject IsolatedClassLoader -> URL with spaces %20 problem
Date Tue, 20 Feb 2007 01:41:47 GMT
He, we're using maven 2.0.4 (although I just tried 2.0.5 and the same
problem exists), and we're using Hibernate Entity Manager 3.2.1-ga, and
we're on a Windows Platform.  These 3 things don't seem to work together.

The problem is the default repo for maven jars contains spaces on windows
C:\Documents and Settings\etc.

Hibernate Entity Manager expects to find META-INF\persistence.xml on the
classpath.  The general idea is to bury this in a jar that is loaded as a
dependency on our maven repo classpath, right?

Hibernate has code similar to this in
org.hibernate.ejb.EjbConfiguration.java (I added logger and assertions):

try {
        Enumeration<URL> xmls = Thread.currentThread()
        .getContextClassLoader()
        .getResources( "META-INF/persistence.xml" );

        if ( ! xmls.hasMoreElements() ) {
        fail( "Could not find any META-INF/persistence.xml file in the
classpath");
        }
        while ( xmls.hasMoreElements() ) {
        URL url = xmls.nextElement();
        LOGGER.debug( "Analyse of persistence.xml: " + url );
        URL jarURL = getJarURLFromURLEntry( url, "/META-INF/persistence.xml"
);
        assertFalse("Jar URL should not contain spaces, "+jarURL,
jarURL.toString().contains(" "));
        }

1. Create a jar-file, install it in local maven repo.
2. Add META-INF\persistence.xml to the jar file
3. Add a dependency to a new maven test project
4. Paste in code like above -- test case will always fail when it tests for
whitespace in the url.

System.out.println(Thread.currentThread
().getContextClassLoader().getClass().getCanonicalName());

prints

org.apache.maven.surefire.booter.IsolatedClassLoader

If I run from Eclipse, I have no problems, and the above println prints
instead:

sun.misc.Launcher.AppClassLoader

I am *desperate* for any kind of solution to this problem that does not
require me to change the local maven repo to a url without spaces.

I need the URLClassLoader (IsolatedClassLoader) to correctly deal with
whitespace and replace it with %20.  If there is some other workaround --
please let me know.  Hibernate ends up throwing an exception and returning
null for the EntityManager which is an absolute show-stopper for us.

Thank you in advance,

Davis

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message