Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rule agent not working with java7 #407

Closed
johanhaleby opened this issue Jul 24, 2015 · 3 comments
Closed

rule agent not working with java7 #407

johanhaleby opened this issue Jul 24, 2015 · 3 comments

Comments

@johanhaleby
Copy link
Collaborator

From manohar....@gmail.com on May 28, 2012 11:29:36

What steps will reproduce the problem? 1. Run a test using power mock rule agent on jdk7 What is the expected output? What do you see instead? The execution fails with the following stack trace.

java.lang.IllegalStateException: Unable to load Java agent; please add lib/tools.jar from your JDK to the classpath
at org.powermock.modules.agent.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:97)
at org.powermock.modules.agent.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:70)
at org.powermock.modules.agent.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:40)
at org.powermock.modules.agent. PowerMockAgent .initializeIfNeeded( PowerMockAgent .java:83)
at org.junit.runner.Runner.(Runner.java:40)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:227)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74) What version of the product are you using? On what operating system? powermock-module-junit4 1.4.12 and powermock-module-junit4-rule-agent 1.4.12 on osx 10.7.3 with jdk 1.7.0_04 Please provide any additional information below. Note that I've faced this issue when running the test using maven's surefire plugin. I have not faced this problem when running from within IntelliJ. The difference I've noticed is when running from maven, JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes() gets called which throws an exception, while running from IntelliJ JDK6AgentLoader.attachToThisVM() gets called which works fine.

I've made sure the rule agent jar is defined first in the classpath in both cases.

The issue disappears if I simply switch to java6.

Original issue: http://code.google.com/p/powermock/issues/detail?id=387

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on May 30, 2012 00:25:05

Is there a way for you to patch this?

Status: Accepted

@johanhaleby
Copy link
Collaborator Author

From ale...@abashev.ru on October 25, 2013 13:41:02

If want to run it at maven build then you could use this workaround

        \<plugin>
            \<groupId>org.apache.maven.plugins</groupId>
            \<artifactId>maven-surefire-plugin</artifactId>
            \<version>2.14</version>
            \<configuration>
                \<argLine>-javaagent:${settings.localRepository}/org/powermock/powermock-module-javaagent/${powermock.version}/powermock-module-javaagent-${powermock.version}.jar -XX:-UseSplitVerifier</argLine>
            \</configuration>
        \</plugin>

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on May 28, 2014 06:12:09

I've added this to the FAQ

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant