You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Kenney Westerhof (JIRA)" <ji...@codehaus.org> on 2005/09/26 12:31:11 UTC

[jira] Commented: (MNG-682) Surefire interferes with ClassLoader.getResource() and Class.getResourceAsStream() calls.

    [ http://jira.codehaus.org/browse/MNG-682?page=comments#action_47153 ] 

Kenney Westerhof commented on MNG-682:
--------------------------------------

Correct. I updated the exception reporting a bit and got this:

[ stacktrace ] -----------------------------------------------------------

java.io.IOException: Unable to find resource /META-INF/com.test.bugs.classloader/config.properties using classloader from class java.lang.Class
    at com.test.bugs.classloader.needs.NeedsClassLoader.getQuote(NeedsClassLoader.java:44)


The java.lang.Class is loaded using the root classloader, and doesn't have access to test-resources.

Btw, a while back I fixed the plugin-execution code to set the ContextClassloader correctly,
so the official way: Thread.currentThread().getContextClassLoader().getResource() should/can be used now.

> Surefire interferes with ClassLoader.getResource() and Class.getResourceAsStream() calls.
> -----------------------------------------------------------------------------------------
>
>          Key: MNG-682
>          URL: http://jira.codehaus.org/browse/MNG-682
>      Project: Maven 2
>         Type: Bug
>   Components: maven-surefire-plugin
>     Versions: 2.0-beta-1
>  Environment: Using a 2.0-beta-1 clean build (svn checkout on 20050730-1345) on linux (and XP) .
>     Reporter: Joakim Erdfelt
>     Assignee: John Casey
>      Fix For: 2.0-beta-3
>  Attachments: needs-classloader-clean.tar.gz, needs-classloader.tar.gz
>
>
> When using the Class.getResourceAsStream() or ClassLoader.getResourceAsStream() method calls in your own project, the tests succeed outside of m2 (in eclipse, on junit command line, and ant build).  But all tests fail when running under Surefire.
> A simple m2 project demonstrating this is attached.

-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org