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

Mocking of JavaFX Properties failed with java.lang.NoClassDefFoundError: mockit/internal/expectations/RecordAndReplayExecution #246

Closed
lauritziu opened this issue Jan 5, 2016 · 5 comments
Assignees
Labels

Comments

@lauritziu
Copy link

I have the following simple test code:

import org.junit.Test;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import mockit.Mocked;
import mockit.NonStrictExpectations;
import mockit.Verifications;

/**
 *
 */
public class JMockitPropertiesTest {
    @Mocked
    private Model testModel;

    @Test
    public void testProperties() {
        new NonStrictExpectations() {{
            testModel.loadingProperty(); result = new SimpleBooleanProperty(false);
        }};

        testModel.loadingProperty().bind(new SimpleBooleanProperty(true));

        new Verifications() {{
            testModel.loadingProperty(); times = 1;
        }};
    }

    public class Model {

        private BooleanProperty loadingProperty;

        public BooleanProperty loadingProperty() {
            return loadingProperty;
        }
    }
}
´´´

If the test is executed the following exception occurs:

```java
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7535 "-Didea.launcher.bin.path=/Applications/development/IntelliJ IDEA 15.app/Contents/bin" -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "/Applications/development/IntelliJ IDEA 15.app/Contents/lib/idea_rt.jar:/Applications/development/IntelliJ IDEA 15.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/Viewer/pdf/target/test-classes:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/Viewer/pdf/target/classes:/Users/tfa/.m2/repository/com/sun/jersey/jersey-core/1.18.1/jersey-core-1.18.1.jar:/Users/tfa/.m2/repository/com/sun/jersey/jersey-client/1.18.1/jersey-client-1.18.1.jar:/Users/tfa/.m2/repository/com/sun/jersey/jersey-json/1.18.1/jersey-json-1.18.1.jar:/Users/tfa/.m2/repository/org/codehaus/jettison/jettison/1.1/jettison-1.1.jar:/Users/tfa/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.3-1/jaxb-impl-2.2.3-1.jar:/Users/tfa/.m2/repository/javax/xml/bind/jaxb-api/2.2.2/jaxb-api-2.2.2.jar:/Users/tfa/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar:/Users/tfa/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/Users/tfa/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2.jar:/Users/tfa/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.2/jackson-mapper-asl-1.9.2.jar:/Users/tfa/.m2/repository/org/codehaus/jackson/jackson-xc/1.9.2/jackson-xc-1.9.2.jar:/Users/tfa/.m2/repository/com/sun/jersey/contribs/jersey-multipart/1.18.1/jersey-multipart-1.18.1.jar:/Users/tfa/.m2/repository/org/jvnet/mimepull/mimepull/1.9.3/mimepull-1.9.3.jar:/Users/tfa/.m2/repository/org/codehaus/jackson/jackson-jaxrs/1.9.2/jackson-jaxrs-1.9.2.jar:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/workbench/controls/target/classes:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/workbench/core/target/classes:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/workbench/icons/icons/1.0.0-SNAPSHOT/icons-1.0.0-20151217.155945-9.jar:/Users/tfa/.m2/repository/com/google/code/findbugs/jsr305/2.0.2/jsr305-2.0.2.jar:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/workbench/resources/target/classes:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/workbench/contribution/1.0-SNAPSHOT/contribution-1.0-20151221.120221-1.jar:/Users/tfa/development/trunk/Forum/ForumClientPlatform/Core/JobService/JobService/target/classes:/Users/tfa/development/trunk/Forum/ForumClientPlatform/Core/ExceptionHandlingService/ExceptionHandlingService/target/classes:/Users/tfa/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/Users/tfa/.m2/repository/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/org/springframework/spring-aop/4.0.0.RELEASE/spring-aop-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/tfa/.m2/repository/org/springframework/spring-beans/4.0.0.RELEASE/spring-beans-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/org/springframework/spring-core/4.0.0.RELEASE/spring-core-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/org/springframework/spring-expression/4.0.0.RELEASE/spring-expression-4.0.0.RELEASE.jar:/Users/tfa/development/trunk/FORUM_Plugins/FullscreenPlugin/Document-modules/viewer/target/classes:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/workbench/voting/VotingService/1.1.4/VotingService-1.1.4.jar:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/services/business/DocumentService/1.1.12/DocumentService-1.1.12.jar:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/services/business/identifier/Identifier/1.1.4/Identifier-1.1.4.jar:/Users/tfa/development/branches/ForumViewer/4.1/SchwabingEventModules/EventService/target/classes:/Users/tfa/.m2/repository/net/engio/mbassador/1.1.10/mbassador-1.1.10.jar:/Users/tfa/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/tfa/.m2/repository/com/qoppa/pdfViewerAndImages/6.11.1/pdfViewerAndImages-6.11.1.jar:/Users/tfa/development/branches/ForumViewer/4.1/SchwabingPluginModules/SchwabingPluginFramework/target/classes:/Users/tfa/development/branches/ForumViewer/4.1/SchwabingPluginModules/PluginDomainModel/target/classes:/Users/tfa/.m2/repository/de/zeiss/dnd/DndJavaFx/3.4.8/DndJavaFx-3.4.8.jar:/Users/tfa/development/branches/ForumViewer/4.1/PreferencesService/target/classes:/Users/tfa/.m2/repository/de/zeiss/forum/preferences/ForumPreferencesClient/3.5.1/ForumPreferencesClient-3.5.1.jar:/Users/tfa/.m2/repository/de/zeiss/forum/archive/rest/FormAccessException/3.4.4/FormAccessException-3.4.4.jar:/Users/tfa/.m2/repository/de/zeiss/forum/common/BaseException/3.4.1/BaseException-3.4.1.jar:/Users/tfa/.m2/repository/de/zeiss/forum/common/JerseyClientFactory/1.1/JerseyClientFactory-1.1.jar:/Users/tfa/.m2/repository/org/springframework/security/spring-security-core/3.1.4.RELEASE/spring-security-core-3.1.4.RELEASE.jar:/Users/tfa/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/Users/tfa/development/branches/ForumViewer/4.1/SchwabingEventModules/PublicEventModel/target/classes:/Users/tfa/.m2/repository/de/zeiss/dicom/ZeissImaging/1.10/ZeissImaging-1.10.jar:/Users/tfa/.m2/repository/org/jnode/jnode-imageio/0.2.8-CZM-07/jnode-imageio-0.2.8-CZM-07.jar:/Users/tfa/.m2/repository/com/sun/media/jai_imageio/1_2-pre-dr-b04-lib-windows-i586-16_Oct_2009/jai_imageio-1_2-pre-dr-b04-lib-windows-i586-16_Oct_2009.jar:/Users/tfa/.m2/repository/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar:/Users/tfa/.m2/repository/com/sun/media/jai_codec/1.1.3/jai_codec-1.1.3.jar:/Users/tfa/.m2/repository/com/sun/media/mlibwrapper_jai/1.1.3/mlibwrapper_jai-1.1.3.jar:/Users/tfa/.m2/repository/de/zeiss/common/SharedClientBase/4.1.2/SharedClientBase-4.1.2.jar:/Users/tfa/.m2/repository/org/springframework/richclient/spring-richclient-core/1.1.0.5/spring-richclient-core-1.1.0.5-tests.jar:/Users/tfa/.m2/repository/org/springframework/spring-web/4.0.0.RELEASE/spring-web-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/org/springframework/richclient/spring-richclient-sandbox/1.1.0.5/spring-richclient-sandbox-1.1.0.5.jar:/Users/tfa/.m2/repository/org/swinglabs/swingx/0.9.3/swingx-0.9.3.jar:/Users/tfa/.m2/repository/com/jhlabs/filters/2.0.235/filters-2.0.235.jar:/Users/tfa/development/branches/ForumViewer/4.1/SharedClientBase/target/classes:/Users/tfa/development/branches/ForumViewer/4.1/SchwabingCoreServices/target/classes:/Users/tfa/.m2/repository/tablelayout/tablelayout/20070306/tablelayout-20070306.jar:/Users/tfa/.m2/repository/com/jgoodies/forms/1.2.1/forms-1.2.1.jar:/Users/tfa/.m2/repository/dcm4che/dcm4che-core/2.0.26/dcm4che-core-2.0.26.jar:/Users/tfa/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar:/Users/tfa/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/tfa/.m2/repository/org/springframework/richclient/spring-richclient-resources/1.1.0.5/spring-richclient-resources-1.1.0.5.jar:/Users/tfa/.m2/repository/org/springframework/richclient/spring-richclient-core/1.1.0.5/spring-richclient-core-1.1.0.5.jar:/Users/tfa/.m2/repository/org/hibernate/hibernate-core/4.1.4.Final/hibernate-core-4.1.4.Final.jar:/Users/tfa/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/tfa/.m2/repository/org/jboss/logging/jboss-logging/3.1.0.GA/jboss-logging-3.1.0.GA.jar:/Users/tfa/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.1_spec/1.0.0.Final/jboss-transaction-api_1.1_spec-1.0.0.Final.jar:/Users/tfa/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/tfa/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar:/Users/tfa/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/Users/tfa/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.1.Final/hibernate-commons-annotations-4.0.1.Final.jar:/Users/tfa/.m2/repository/org/springframework/spring-binding/1.0.5/spring-binding-1.0.5.jar:/Users/tfa/.m2/repository/ognl/ognl/2.6.9/ognl-2.6.9.jar:/Users/tfa/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/Users/tfa/.m2/repository/org/swinglabs/swing-worker/1.1/swing-worker-1.1.jar:/Users/tfa/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar:/Users/tfa/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/Users/tfa/.m2/repository/com/zeiss/forum/client/platform/core/http/1.0.0/http-1.0.0.jar:/Users/tfa/.m2/repository/org/jmockit/jmockit/1.20/jmockit-1.20.jar:/Users/tfa/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/tfa/.m2/repository/org/springframework/spring-test/4.0.0.RELEASE/spring-test-4.0.0.RELEASE.jar:/Users/tfa/.m2/repository/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar:/Users/tfa/.m2/repository/org/mockito/mockito-all/1.9.5/mockito-all-1.9.5.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.zeiss.forum.viewer.document.pdf.viewer.internal.ui.image.eval.JMockitPropertiesTest,testProperties
objc[8949]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

java.lang.NoClassDefFoundError: mockit/internal/expectations/RecordAndReplayExecution

    at com.sun.javafx.binding.ExpressionHelper.addListener(ExpressionHelper.java:54)
    at javafx.beans.property.BooleanPropertyBase.addListener(BooleanPropertyBase.java:75)
    at javafx.beans.property.BooleanPropertyBase.bind(BooleanPropertyBase.java:185)
    at com.zeiss.forum.viewer.document.pdf.viewer.internal.ui.image.eval.JMockitPropertiesTest.testProperties(JMockitPropertiesTest.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: mockit.internal.expectations.RecordAndReplayExecution
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 12 more
´´´

What can be wrong? The mentioned class is in the classpath, because other tests went well. Is there a special problem with JavaFX properties?
@rliesenfeld rliesenfeld added the bug label Jan 6, 2016
@rliesenfeld rliesenfeld self-assigned this Jan 6, 2016
@aelmhorst
Copy link

I am having the same issue with release 1.21 of jmockit. I get NoClassDefFoundErrors randomly on classes that are clearly in scope (they exist in the project itself). At first I thought it was related to classes I'm mocking, but it appears to be able to happen to any class. But it's definitely random. Works fine on my box, but not on the build machine. I haven't tracked down what the difference is. I'm reverting to jmockit 1.20, which has not given me this issue.

@lauritziu Version 1.20 does not give me this problem. I'd be interested in your results of trying 1.20.

@rliesenfeld
Copy link
Member

For me, the problem is reproducible with JMockit 1.20 (and should be with any older version as well).

@lauritziu
Copy link
Author

That's the same for me. The first time it occurred with 1.20. I hoped, that 1.21 have fixed it. I didn't. My impression is, that happens not randomly. @aelmhorst if you execute the code above the error just happen randomly? That's strange.

My environment:
Mac OS El Capitain
Java 1.8.0_60

@lauritziu
Copy link
Author

Unfortunately, this very cool framework is not usable for me at the moment. That's sad because I would like to promote it in my company.

@aelmhorst
Copy link

I've been battling with this issue, still with 1.20. My building is working now, and it may be fixed. Time will tell. Here's what I've learned:

I was able to initially get the build to start running again as follows

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <argLine>-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/1.20/jmockit-1.20.jar</argLine>
    </configuration>
</plugin>   

However, I am using Jacoco for code coverage and setting JMockit as the java agent for Surefire means that Jacoco wasn't running.

Finally what I did was to ensure that JMockit was specified prior to junit in the POM. That seemed to clear up my builds for today. Hopefully that fixes it. There seem to be a number of places where specifying JMockit before Junit is recommended, but according to the documentation that's unnecessary if using the @RunWith( JMockit.class) annotation, which I'm doing on the classes that were failing. However, it has cleared up my issues with builds for today.

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

No branches or pull requests

3 participants