chiffchaff / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

PowerMockRule doesn't work on IntelliJ Idea #522

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I get error: PowerMockRule can only be used with the system classloader but was 
loaded by java.net.URLClassLoader

it's due to code:

static {
        if (PowerMockRule.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
            throw new IllegalStateException("PowerMockRule can only be used with the system classloader but was loaded by " + PowerMockRule.class.getClassLoader());
        }
        PowerMockAgent.initializeIfPossible();
    }

Original issue reported on code.google.com by iir...@gmail.com on 15 Oct 2014 at 8:25

GoogleCodeExporter commented 9 years ago
it happens only when you have a  big project and lot of maven dependencies, and 
then idea tries to save classpath to a file, and uses a custom classloader 
which loads this classpath

Original comment by iir...@gmail.com on 15 Oct 2014 at 8:45

GoogleCodeExporter commented 9 years ago
Same thing happens to me. Any workaround we can do?

Original comment by archmi...@gmail.com on 16 Jun 2015 at 12:51

GoogleCodeExporter commented 9 years ago
Possible workarounds:
- open .idea/workspace.xml and set dynamic.classpath to false (may not work if 
your classpath is too long)
- start tests not with idea but with idea Maven integration
- use something else for patching (eg AspectJ)

Original comment by iir...@gmail.com on 16 Jun 2015 at 1:03