Breakpoints and maven options are ignored when using spring devtools - maven

I'm trying to use spring devtools for my project. When I add devtools dependency breakpoints stopped working and maven options are ignored. I'm using Netbeans.
I added dependency into pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
And this is the netbeans action for debug:
Executed goal: spring-boot:run
Profile: dev
Properties:
jpda.listen=maven
Env.MAVEN_OPTS=-Dflyway.enabled=false
Breakpoints and maven options (MAVEN_OPTS) are working fine without devtools dependency. Adding the devtools dependency causes "-Dflyway.enabled=false" option and breakpoints being ignored. The maven command with all arguments generated by Netbeans is the same, I can see it in the log output. Is there anything else I have to set for devtools?

I found the answer, the properties in action must be written this way (spring boot 2.0.0):
spring-boot.run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dspring.flyway.enabled=false
jpda.listen=true
For spring boot version < 2.0.0 it is:
run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dflyway.enabled=false
jpda.listen=true

Related

Issue running Kogito DMN TrafficViolationTest in my junit

I imported dmn-quarkus-example project into eclipse. the project compiles and shows no errors. when I run mvn clean quarkus:dev, I was able to test the rest endpoint through postman and it works.
but my junit in my eclipse fails with 404.
I read few blogs and updated my application.properties file with the following, still no luck
quarkus.http.port=9090
%dev.quarkus.http.port=9191
quarkus.http.test-port=8181
the other thing I had to do to get my junit working is added the following dependencies in the pom.xml
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
it working still not able to understand why?
it started working after
mvn clean install and tried maven update on eclipse.....
it random....
This sounds like Eclipse is not configured properly, in general; based on the provided information not possible to even say if it's something related to Quarkus, or just a general Eclipse configuration issue.
Moreover, tested locally with Eclipse 2019-12 and no special configuration and no special plugin, running the JUnit test works out of the box correctly, in the example screenshot below running the unit test of the REST interface for Kogito on Quarkus example:
Please ensure you have no Maven exclusion in your Eclipse configuration, and that Eclipse is allowing to run the necessary Maven phases with M2Eclipse (like running any Maven project with Eclipse)

Dependency listed in pom file not found in deployed project

I asked a question here that I think I may have found the root of. I have a Spring Boot app using a datasource, net.sourceforge.jtds.jdbc.Driver, that is supposed to be included transitively by Spring Boot 2.0.2 with spring-boot-starter-jpa. However, when I run
jar tf my.jar | grep jtds
the driver class isn't found (we don't have a maven executable on the server to list the classpath). Everything I do to inspect the classpath reflects that the jar isn't there.
I've done this in 2 scenarios: 1) When I didn't explicitly add the jar to my pom, I got the error reported in my previous post. 2) When I do add it explicitly to the pom, I get this error:
java.lang.IllegalStateException: Cannot load driver class: net.sourceforge.jtds.jdbc.Driver
Can someone tell me what's going on?? I am confounded as to why this class can't be found and loaded.
Please mind, that in the Spring Boot Parent POM the jtds dependency is only included in test scope.
If you want to use classes of this dependency also in your production code, please change the Maven scope to compile.
Ok, the problem was solved by adding the dependency with a runtime scope.
In child pom where jar is packaged, you should have
spring-boot-maven-plugin. and dependency as below:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
</dependency>
In parent pom :
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>${jtds.version}</version>
</dependency>

what property to configure in serenity.properties file to Run chrome driver in maven project?

I am using selenium with serenity framework with maven.
Earlier i had placed my chrome driver in resources/Drivers and configured
webdriver.chrome.driver = .\resources\Drivers\chromedriver.exe.
It worked fine for me.
Now i have configured chrome dependency in pom.xml as below:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.36.0</version>
</dependency>
Now this dependency will be in .m2 repository.
I am not getting what should i configure "webdriver.chrome.driver" in serenity.properties.
If i remove this property and run my project i get:java.lang.NoClassDefFoundError: org/openqa/selenium/ContextAware
Put this in your property file webdriver.driver = chrome.
And you only have to declare your driver as following, serenity will initial it for you:
#Managed
WebDriver webdriver;

intelij spring boot hot swap causes context reload

I am using Intellij 2017.2 with Spring Boot 1.5.4
When I recompile my current class with ctr+shift+F9, instead of the IDE doing a bytecode hotswap, the spring container gets reloaded.
On top of that, after the reload my RestConroller no longer works
I have tried adding / removing from my pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
please advise
I am not sure if this is a spring boot bug as of the new version, but I ended up disabling manually the hot reload via properties:
This is done by setting the following in your application.properties:
spring.devtools.restart.enabled=false
The official doc:
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable

Maven Spring project not executing due to ClassNotFoundException

I'm working on a Spring/Maven tutorial to test splitting up Spring bean definitions between multiple files. My issue is that mvn -X -e exec:java shows build failure, but running as a Java application within STS shows the proper output.
My project is set up as com.jason.basicOne, with com.jason as the groupId and basicOne as the artifactId. The only compiler warning within STS is due to an imported class not being used.
Things I've done:
Used the <import /> tags to reference the secondary files, and enabled the usage within Spring Properties.
Refreshed the project several times via mvn clean and mvn package
But the ClassNotFoundException still shows up for com.jason.App. What other things should I look for?
EDIT
I found the error. In my pom.xml, I use the exec-maven-plugin to enable execution via mvn exec:java on the command line. The plugin definition was set to a previous project, from which I cut and pasted to the new project. The updated package name was not included, which is why the project executed via STS and not command line.
Your example compiles correctly if you
1. check com.jason.App class. Should it read com.jason.basicOne.App instead?
2. see if your pom.xml has right spring jars.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
Make sure your ".m2/" does not have an old spring which is referenced by your pom.xml

Resources