[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66152 ]
Kenney Westerhof commented on MSUREFIRE-115: -------------------------------------------- API doc for java.lang.Class: {noformat} public ClassLoader getClassLoader() Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader. .... {noformat} The lava.lang.* classes are loaded by the system classloader. Since the unit test classloader has no parent (i.e. 'isolated' classloader), it returns null, which is perfectly OK according to the API specs. The system classloader should be consulted in the case getClassLoader returns null: ClassLoader.getSystemClassLoader(). However, in this case, a resource for java.util.Date is _not_ present in the system classloader, but in the Thread.currentThread().getContextClassLoader(). This is the one that should always be used. close this issue? > Classloading problem for getting a resource > ------------------------------------------- > > Key: MSUREFIRE-115 > URL: http://jira.codehaus.org/browse/MSUREFIRE-115 > Project: Maven 2.x Surefire Plugin > Type: Bug > Versions: 2.1.3, 2.2 > Environment: Maven 2.0.4 > Windows XP > Reporter: Wim Deblauwe > Priority: Blocker > Attachments: surefire-test.zip > > > We are using Betwixt and some of our unit tests fail when run using > surefire, but run fine in IntelliJ or Maven 1. Betwixt looks for > descriptors with the name of the class + .betwixt to control how > something is written out in XML. It uses the construct: > myClass.getResource() to find the .betwixt file. > E.g. com.mycomp.MyClass -> com/mycomp/MyClass.betwixt > We have a betwixt file for the java.util.Date class. However, betwixt > seems to be unable to pick it up when using surefire. I have created a > small test that shows the problem and have attached it. > I tried with version 2.2 using different configurations (never, once, > pertest) and with version 2.1.3 (default configuration) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira