You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jamo Smith (JIRA)" <ji...@codehaus.org> on 2007/02/09 05:00:44 UTC
[jira] Created: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
ClassLoader.getSystemResource(String) returns null with valid resource
----------------------------------------------------------------------
Key: SUREFIRE-286
URL: http://jira.codehaus.org/browse/SUREFIRE-286
Project: Maven Surefire
Issue Type: Bug
Components: classloading
Affects Versions: 2.0 Report Plugin
Environment: Windows XP
Reporter: Jamo Smith
Priority: Minor
Attachments: mvntest.zip
src/main/java/org/mvntest/TinyGetter.java does this:
URL url = ClassLoader.getSystemResource("tiny.gif");
tiny.gif is located in
src/main/resources
a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
which fails with NPE (url is null)
I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
A full, isolated, maven2 project is attached.
Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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] Issue Comment Edited: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Stig Lau (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_101935 ]
Stig Lau edited comment on SUREFIRE-286 at 7/11/07 12:36 PM:
-------------------------------------------------------------
Can you check if this works:
this.getClass().getClassLoader().getResource("tiny.gif");
was:
Can you check if this works:
this.getClass().getResource("tiny.gif");
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.4
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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: (SUREFIRE-286) ClassLoader.getSystemResource(String)
returns null with valid resource
Posted by "Dan Fabulich (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dan Fabulich closed SUREFIRE-286.
---------------------------------
Resolution: Won't Fix
Fix Version/s: (was: 2.4)
This test passes as-is if you set useSystemClassLoader=true in the latest 2.4 trunk. Others have suggested other useful workarounds. It's annoying that you have to set useSystemClassLoader=true (it should really be the default), but that would cause a lot of other related problems, for example SUREFIRE-334. So, for now, you'll need to use one of the workarounds.
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Zachary Jones (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_88149 ]
Zachary Jones commented on SUREFIRE-286:
----------------------------------------
I am also having a problem with surefire classloading.
I had to hack the ServiceMix class:
org.apache.servicemix.http.processors.ConsumerProcessor.
I saved the hacked version as the same class name and the same package. This class does compile to target/classes. The ServiceMix jar that contains this class is included in my classpath after the target/classes directory (seen with -X)
When running mvn test, I get a test failure for the Test class that tries to create a ConsumerProcessor. We are expecting it to create "our" version of ConsumerProcessor, but it instead creates the ServiceMix version.
I have tried all the available usage options from the surefire plugin documentation to no avail. Through debug in Eclipse, I see through a watch expression (getClass().getClassLoader()) is always the IsolatedClassLoader, no matter what options we set.
This test passes in Eclipse, so I am pretty sure it is a classloading issue with the surefire plugin.
Thanks for your help in advance.
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.3
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Stig Lau (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_101935 ]
Stig Lau commented on SUREFIRE-286:
-----------------------------------
Can you check if this works:
this.getClass().getResource("tiny.gif");
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.4
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brett Porter updated SUREFIRE-286:
----------------------------------
Fix Version/s: 2.3
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.3
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Kurt T Stam (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_100864 ]
Kurt T Stam commented on SUREFIRE-286:
--------------------------------------
I just spend a day figuring out what was wrong with my config. Turns out that it was this classloading issue. My tests run fine in Maven1 and ant. I think this is a MAJOR bug!
--Kurt
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.4
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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: (SUREFIRE-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Clint Gilbert (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_113015 ]
Clint Gilbert commented on SUREFIRE-286:
----------------------------------------
I had the same issue, but using
this.getClass().getClassLoader().getResourceAsStream("my-resource");
instead of
this.getClass().getResourceAsStream("my-resource");
Did the trick. Thanks for the suggestion! It saved me lots and lots of frustration.
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.4
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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-286)
ClassLoader.getSystemResource(String) returns null with valid resource
Posted by "Brett Porter (JIRA)" <ji...@codehaus.org>.
[ http://jira.codehaus.org/browse/SUREFIRE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brett Porter updated SUREFIRE-286:
----------------------------------
Fix Version/s: (was: 2.3)
2.4
> ClassLoader.getSystemResource(String) returns null with valid resource
> ----------------------------------------------------------------------
>
> Key: SUREFIRE-286
> URL: http://jira.codehaus.org/browse/SUREFIRE-286
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.0 Report Plugin
> Environment: Windows XP
> Reporter: Jamo Smith
> Priority: Minor
> Fix For: 2.4
>
> Attachments: mvntest.zip
>
>
> src/main/java/org/mvntest/TinyGetter.java does this:
> URL url = ClassLoader.getSystemResource("tiny.gif");
> tiny.gif is located in
> src/main/resources
> a TestCase can be found in src/test/java/org/mvntest/TinyGetterTest.java
> which fails with NPE (url is null)
> I believe this TestCase ought to be successful, since tiny.gif should be in the classpath during tests (how else do you have a simulated test environment?). I tried placing tiny.gif in src/main/java, src/test/java and src/test/resources with no luck anywhere. Although I believe this should work even if it is only in src/main/resources
> A full, isolated, maven2 project is attached.
> Thanks, and I hope I'm not over looking something. If I am, I apologize in advance.
--
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