Re: Weird classpath issue using DefaultConfiguration during unit testing

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jun 22 2005 - 14:42:12 EDT

  • Next message: Paul Cowan: "Cayenne performance degrades over time"

    Haven't used this in a while, but is it possible that leading "/" causes
    the problem? Per our own JavaDocs:

    .. Format should be "my/package/name" without leading "/"...

    Andrus

    > I'm seeing a weird classpath issue using DefaultConfiguration during unit
    > testing.
    >
    > I'm trying to run a unit test including Cayenne using
    >
    > DefaultConfiguration conf = new DefaultConfiguration();
    > conf.addClassPath("/com/gvea/cayenne/model");
    > Configuration.initializeSharedConfiguration(conf);
    >
    > I've traced it down to this statement in the classloader with the
    > debugger:
    >
    > Launcher$AppClassLoader(ClassLoader).getResource(String) line: 781
    > org.objectstyle.cayenne.util.ResourceLocator.findURLInClassLoader(String,
    > ClassLoader) line: 255
    >
    > Now the debugger says that
    > "file:/E:/workspace/EngWorkMgmt/WEB-INF/classes/"
    > is in the path of the classloader.
    >
    > ucp= URLClassPath (id=78)
    > path= ArrayList (id=87)
    > elementData= Object[38] (id=92)
    > modCount= 36
    > size= 36
    >
    > contains
    >
    > [file:/E:/Applications/eclipse3/plugins/org.eclipse.jdt.junit_3.0.1/junitsupport.jar,
    > file:/E:/Applications/eclipse3/plugins/org.eclipse.jdt.junit.runtime_3.0.0/junitruntime.jar,
    > file:/E:/workspace/EngWorkMgmt/WEB-INF/classes/,
    > file:/E:/workspace/EngWorkMgmt/WEB-INF/lib/commons-beanutils-1.6.1.jar,
    > [...]
    > file:/E:/workspace/EngWorkMgmt/WEB-INF/lib/testing/junit.jar,
    > file:/E:/workspace/EngWorkMgmt/WEB-INF/lib/testing/junit-addons-1.5-2004-08-
    > 18.jar]
    >
    > and that I'm properly using this path to the cayenne.xml file.
    >
    > arg0= "/com/gvea/cayenne/model/cayenne.xml"
    >
    > Which should resolve to the following path
    >
    > file:/E:/workspace/EngWorkMgmt/WEB-
    > INF/classes//com/gvea/cayenne/model/cayenne.xml
    >
    > Executing "head -2
    > E:/workspace/EngWorkMgmt/WEB-INF/classes//com/gvea/cayenne/model/cayenne.xml"
    > gives
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <domains project-version="1.1">
    >
    > So the file exists at that path.
    >
    > However, the classloader still returns null.
    >
    > Any ideas?
    >
    > Everything works fine with FileConfiguration.
    >
    > FileConfiguration conf = new
    > FileConfiguration("WEB-INF/classes/com/gvea/cayenne/model/cayenne.xml");
    > Configuration.initializeSharedConfiguration(conf);
    >



    This archive was generated by hypermail 2.0.0 : Wed Jun 22 2005 - 14:42:13 EDT