JVMJ9VM007E Command-line option unrecognised: -javaagent - java

I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK.
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.chubb.prssearchpolicy.test.PRSSearchPolicyResourceTest.init(PRSSearchPolicyResourceTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:136)
at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:53)
at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
at mockit.Invocations.<clinit>(Invocations.java:26)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 24 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
at sun.tools.attach.WindowsVirtualMachine.<init>(WindowsVirtualMachine.java:64)
at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:64)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:213)
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:133)
... 29 more
For This I passes VM argument in run configuration but getting following error:
JVMJ9VM007E Command-line option unrecognised: -javaagent=C:\Users\junit\jmockit.jar
Has anyone faced this issue? Response will be greatly appreciated.

Can you try adding the following parameter -Dcom.ibm.tools.attach.enable=yes also jdk tools.jar file should be in your classpath
Also please have a look into this post which is strikingly similar to yours. According to the accepted answer there was a bug in one of the distributions which needs to have TestNG in the classpath as workaround.
AttachNotSupportedException while running jMockit tests on IBM JRE

Related

Failed to run elasticsearch --version command

Elasticsearch Version - 5.5.1,
Java Version - 8-u131
When I run the elasticsearch version command(or elasticsearch-plugin install), instead of displaying the version it shows this stacktrace:
>./elasticsearch --version
Exception in thread "main" java.lang.IllegalArgumentException: Invalid Configuration class specified
at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:198)
at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:159)
at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:55)
at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:175)
at org.elasticsearch.common.logging.LogConfigurator.configureWithoutConfig(LogConfigurator.java:99)
at org.elasticsearch.cli.Command.main(Command.java:85)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:170)
... 7 more
Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(Lorg/apache/logging/log4j/core/LoggerContext;Lorg/apache/logging/log4j/core/config/ConfigurationSource;)V
at org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration.<init>(BuiltConfiguration.java:58)
... 12 more
This seems like a case of missing/incorrect versioning of log4j jars packaged with elasticsearch 5.5.1 rpm.
It ships with 2.9.1 and missing method appeared in 2.7.x. Do you have the same exception with zip version? You might want to add set -x as second line in elasticsearch script file and check what is passed in -cp "$ES_CLASSPATH" - maybe it picks up some old jars from some other path.

Jenkins Cobertura build - NoClassDefFoundError

