How to delegate all building and all executing to maven - intellij-idea

Lately (even after cache cleanup/reinstalls) I have issues with idea, where builds are failing, run configuration is failing. The problem is, that it is idea thing, maven builds just fine, run from cli runs just fine.
In idea I already checked "delegate build/run configurations to maven", and run configuration does not have any action to be done before build. Yet for some reason when I click run, it tries to download some libraries and then it fails. Second later java -jar from cli using previously outside of intellij build jar WORKS.
How to turn all these clever (and for me dysfunctional) stuff? I just want idea to run java -jar and that's it to minimize number of places, where it can fail. I know about possibility starting code externally from java and just connect with debugger, but I'd like to avoid it as it is not that convenient, and if I have ultimate edition, I'd like to be able to start debugging session from ide.
EDIT:
maven project is freshly updated, jdk is the same as one used maven. Yet for some reason project run produces:
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration] from ClassLoader
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
second later, java -jar using fat jar works.

Related

Application startup problems when running tests via the #QuarkusTest annotation

Reservation: I am not sure if this is a bug or a work limitation of the annotation #QuarkusTest. This is our first big project on this framework, so please do not judge strictly.
My team and I write a project using Kotlin, Quarkus as the main framework, Gradle as the build system and Smallrye GraphQL. We have an application that is covered with tests. The problem arises when we write integration HTTP tests for our EndPoints. The tests work out correctly, but only when we run them having the application started manually before. If we do not start the application using ./gradlew web:quarkusDev and put the #QuarkusTest annotation, which, according to the documentation, should run the application without any additional commands before running the tests, an exception occurs:
"Connection refused: no further information
java.net.ConnectException: Connection refused: no further information"
It seems like the application does not start at all.
This is the link to our small test project on github, which reproduces the problem.
We understand that requests should be sent to http://localhost:8081/mapins but it does not work. We get such response: "GraphQL Schema not generated. Make sure you have a GraphQL Endpoint. Go to https://quarkus.io/guides/microprofile-graphql to learn how". When we exclude the path from requests for autoconfiguration we get the same result as in the case when we send requests to http://localhost:8081/ - responses are just empty. We have already tried using quarkus.http.test-port but results are the same...
We searched for information about this problem, but the only thing we found was a bit similar question on StackOverflow, where the solution was - to connect "io.quarkus:quarkus-resteasy-reactive-jackson". We tried this option, but it did not help.
Maybe the problem is that our application is multimodule and needs to be started from concrete module and #QuarkusTest uses some kind of default command? ./gradlew web:quarkusDev has to be called for appropriate startup and maybe quarkus uses some other command during autoconfiguration. Is it possible to set starting command for tests manually?
Output of java -version:
Java 17, Kotlin 1.6.21
Quarkus version:
2.11.1.Final
Build tool (output of gradlew --version):
Gradle 7.4.2

Unable to load class 'kotlin.coroutines.Continuation'

This error keeps happening every once in a while in my Kotlin projects. I tried several Kotlin versions (1.3.41, 1.3.60, 1.3.72) but this seems to come up on any version and in various projects. Once it starts happening, I can't build any project.
Full error message:
Unable to load class 'kotlin.coroutines.Continuation'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt.
Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I have tried all the suggestions and none of it helped. When I click
"Re-download dependencies and sync project (requires network)", it says
Clicking "Stop Gradle build processes (requires restart)" restarts Intellij but doesn't help.
Closing Intellij and killing Java processes didn't help either.
While none of the linked suggestions in the error popup worked, running 'clean' gradle task manually did do the trick!
./gradlew clean
The error still comes up every once in a while but can be reliably fixed by running gradle clean.

"mvn clean install" failed in command line, but passed in intellij

