ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Bailliez <sbaill...@imediation.com>
Subject RE: Fixing Classloader Linking Errors
Date Fri, 04 May 2001 20:13:48 GMT

As you guessed, this is due to the fact that you cannot load twice the same
class with different classloaders in the same JVM, this is to prevent some
malicious hacking by replacing classes.

Your only choice is to run with fork=yes or to avoid duplicating the classes
in your junit task classpath

What prevents you from forking ?

-- 
 St├ęphane Bailliez 
 Software Engineer, Paris - France 
 iMediation - http://www.imediation.com 
 Disclaimer: All the opinions expressed above are mine and not those from my
company. 



> -----Original Message-----
> From: Bendfelt, Tim (MED, nVisia, GEMS-IT)
> [mailto:Timothy.Bendfelt@med.ge.com]
> Sent: Friday, May 04, 2001 7:32 PM
> To: 'ant-user@jakarta.apache.org'
> Subject: Fixing Classloader Linking Errors
> 
> 
> 
> I have run into a dreaded Classloader linking constraint 
> while executing
> a junit task and need advice on which solution to pursue. 
> Apparently the
> root of the problem is the duplication of classpaths between 
> the System
> Classloader and "some other" Classloader. here is the Exception stack:
> 
> java.lang.LinkageError: loader constraints violated when linking
> org/xml/sax/ContentHandler class
> at com.client.Foo.<init>(Foo.java:67)
> at com.client.test.FooTest.testBar(FooTest.java:43)
> at java.lang.reflect.Method.invoke(Native Method)
> at junit.framework.TestCase.runTest(TestCase.java:156)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:121)
> at junit.framework.TestSuite.runTest(TestSuite.java:160)
> at junit.framework.TestSuite.run(TestSuite.java:155)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.r
> un(JUnitTe
> stRunner.java:209)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
> InVM(JUnit
> Task.java:409)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
> (JUnitTask
> .java:283)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
> (JUnitTask
> .java:263)
> at org.apache.tools.ant.Target.execute(Target.java:153)
> at org.apache.tools.ant.Project.runTarget(Project.java:898)
> at org.apache.tools.ant.Project.executeTarget(Project.java:536)
> at org.apache.tools.ant.Project.executeTargets(Project.java:510)
> at org.apache.tools.ant.Main.runBuild(Main.java:421)
> at org.apache.tools.ant.Main.main(Main.java:149)
> 
> 
> I have attempted to run the junit with fork="yes", but this 
> breaks some
> other things and is not viable.
> The junit test runs fine outside of the ant/junit target. 
> (from command
> prompt)
> 
> Any input would be appreciated. Here are two useful archive searches
> that hint at the cause/solution:
> http://marc.theaimsgroup.com/?l=ant-dev&w=2&r=1&s=loader+const
raints+&q=
b
http://marc.theaimsgroup.com/?l=ant-user&w=2&r=1&s=loader+constraints&q=
b

Any discussion on this topic is bound to help as I am at a loss to
adequately dissect the problem.

Tim

Mime
View raw message