You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Wim Deblauwe (JIRA)" <ji...@codehaus.org> on 2006/05/18 10:53:41 UTC
[jira] Created: (MSUREFIRE-115) Classloading problem for getting a
resource
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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "J?rg Hohwiller (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_67343 ]
Jörg Hohwiller commented on MSUREFIRE-115:
------------------------------------------
I have the same problem. The suggested classloader workaround does NOT work for me.
I had "MyClass.class.getResourceAsStream("/foo/bar.xml")" what works within Eclipse but not with maven2.
I changed to "MyClass.class.getClassloader().getResourceAsStream("/foo/bar.xml")" without a change.
The suggested workaround "Thread.currentThread().getContextClassLoader().getResourceAsStream("/foo/bar.xml")"
only caused that the Testcase does NOT even work in Eclipse anymore, what seems obvious to me cause "/foo/bar.xml" is
located in the JAR containing "MyClass".
Anyways, I think that a typical maven2 user wants "mvn test" to work as within the IDE and NOT digg into the problem and find
a workaround somewhere he has to adopt in order to keep going with maven2.
> 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, workaround-for-fork.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
[jira] Updated: (MSUREFIRE-115) Classloading problem for getting a
resource
Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=all ]
Brett Porter updated MSUREFIRE-115:
-----------------------------------
Fix Version/s: 2.3
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Kenney Westerhof (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_77008 ]
Kenney Westerhof commented on MSUREFIRE-115:
--------------------------------------------
Taking another look at the unit test, the line to read the resource should be
URL dateResource = getClass().getClassLoader().getResource( "java/util/Date.betwixt" );
and not
URL dateResource = Date.class.getResource( "/java/util/Date.betwixt" ); // or getResource("Date.betwixt");
Anyway, the Date.class.getResource(..) scheme only works with a flat classloader: all the resources
should be in the boot classpath (like java -classpath target/test-classes/:target/classes etc..).
In any classloading scheme where application resources are NOT in the boot/system classloader
something like this will not work, unless you add the Date.betwixt file to the JRE's rt.jar.
Since there are a lot of legacy apps out there that wrongly assume that everything is available in the system
classloader, we could modify the forked mode to use that. It'll still use the 2 classloader approach,
where surefire is in a separate child classloader, but everything else will be in the app classloader.
Child delegation won't work, since the Date.class classloader doesn't recognize that option.
It would require a major, probably breaking change, since the test classpath cannot be specified in the
property file passed to the forked instance, but has to be specified on the commandline. This can break
execution because the classpath will easily get too long to fit on a commandline.
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Carlos Sanchez (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66210 ]
Carlos Sanchez commented on MSUREFIRE-115:
------------------------------------------
Although this might be an incorrect use of the API, if it works in m1 and the IDEs it may be worth to check for a workaround in maven2
> 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Mark Holster (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66161 ]
Mark Holster commented on MSUREFIRE-115:
----------------------------------------
That's because finding a resource by the Class object difference from finding a resource by a Classloader object: The Class.getResource() adds a package prefix, or removes a leading "/" from the resource name. The ClassLoader.getResource() does not do this.
URL dateResource1 = contextClassLoader.getResource( "java/util/Date.betwixt" ); should find the resource with the contextclassloader.
> 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Wim Deblauwe (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66157 ]
Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------
I added 2 more tests, taking your suggestions into account.
{noformat}
public void testClassloading()
{
ClassLoader classLoader = getClass().getClassLoader();
System.out.println( "classLoader: " + classLoader );
URL resource = getClass().getResource( "/java/util/Date.betwixt" );
System.out.println( "resource: " + resource );
ClassLoader dateClassLoader = Date.class.getClassLoader();
System.out.println( "dateClassLoader: " + dateClassLoader );
URL dateResource = Date.class.getResource( "/java/util/Date.betwixt" );
System.out.println( "dateResource: " + dateResource );
assertNotNull( "the resource should not be null", dateResource );
}
public void testWithContextClassLoader()
{
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
System.out.println( "contextClassLoader: " + contextClassLoader );
URL dateResource1 = contextClassLoader.getResource( "/java/util/Date.betwixt" );
System.out.println( "dateResource1: " + dateResource1 );
assertNotNull( "the resource1 should not be null", dateResource1 );
}
public void testWithSystemClassLoader()
{
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
System.out.println( "systemClassLoader: " + systemClassLoader );
URL dateResource2 = systemClassLoader.getResource( "/java/util/Date.betwixt" );
System.out.println( "dateResource2: " + dateResource2 );
assertNotNull( "the resource2 should not be null", dateResource2 );
}
{noformat}
And this is the output I get:
{noformat}
Running CLTest
classLoader: org.apache.maven.surefire.booter.IsolatedClassLoader@1bf216a
resource: file:/C:/javatests/surefire-test/target/classes/java/util/Date.betwixt
dateClassLoader: null
dateResource: null
contextClassLoader: org.apache.maven.surefire.booter.IsolatedClassLoader@1bf216a
dateResource1: null
systemClassLoader: sun.misc.Launcher$AppClassLoader@133056f
dateResource2: null
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.11 sec <<< FAILURE!
{noformat}
According to what you say, the test with the context classloader should work but it does not.
> 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
[jira] Updated: (SUREFIRE-106) Classloading problem for getting a
resource
Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brett Porter updated SUREFIRE-106:
----------------------------------
Affects Version/s: 1.5.3 (2.1.3 plugin)
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: SUREFIRE-106
> URL: http://jira.codehaus.org/browse/SUREFIRE-106
> Project: Maven Surefire
> Issue Type: Bug
> Affects Versions: 1.5.3 (2.1.3 plugin), 2.0 (2.2 plugin)
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Assigned To: Kenney Westerhof
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: maven-surefire-plugin-2.2-UseSystemClassLoader.patch, surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "David Boden (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66488 ]
David Boden commented on MSUREFIRE-115:
---------------------------------------
I have exactly the same problem running tests for which use Apache DBCP version 1.2.1 (latest). The tests can't see the *.jocl configuration files.
I've followed it through with my debugger. The Thread context classpath gets set with the the test resources directory. However, Apache DBCP doesn't use the Thread context classpath to look for the .jocl files. Instead, it calls:
>> org.apache.commons.dbcp.PoolingDriver line 371 >>
java.io.InputStream in = getClass().getResourceAsStream(String.valueOf(name) + ".jocl");
I think we need that workaround to add classes onto the surefire boot classpath.
> 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, workaround-for-fork.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
[jira] Updated: (MSUREFIRE-115) Classloading problem for getting a
resource
Posted by "Christian Schulte (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=all ]
Christian Schulte updated MSUREFIRE-115:
----------------------------------------
Attachment: maven-surefire-plugin-2.2-UseSystemClassLoader.patch
Patch to enable the system class loader for tag maven-surefire-plugin-2.2
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: maven-surefire-plugin-2.2-UseSystemClassLoader.patch, surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Updated: (MSUREFIRE-115) Classloading problem for getting a
resource
Posted by "Christian Schulte (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=all ]
Christian Schulte updated MSUREFIRE-115:
----------------------------------------
Attachment: surefire-2.0-UseSystemClassLoader.patch
Patch to enable the system class loader for tag surefire-2.0
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Kenney Westerhof (JIRA)" <ji...@codehaus.org>.
[ 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Mark Holster (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66519 ]
Mark Holster commented on MSUREFIRE-115:
----------------------------------------
While browsing through the issue's I noticed MSUREFIRE-123 and MSUREFIRE-121 are describing the same problem, and maby MSUREFIRE-109 too. The workaround works for MSUREFIRE-123, and I guess for the others too (no test case attached/uploaded).
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Christian Schulte (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_79526 ]
Christian Schulte commented on MSUREFIRE-115:
---------------------------------------------
I have similar problems (since more than a year!) but with the JDKs service provider lookup mechanism. At least Sun JDKs will lookup service provider files (META-INF/services) for charactersets by using the system classloader. This class loader can never have a reference to some artifact provided by surefire since it cannot be modified. Currently the surefire plugin documentation states:
By default, Surefire loads classes using the default Java mechanism. However, it can be set to use "child first" classloading, like a web application - meaning your dependencies take precedence over those in the JDK. Classes in the java.* and javax.* packages can never be overridden. The only use for this is so that code in the test classpath can override stuff present in the JDK or its "standard extensions" directory which is not in these restricted packages. This means effectively implementations of the various "service provider" interfaces in java such as the xml parser implementation used by jaxp, the cryptography providers, the socket implementation class.
This holds true as long as the JDK lookup mechanism for service provider files uses the context class loader. Sun JDKs do not! At least not for charactersets. They always use the system classloader. I really need a solution to enable the system class loader (e.g. pass the artifacts to the system classpath when forking via the -classpath argument). I attached two patches to this issue which will introduce a new maven-surefire-plugin parameter named useSystemClassLoader which will be set to false by default. When set to true the commandline classpath build by SurefireBooter will also contain all classpath elements from the maven plugin. Really. I had to disable unit tests for a project for more than a year now! There must be a way to enable the system classloader for JDKs which uses it for service provider lookups.
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Mark Holster (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66342 ]
Mark Holster commented on MSUREFIRE-115:
----------------------------------------
As far as I can see that option only chances the delegation order for loading the classes, but still uses the isolated classloader. Or am I missing something here???
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Adrian (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_65677 ]
Adrian commented on MSUREFIRE-115:
----------------------------------
I have a problem running tests using hibernate since it cannot load xml files that should be on the classpath. This might be the same 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Wim Deblauwe (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66171 ]
Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------
So very true, sorry about that.
so, I guess I will have to talk to the betwixt team to not use this construct:
Date.class.getResource( "/java/util/Date.betwixt" );
but use:
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
URL dateResource = contextClassLoader.getResource( "java/util/Date.betwixt" );
How I wished we used XStream in stead :(
> 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
[jira] Moved: (SUREFIRE-106) Classloading problem for getting a
resource
Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brett Porter moved MSUREFIRE-115 to SUREFIRE-106:
-------------------------------------------------
Affects Version/s: (was: 1.5.3 (2.1.3 plugin))
(was: 2.0 (2.2 plugin))
2.0 (2.2 plugin)
Fix Version/s: (was: 2.3)
2.3
Key: SUREFIRE-106 (was: MSUREFIRE-115)
Project: Maven Surefire (was: Maven 2.x Surefire Plugin)
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: SUREFIRE-106
> URL: http://jira.codehaus.org/browse/SUREFIRE-106
> Project: Maven Surefire
> Issue Type: Bug
> Affects Versions: 2.0 (2.2 plugin)
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Assigned To: Kenney Westerhof
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: maven-surefire-plugin-2.2-UseSystemClassLoader.patch, surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Closed: (MSUREFIRE-115) Classloading problem for getting a
resource
Posted by "Kenney Westerhof (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=all ]
Kenney Westerhof closed MSUREFIRE-115.
--------------------------------------
Assignee: Kenney Westerhof
Resolution: Fixed
Fixed in revision 488508. Added useSystemClassloader parameter that puts ALL test classpath elements
in the system classloader. This is the only safe way to do it.
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Assigned To: Kenney Westerhof
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: maven-surefire-plugin-2.2-UseSystemClassLoader.patch, surefire-2.0-UseSystemClassLoader.patch, surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Mark Holster (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_65715 ]
Mark Holster commented on MSUREFIRE-115:
----------------------------------------
I've tried to provide a patch for this issue, but after debugging for a while i'm not sure if this is a bug: The java.util.Date class is loaded by the system classloader while the resource is on the URLClasspath of the isolated classloader that surefire provides. Trying to find a resource in the isolated classloader from the system classloader will never work because of the classloading hierarchy.
As documented the surefire plugin runs the tests in the isolated classloader, and therefore (I think) this issue isn't a bug but a consequence of the classloading hiererchy. As far as I can see the only solution to this issue is not loading the tests in the isolated classloader but in the app- or system classloader. Can a surefire guru confirm this :)? Should I try to provide a patch that runs the tests outside the isolated classloader?
> 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Olivier Lamy (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_67344 ]
Olivier Lamy commented on MSUREFIRE-115:
----------------------------------------
The workaround says :
MyClass.class.getClassloader().getResourceAsStream("foo/bar.xml")
and not
MyClass.class.getClassloader().getResourceAsStream("/foo/bar.xml")
Note the "/" removed.
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Wim Deblauwe (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66272 ]
Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------
I would be most gratefull if you could do that. Maybe some option to turn off the use of the isolated classloader?
> 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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Wim Deblauwe (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66779 ]
Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------
Is it possible to put a snapshot with this fix somewhere so I can test it?
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Ronny Naess (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_76786 ]
Ronny Naess commented on MSUREFIRE-115:
---------------------------------------
Anything new in this matter?
I have testresources in two test dependent jars. My artifacts has who depends this test-jars containing needed resources has randomly success and failure. If I run "mvn -X test" I can se the log output listing my test classpath and it is correct. However that may not be the case. Two artifacts may run tests as expected (aka finding test resources) while the next artifact up for test may fail. I have listet the resources from the classloader and It proves that while the test classpath listing says my test-jar is there, the actual output (file read with ouput to screen) says something else. I have the same resources (file names not content) for main and test, and I have to list the file content to se the difference.
My current solution is to run the tests in Eclipse and skip them in maven so we can have successfully builds. I do not like doing it this way since this breakes the development process since a developer may forget to test or retest for that matter and with the risk of checking in code that may fail.
The strange thing is that it is so random. One time it may work and the next it may fail. I have tried fork and childclasspath settings and none worked.
> Classloading problem for getting a resource
> -------------------------------------------
>
> Key: MSUREFIRE-115
> URL: http://jira.codehaus.org/browse/MSUREFIRE-115
> Project: Maven 2.x Surefire Plugin
> Issue Type: Bug
> Affects Versions: 2.2, 2.1.3
> Environment: Maven 2.0.4
> Windows XP
> Reporter: Wim Deblauwe
> Priority: Blocker
> Fix For: 2.3
>
> Attachments: surefire-test.zip, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Tim Riley (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_69780 ]
Tim Riley commented on MSUREFIRE-115:
-------------------------------------
I seem to be experiencing this same issue when testing my JAXB 2.0.2 code. Where it runs perfect in the IDE but not in maven2. I have tried a bunch of different combinations between <forkMode> and <childDelegation> and nothing worked. Seeing how this issue is a Blocker are there any plans to correct this in a SNAPSHOT or future release (it is currently unscheduled).
> 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, workaround-for-fork.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
[jira] Updated: (MSUREFIRE-115) Classloading problem for getting a
resource
Posted by "Mark Holster (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=all ]
Mark Holster updated MSUREFIRE-115:
-----------------------------------
Attachment: workaround-for-fork.zip
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Carlos Sanchez (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66340 ]
Carlos Sanchez commented on MSUREFIRE-115:
------------------------------------------
The isolated classloader can be turned off with the childDelegation option
http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
In surefire 2.2 is false by default
> 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, workaround-for-fork.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
[jira] Commented: (MSUREFIRE-115) Classloading problem for getting
a resource
Posted by "Wim Deblauwe (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/MSUREFIRE-115?page=comments#action_66367 ]
Wim Deblauwe commented on MSUREFIRE-115:
----------------------------------------
I think so too, because I tried to use childDelegation, but it resulted in the same problem.
> 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, workaround-for-fork.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