When I run Corda flow tests from IntelliJ, the tests fail with the following errors:
QUASAR WARNING: Quasar Java Agent isn't running. If you're using
another instrumentation method you can ignore this message; otherwise,
please refer to the Getting Started section in the Quasar
documentation.
and
java.lang.IllegalStateException: Missing the '-javaagent' JVM
argument. Make sure you run the tests with the Quasar java agent
attached to your JVM. See https://docs.corda.net/troubleshooting.html
- 'Fiber classes not instrumented' for more details.
How can I fix this?
Corda flows need to be instrumented using Quasar before they are run, so that they can be suspended mid-execution.
To achieve this in IntelliJ, you need to:
Create a run config for your tests
Open the run config and change the VM options to -ea -javaagent:PATH-TO-QUASAR-JAR
In the CorDapp example and templates, quasar.jar is located at lib/quasar.jar, so you'd use -ea -javaagent:../lib/quasar.jar
Alternatively, you can edit the default JUnit run config to use the Quasar javaagent by default, avoiding you having to do this every time you pick a new test to run.
This is a basic error that you get if you don't set Quasar, you need to select your test-> go to Intellij top bar-> Run -> Edit Configurations and then set up like this photo in VM options:
From template readme
We recommend editing your IntelliJ preferences so that you use the Gradle runner - this means that the quasar utils plugin will make sure that some flags (like -javaagent - see below) are set for you.
To switch to using the Gradle runner:
Navigate to Build, Execution, Deployment -> Build Tools -> Gradle ->
Runner (or search for runner) Windows: this is in "Settings" MacOS:
this is in "Preferences" Set "Delegate IDE build/run actions to
gradle" to true Set "Run test using:" to "Gradle Test Runner" If you
would prefer to use the built in IntelliJ JUnit test runner, you can
run gradlew installQuasar which will copy your quasar JAR file to the
lib directory. You will then need to specify -javaagent:lib/quasar.jar
and set the run directory to the project root directory for each test.
Btw, if you face same error in VSCode, you can add
"java.test.config": {
"vmArgs": ["-ea", "-javaagent:../lib/quasar.jar"]
},
to settings.json. The path ../lib/quasar.jar may be different in your project.
Related
I am have this Exception please help me!
"Error occurred during initialization of boot layer
java.lang.module.Find Exception: Module test not found"
But i write VM option "--module-path "D:\UT java\javafx-sdk-17.0.1\lib" --add-modules javafx.controls,javafx.fxml"
and i have module-info.java "
requires javafx.fxml;
requires javafx.controls;
requires javafx.graphics;
requires java.sql;
requires java.desktop;
requires jdk.jfr;"
i add my sdk. And if i create javafx demo project and execute him it work. and if i start change fxml file and change controller i have this exception.
I have IntellIJIdea 2021, javafx-sdk-17.0.1, jdbc jr 8,11,16
Steps to fix:
Delete the JavaFX sdk (you don’t need it).
Delete old Java versions (they are obsolete).
Update your IntelliJ IDE and IDE plugins to the most recent release, 2021.3.2+.
Create a new JavaFX project using JDK and JavaFX 17.0.2+.
Select Maven for the build system unless you know and prefer Gradle.
Do not set VM arguments, you don’t need them.
Adding modules via the --add-modules VM arguments is unnecessary when you have a valid module-info.java file.
The --module-path is still required so that the modules can be found, but Idea will provide the correct path for your modules automatically when it recognizes the modules through your Maven dependencies.
So you don't need to explicitly define the --module-path VM argument yourself for a Maven based build (that would be difficult to do anyway because the modules are all downloaded to different directories in your local maven repository).
Test it works following the Idea create new JavaFX project execution instructions.
Add additional modules one at a time by adding their maven dependency to pom.xml and the requires clause to module-info.java.
Ensure you synchronize the Maven and Idea projects between each
addition.
See, for example, this question on correctly adding the javafx.media module.
Adding other modules such as javafx.web, javafx.fxml or javafx.swing follows a similar pattern.
Test between each addition by building and running the project, to ensure you haven’t broken anything.
Copy your original source code into the appropriate package directories under the new project source directory:
src/main/java
Place resources in:
src/main/resources
following the Eden resource location guide.
Fix any errors, ensure everything compiles and runs, then test it.
In some other ci, for example, with Travis, it supports multiple JDKs test (e.g https://blog.travis-ci.com/support_for_multiple_jdks).
However, I'm not sure how can I make it under the GitLab ci.
Assume I have a java project, I want to make sure this project can both build and run correctly under jdk8 and jdk11, How can I do this in the Gitlab CI?
Many thanks!
One way to do this would be to define pipeline jobs with different images with required dependencies. You can use any public images from dockerhub. After quick search I choose for my yaml example codenvy/jdk8_maven3_tomcat8 (jdk8 + maven) and appinair/jdk11-maven (jdk11 + maven), I'm not sure they will work for you though.
tests_jdk8:
image: codenvy/jdk8_maven3_tomcat8
script:
- <your mvn test/build script>
tests_jdk11:
image: appinair/jdk11-maven
script:
- <your mvn test/build script>
If you can dockerize your environment you can use your custom images instead. Or you write some before_script which can install your project requirements to any os docker image. Would be perfect to reflect existing production environment.
If you have already instances where you test your project you can always connect them as Gitlab shell/docker runner and run your test on custom runner.
All depends on what resources you've got and what do you want to achieve.
I have multiple projects in my workspace. how I can set a startup project using the command line.
There's no built-in way to set the startup project in a persistent manner, but you can specify the project to run when using dotnet run with the --project option:
dotnet run --project /path/to/project
For changing startup project in VS Code, you should open launch.json file from Explorer window and edit "program" and "cwd" attributes.
When I select and run a test, the build fails with the message:
"Kotlin: Usage of '#JvmDefault' is only allowed if the flag -Xenable-jvm-default is enabled" for the following files.
corda/serialization/src/main/kotlin/net/corda/serialization/internal/OrdinalIO.kt
corda/serialization/src/main/kotlin/net/corda/serialization/internal/SerializationFormat.kt
corda/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializer.kt
I have cloned corda from my fork of corda/corda on github, and am on branch master, opened in IntelliJ as per instructions on the docsite. The JDK version is 1.8.0_152 and the Kotlin plugin is on version 1.2.41. I see that the -Xenable-jvm-default is enabled in the corda/build.gradle file. There are no local changes. Could you please advise on what I missed or need to do to fix this?
This can be fixed by invalidating IntelliJ's caches and restarting IntelliJ. See jetbrains.com/help/rider/Cleaning_System_Cache.html.
Make sure you are using the gradle runner to execute the tests on IntelliJ.
Navigate to Build, Execution, Deployment -> Build Tools -> Gradle -> Runner (or search for runner)
Windows: this is in “Settings”
MacOS: this is in “Preferences”
Set “Delegate IDE build/run actions to gradle” to true
Set “Run test using:” to “Gradle Test Runner”
I cant get SpringBoot autorestart get to work. I simply create http://start.spring.io/ Gradle project with DevTools selected and run 'gradle eclipse' to create eclipse project and 'gradle bootRun' and now I can do some change in project in Eclipse and this doesnt trigger auto restart at all. There is no message in bootRun console, no change detection. Any idea whats wrong here? I tried several times making starter project with http://start.spring.io and no way with auto restart ...
https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3
Gradle in Eclipse and Gradle on the command line use different directories for their compiled classes. The dev tools (launched via bootRun) will be looking in build/classes whereas Eclipse will be compiling your changes into bin/classes. Rather than launching your app using gradle bootRun, try launching it in Eclipse instead using Run As -> Java application.
In one terminal:
gradle build --continuous
In second terminal:
gradle bootRun
Reference: https://dzone.com/articles/continuous-auto-restart-with-spring-boot-devtools
BTW, I find it take longer time than the eclipse.