I have a test class ProcessorTest with the lines
JSONObject jsonObj = XML.toJSONObject(convert);
DBOb = (DBObject) JSON.parse(jsonObj.toString());
The XML class is from json.org. The class is used else where in the code without a problem.
Everything runs fine on localhost (i.e., all Maven and JUnit tests execute).
When I pushed to Jenkins I get this error:
Jenkins Error
Error Details
net/sourceforge/cobertura/coveragedata/TouchCollector
Stack Trace
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at org.json.XML.__cobertura_init(XML.java)
at org.json.XML.<clinit>(XML.java)
at ProcessorTest.classSetup(ProcessorTest.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 26 more
I'm using Jenkins 1.553 and the Cobertura plugin 1.9.6.
How do I fix this?
The project structure is like this:
-- project1
|
| - core
| - Tests (includes the tests that fail)
-- org.json
|
| - XML.class
When pushed to Jenkins I assume the org.json project is unavailable for the tests.
This exception and stack trace is misleading; it actually results from not having SLF4J + ch.qos.logback included in your classpath (the .ant/lib path or some other classpath available to ant). Cobertura (up to and including 2.1.1, at least) has a specific requirement for the ch.qos.logback SLF4J implementation. If this SLF4J implementation is not included, then the following stack trace can result:
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at [org.package.ClassName].__cobertura_init([ClassName].java)
at [org.package.ClassName].<clinit>([ClassName].java)
at [org.package.ClassName]Test.[method]([ClassName]Test.java:113)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
In my case, I already had slf4j-simple-1.7.14.jar in my .ant/lib classpath, and I needed to remove it and replace it with logback-core-1.0.13.jar and logback-classic-1.0.13.jar. After that, my instrumented test cases executed without this exception.
Seems like you have a Java version different in your Jenkins machine. Try to install exactly the same version than you have on local.
More info here: https://github.com/cobertura/cobertura/issues/52
This strange behavior could also be related to a different Maven version on your Jenkins build machine than you use locally. It would also be of interest which version of the cobertura-maven-plugin you are using in your pom.xml.
The pure Cobertura library itself (bundled with the maven plugin of your project) uses a bunch of dependencies which might be in conflict with the Cobertura integration of the Jenkins environment. Try to check for asm.jar in your dependency tree. Maybe this causes runtime trouble in the jenkins environment as well.
A setup that works in my institution (with projects that include org.json dependencies):
latest Jenkins version 1.596 in combination with the Jenkins Cobertura-Plugin 1.9.6
latest cobertura-maven-plugin maven plugin for various projects in version 2.6
My strong guess: It is not about the JSON stuff itself, but about the environment of your setup; your Jenkins version 1.553 is a bit outdated. I would advice you to go for an upgrade if possible with your admins/other projects.

Cannot open some applications in VisualVM

I am using Ubuntu 14.04 with Oracle JDK 8. I want to inspect performance of my application using VisualVM. I can inspect other applications like JDownloader but I can't inspect my own applications and Eclipse 4.3. Before I made fresh install of Ubuntu, I was using JDK 7 and I have no problem and using it without any configuration. It gives following log.
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor com.sun.tools.visualvm.core.ui.DataSourceWindowManager$1
java.lang.IllegalArgumentException: Unexpected composite type for ThreadInfo
at sun.management.ThreadInfoCompositeData.validateCompositeData(ThreadInfoCompositeData.java:372)
at sun.management.ThreadInfoCompositeData.getInstance(ThreadInfoCompositeData.java:68)
at java.lang.management.ThreadInfo.<init>(ThreadInfo.java:263)
at java.lang.management.ThreadInfo.from(ThreadInfo.java:794)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeBuilderViaFrom.fromCompositeData(DefaultMXBeanMappingFactory.java:1018)
Caused: java.io.InvalidObjectException: Failed to invoke from(CompositeData)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory.invalidObjectException(DefaultMXBeanMappingFactory.java:1457)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeBuilderViaFrom.fromCompositeData(DefaultMXBeanMappingFactory.java:1021)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$CompositeMapping.fromNonNullOpenValue(DefaultMXBeanMappingFactory.java:919)
at com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory$NonNullMXBeanMapping.fromOpenValue(DefaultMXBeanMappingFactory.java:133)
at com.sun.jmx.mbeanserver.ConvertingMethod.fromOpenReturnValue(ConvertingMethod.java:131)
at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:168)
at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:252)
Caused: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy8.getThreadInfo(Unknown Source)
at com.sun.tools.visualvm.jmx.impl.JmxSupport.isReadOnlyConnection(JmxSupport.java:95)
at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.isTakeThreadDumpSupported(JmxModelImpl.java:311)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.resolveThreads(ApplicationThreadsViewProvider.java:65)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:29)
at com.sun.tools.visualvm.application.views.threads.ApplicationThreadsViewProvider.supportsViewFor(ApplicationThreadsViewProvider.java:25)
at com.sun.tools.visualvm.core.ui.DataSourceViewsManager.getViews(DataSourceViewsManager.java:116)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.openWindowAndAddView(DataSourceWindowManager.java:169)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager.access$000(DataSourceWindowManager.java:30)
at com.sun.tools.visualvm.core.ui.DataSourceWindowManager$1.run(DataSourceWindowManager.java:80)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1393)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2005)
you should run visualvm on the same JDK version as your app, look at help->about->details (Java), mine was surprisingly jdk8 instead of jdk13 (I have both), so you can setup JDK version for visualvm manually etc/visualvm.conf, uncomment and setup parameter
visualvm_jdkhome=C:\Program Files\Java\jdk-13
run eclipse and your application with jvm parameters -Duser.language=en -Duser.country=us ...
then you will be able profile with jvisualvm.
for eclise put this two lines in eclipse.ini
-Duser.language=en
-Duser.country=us
maybe your pre installed Ubuntu had languge settings as english and you was ok.

Cause of Java Error Stack

