Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: groovy
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
The following test case shows the problem:
public void testWithParentClassPathPropagatesWithNoParentContainer()throws IOException {
File testCompJar = new File(System.getProperty("testcomp.jar"));
URLClassLoader classLoader = new URLClassLoader(new URL[]
, this.getClass().getClassLoader());
Class testComp = null;
try
{ testComp = classLoader.loadClass("TestComp"); }catch (ClassNotFoundException ex)
{ fail("Unable to load test component from the jar using a url classloader"); } Reader script = new StringReader(
""
+ " pico = builder.container(parent:parent)
"
+ "");
PicoContainer pico = buildContainer(new GroovyContainerBuilder(script, classLoader), null, null);
Object testCompInstance = pico.getComponentInstance(testComp);
assertEquals(testCompInstance.getClass().getName(), testComp.getName());
}
It fails claiming that the TestComp class is not found and the classloader stack trace does not show the URL classloader.
I was under the impression that the groovy container builder's classpath SHOULD get passed into the script somehow, otherwise, groovy scripts are always loaded under the basic system classpath.
I am working on a solution, but I wanted to make sure that I understood that the GroovyContainerBuilder classpath passed in SHOULD be the classpath used for building containers. (Aside from dynamic classpaths, of course!)
Thanks for taking a look at it. If people don't think I'm misunderstanding the use of the API, I'll check in a fix shortly.
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | nano-175.patch [ 20240 ] |
One minor clarification: The SCRIPT execution is where the failure is occuring.