New to java and intellij, pls forgive me if i cannot describe the issue clearly.
Brand new install of intellij, brand new import of the java project.
From beginning, seems the project builds fine in intellij, in the GUI there's that clean/compile/verify/install/... life cycles. I click clean, then install, it triggers the unit test and all passing. Now i go to the project root in the command line, "mvn clean install" also passing.
Now i make a change to a resource file, *.sql which is used for in-memory db setup for unit test. i click clean, then install, still passes successfully.
Now i go to the command line again, "mvn clean install" fails in unit test.
I'm so confused now, either way i'm doing the "clean", what's the cause and how should to fix it pls ?
BTW, after working in visual studio for so long, this java and intellij is giving me heart attacks, why the build system in java is so hard and messy ?
Your project is likely configured differently from the maven pom.xml file. When the two aren't configured the same, you'll have problems. I would guess that some dependency is configured correctly in the IntelliJ Project file, but not in the pom.xml. I usually have the reverse problem. I use only the pom.xml to specify dependencies, and rely on the maven plugin to refresh the project (eclipse).
With IntelliJ, it's been a few years, but I remember the same idea. Try deleting the project file, and importing an existing maven pom file. Then modify your dependencies using only the pom.xml and not IntelliJ's project interface. If the pom.xml is correctly defined, the project import will work first try. That heavily depends upon the previous developer working with the project.
Maven is actually a very powerful (if not quirky at times) build tool, and the differences between execution on command line or "inside" IntelliJ are usually simple to explain.
Please check:
you are running the same version of maven (check command line with -version, compare to intellij setup in settings
you are using the same local .m2 folder (local repo) for maven vs intellij
you are not running with any "Profiles" in intellij (check that none are ticked).
you are not skipping any tests because they end with "IT" (meaning Integration Test)
These are the common reasons for differences.
If you post a log of your failing build we might be able to help more.
ok, my friend found the issue, in Maven settings in intellij, there's a "Runner" page, there's a "Skip test" there. In my case it's checked, so the run in intellij skipped unit test (which should fail) and did all other stuff, made it looks like it's passing.
Still several puzzles to me, but this "Runner" -> "Skip test" fixed the issue.
Pretty upset with intellij.

Do we need to install JDK to run WebDriver's TestNG tests through command line?

I am new to Selenium/WebDriver and created a project which I can execute through Eclipse IDE successfully. Now, I plan to run the test through command prompt by creating the proper TestNG1.xml and making sure the testng-6.8.5.jar is correctly pointed in PATH. I even tried giving full path of the testng-6.8.5.jar. Unfortunately I keep getting the error,
Error: Could not find or load main class org.testng.TestNG
I don't have JDK installed (and I don't want to install) so wondering if JDK is mandatory to run TestNG tests from Command line? From above error it looks like it's not even trying to access the TestNG1.xml I have.
I plan to distribute these tests as group of files to my fellow Business Analyst who only have JRE installed on their machine.
Yes, you need JDK installed where you are going to run your Test Here is some documentation of TestNG
Having JRE is enough to run the TestNG tests, or no need to install JDK to run the TestNG tests through command line
the issue was with the testng-6.8.5.jar library as selenium-server-standalone-2.32.0.jar was allowing me to run the project with no errors.

Hudson CI: cannot test grails-app

I've tried in each and every way to test a grails-app using hudson. I've tried testing with maven, I've tried testing with the grails plugin and I've tried testing with a shell builder it seems that building via shell is the only thing that works..
Every time I get the same error:
org.hibernate.HibernateException:
contains is not valid without active
transaction
But If i go to a shell and type
grails test-app
everything runs fine.
Does anyone have any idea on what's going on?
I'm using CentOS with Java 1.6, no slaves, just a simple hudson deploy over Tomcat6.
I've tried both with maven and grails builder, both fail.
Edit: it seems that if I run both unit and integration tests on the same command (either with grails or with mvn) the integration tests fail always.
Hudson/Jenkins usually just use the command line for executing grails plugins (You should be able to confirm that from the build output). You could probably add a pre build step to dump the environment, so you can see if anything there (or in your own shell) cause it to be fundamentally different.
Otherwise try to log in as the hudson user and find the hudson workspace and repeat the process manually. That has been the easiest way to debug hard problems like this..
regards