How do I determine the cause of this error stack
Is it complaining about a missing Jar file ?
Thanks
Caught Exception while Creating QueueConnection from QueueConnectionFactory com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information. com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI. The Java(tm) MQI has thrown an exception describing the problem. See the linked exception for further information.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NLSServices.java:319)
at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLSServices.java:233)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:6889)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6277)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:285)
at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6233)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:120)
at connection.JMSConnection.makeQueueConnectionMQSeries(JMSConnection.java:228)
at connection.JMSConnection.makeQueueConnection(JMSConnection.java:614)
at testType.JMS_PTP.setupMsgTransportProtocol(JMS_PTP.java:335)
at testType.JMS_PTP.run(JMS_PTP.java:806) Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9546: Error return code received. [1=java.lang.reflect.InvocationTargetException[null],3=NativeConstructorAccessorImpl.newInstance0]
at com.ibm.mq.jmqi.JmqiEnvironment.processESESecurity(JmqiEnvironment.java:989)
at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:809)
at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:615)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:6881)
... 8 more Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.ibm.mq.jmqi.JmqiEnvironment.processESESecurity(JmqiEnvironment.java:896)
... 11 more Caused by: java.lang.NoClassDefFoundError: com/ibm/mq/headers/MQDataException
at com.ibm.mq.ese.service.ServicesFactoryImpl.createPolicyService(ServicesFactoryImpl.java:173)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.createServices(InterceptedJmqiImpl.java:224)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.<init>(InterceptedJmqiImpl.java:184)
at com.ibm.mq.ese.jmqi.ESEJMQI.<init>(ESEJMQI.java:117)
... 16 more Caused by: java.lang.ClassNotFoundException: com.ibm.mq.headers.MQDataException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 20 more Linked Exception: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9546: Error return code received. [1=java.lang.reflect.InvocationTargetException[null],3=NativeConstructorAccessorImpl.newInstance0]
-----------------------------------------------
In order to identify the cause of an error in a StackTrace it is common to read the stack from bottom to up and look for the Caused by words. That is the main reason of your problem. In your particular case:
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.headers.MQDataException
So that states that this class MQDataException was not found on your classpath. So you should put the jar that contain this class on the classpath of your application and it should work fine.
It is complaining about a missing class file. Where that file should be is up to you.
If its a standalone application, just install the WebSphere MQ Client in the location of your choice and add the just a few jars to the classpath as given here: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fjm10330_.htm . This would be easier I guess.

Jmockit NullPointerException with Junit

I'm trying to run a test that written by another programmer with JUnit in eclipse-indigo, and he is sure it works but when I try Jmockit there is a failure and I can't find a solution, yet.
I try to change jmockit.jar in classpath but not working. Do you have any idea about this problem?
Edit: When I use "ant test" in terminal there is no problem but if I click run as > JUnit test in my IDE I got this error.
Exception in thread "(Attach Listener)" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)
Caused by: java.lang.NullPointerException
at mockit.internal.state.TestRun.getInstance(TestRun.java:40)
at mockit.internal.state.TestRun.mockFixture(TestRun.java:111)
at mockit.internal.ClassFile.createClassFileReader(ClassFile.java:33)
at mockit.internal.annotations.AnnotatedMockMethodCollector.collectMockMethods(AnnotatedMockMethodCollector.java:39)
at mockit.internal.RedefinitionEngine.<init>(RedefinitionEngine.java:86)
at mockit.internal.RedefinitionEngine.<init>(RedefinitionEngine.java:110)
at mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:130)
at mockit.internal.startup.Startup.loadInternalStartupMocksForJUnitIntegration(Startup.java:112)
at mockit.internal.startup.Startup.initialize(Startup.java:79)
at mockit.internal.startup.Startup.agentmain(Startup.java:69)
... 6 more
Agent failed to start!
[WARN ][load ] agent library 'instrument' failed to init with result: 102
java.lang.RuntimeException: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
at mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:130)
at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:80)
at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:41)
at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:244)
at org.junit.runner.Runner.<clinit>(Runner.java:25)
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:30)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:455)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:684)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:391)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:122)
at mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:123)
at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:81)
... 16 more
java.lang.NoClassDefFoundError: org/junit/internal/runners/ErrorReportingRunner
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
As you stated in your comment you set an extra argument to the execution in ant.
Try setting
-javaagent:libtest/jmockit.jar
as a VM Argument (its the second input field on the Arguments tab) in the launch configuration for your junit test.
And make sure that the classpath is the same as in ant.
If you have the zip file of the distribution around, it should be pretty easy to just debug this and see why it's getting the NPE. Just add the source attachment as the zip file.

Categories

Resources