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

Error when running test on IntelliJ IDEA #124

Closed
AlberTajuelo opened this issue Aug 3, 2017 · 7 comments
Closed

Error when running test on IntelliJ IDEA #124

AlberTajuelo opened this issue Aug 3, 2017 · 7 comments
Labels

Comments

@AlberTajuelo
Copy link

Hi,

I have updated Karate Version to last version released (0.5.0) in pom.xml file:

    <properties>
        <karate.version>0.5.0</karate.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit4</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

And with this version:

IntelliJ IDEA 2016.3.5
Build #IC-163.13906.18, built on March 6, 2017
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

When I launch a specific feature with Cucumber Plugin (https://plugins.jetbrains.com/plugin/7212-cucumber-for-java), I receive this error:

Exception in thread "main" java.lang.NoClassDefFoundError: javafx/collections/ObservableList
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetPublicMethods(Class.java:2902)
	at java.lang.Class.getMethods(Class.java:1615)
	at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:40)
	at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:86)
	at cucumber.runtime.Runtime.<init>(Runtime.java:92)
	at cucumber.runtime.Runtime.<init>(Runtime.java:70)
	at cucumber.runtime.Runtime.<init>(Runtime.java:66)
	at cucumber.api.cli.Main.run(Main.java:35)
	at cucumber.api.cli.Main.main(Main.java:18)
	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:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: javafx.collections.ObservableList
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 16 more

If I launch this with mvn clean test works fine.

Anyone has suffered this bug?

Thanks for all

@ptrthomas
Copy link
Member

@AlberTajuelo - this is strange, this hasn't been reported yet. I just tried IntelliJ and it seems to work fine:

IntelliJ IDEA 2017.1
Build #IU-171.3780.107, built on March 22, 2017
JRE: 1.8.0_112-release-736-b13 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

Can you try this experiment, bring up the UI following the instructions here: https://github.com/intuit/karate/wiki/Karate-UI - do you get the same error. Then would it be possible for you to try upgrade the JRE.

@AlberTajuelo
Copy link
Author

AlberTajuelo commented Aug 4, 2017

Hi @ptrthomas

Thanks for your response.

I have run it with a Karate-UI and I receive this error:

Error:(12, 12) java: cannot access javafx.application.Application
  class file for javafx.application.Application not found

I have been reading this StackOverFlow thread and I have found that "openjfx" is not installed by default when you install OpenJDK v8. and they recommend two options:

  • Install OracleJDK v8.
  • Install "openjfx" package.

For IntelliJ IDEA users, you have to do this following steps:

  • Select "File" > "Project Structure".
  • Move to "SDKs" tab and select your "1.8" Java.
  • Click on red minus button and then re-add the JDK
  • Now, you will have JavaFX related files needed and loaded by IntelliJ IDEA.

You have to make sure that you have this jar files in classpath:

  • /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
  • /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar

So, now it is working fine. It should be recommended in the extensive documentation to recommend to add this javafx library.

Thanks for your time @ptrthomas

@ptrthomas
Copy link
Member

ptrthomas commented Aug 4, 2017

Thanks a lot @AlberTajuelo - I will add a link to your comment in the doc.

EDIT: this problem should be permanently solved now with #656

@BalurQA
Copy link

BalurQA commented Sep 13, 2018

Hi @ptrthomas

Thanks for your response.

I have run it with a Karate-UI and I receive this error:

Error:(12, 12) java: cannot access javafx.application.Application
  class file for javafx.application.Application not found

I have been reading this StackOverFlow thread and I have found that "openjfx" is not installed by default when you install OpenJDK v8. and they recommend two options:

  • Install OracleJDK v8.
  • Install "openjfx" package.

For IntelliJ IDEA users, you have to do this following steps:

  • Select "File" > "Project Structure".
  • Move to "SDKs" tab and select your "1.8" Java.
  • Click on red minus button and then re-add the JDK
  • Now, you will have JavaFX related files needed and loaded by IntelliJ IDEA.

You have to make sure that you have this jar files in classpath:

  • /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
  • /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar

So, now it is working fine. It should be recommended in the extensive documentation to recommend to add this javafx library.

Thanks for your time @ptrthomas

I tried above steps in intelliJ, still issue is not resolved to me. On running runner class fine getting below error.

java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\xxxx\Documents\Automation\RESTAPI\IntelliJ%20Karate%20API\target\test-classes\examples\users\users.feature (The system cannot find the path specified)
at com.intuit.karate.FileUtils.toString(FileUtils.java:265)
at com.intuit.karate.cucumber.FeatureWrapper.fromFile(FeatureWrapper.java:74)
at com.intuit.karate.cucumber.KarateRuntimeOptions.getRuntime(KarateRuntimeOptions.java:83)
at com.intuit.karate.cucumber.KarateFeature.getRuntime(KarateFeature.java:69)
at com.intuit.karate.junit4.Karate.(Karate.java:101)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.io.FileNotFoundException: C:\Users\xxxxx\Documents\Automation\RESTAPI\IntelliJ%20Karate%20API\target\test-classes\examples\users\users.feature (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at com.intuit.karate.FileUtils.toString(FileUtils.java:263)
... 26 more

@ptrthomas
Copy link
Member

@BalurQA sorry cannot replicate. also think this is not related to original issue.

follow the instructions here please, thanks: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

@nikhila294
Copy link

Hi,

I have updated Karate Version to last version released (0.5.0) in pom.xml file:

    <properties>
        <karate.version>0.5.0</karate.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit4</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

And with this version:

IntelliJ IDEA 2016.3.5
Build #IC-163.13906.18, built on March 6, 2017
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

When I launch a specific feature with Cucumber Plugin (https://plugins.jetbrains.com/plugin/7212-cucumber-for-java), I receive this error:

Exception in thread "main" java.lang.NoClassDefFoundError: javafx/collections/ObservableList
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetPublicMethods(Class.java:2902)
	at java.lang.Class.getMethods(Class.java:1615)
	at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:40)
	at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:86)
	at cucumber.runtime.Runtime.<init>(Runtime.java:92)
	at cucumber.runtime.Runtime.<init>(Runtime.java:70)
	at cucumber.runtime.Runtime.<init>(Runtime.java:66)
	at cucumber.api.cli.Main.run(Main.java:35)
	at cucumber.api.cli.Main.main(Main.java:18)
	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:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: javafx.collections.ObservableList
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 16 more

If I launch this with mvn clean test works fine.

Anyone has suffered this bug?

Thanks for all

Use java version 1.8

@ptrthomas
Copy link
Member

@nikhila294 you are using a very old version of karate which is not supported any more. also please ask these kinds of questions on stack overflow

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

No branches or pull requests

4 participants