spring-loaded
Java agent that enables class reloading in a running JVM
I'd like to use hot swap with my Spring Boot project. Somehow I am not able to make it working by running it in my IDE (IntelliJ), despite of having this topic covered by documentation. I simply run the class with my main method with VM attributes:
-javaagent:/path/to/jar/springloaded.jar -noverify
My question is, how do I make it work? :-)
Further question is how to use spring loaded with Gradle and IntelliJ. I find it quite inconvenient to force the developer to download the JAR manually, place it somewhere and point to it with a JVM parameter. Is there any better way (should I configure my own task which does the job and run it from my IDE as a Gradle task)?
Source: (StackOverflow)
I have an issue where debugging stops working in Intellij, when applying Spring-loaded as a dependency to the maven plugin.
Situation 1 (working):
Using a autogenerated spring-boot maven (pom.xml) file with a declared "Spring-boot-maven-plugin" I can debug my my app using the debug-maven command in intellij. The pom file looks like this:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Situation 2 (not working):
Following the guide lines here: spring-boot-hot-swapping one should add a dependency for spring-loaded, to make use of spring-loaded. The pom file now looks like:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Debugging the same run-configuration as before does not work. The break-points simply never turns into a "checkmark" and the code never suspends. Code is now hotswapping as one would expect... If I remove the plugin-dependency again, debugging starts working again...
Please help me make situation two work!
IntelliJ 14.1.3 Ultimate, Java 7, Spring boot 1.2.4, Spring loaded 1.2.3
Source: (StackOverflow)
Unable to reload grails application at runtime, My current development environment:
Grails app version 2.4.3
JDK: 1.7.0_21
I have added following setting in my BuildConfig file
grails.servlet.version = "3.0"
grails.reload.enabled = true
Some links
After going through different stack overflow links such as,
What is affecting to reload app at runtime?
Source: (StackOverflow)
I am trying to get a simple Spring-Boot application to work with Spring Loaded and Gradle without any success. I have tried the following:
Using Spring-Boot with the bootRun
task simply reloads static resources just fine with a simple F5 in the browser
If I use bootRun
again and change a class through a text editor and the use compileJava
it doesnt work.
If I run it with IntelliJ Application
make a change in an existing controller and use the IntelliJ make
it works only for existing methods. Doesnt update new methods, change of signatures etc.
Using IntelliJ with VM argument:
-javaagent:C:\Users\myuser\.m2\repository\org\springframework\springloaded\1.2.1.RELEASE\springloaded-1.2.1.RELEASE.jar -noverify
Still does nothing.
Ideally, I would like to perform the process through using Gradle only - so I'm IDE independent
Please have a look at the Github project so you can see my sample code:
Sample Project
Just perform any changes in the DemoController
Source: (StackOverflow)
I've successfully setup a spring-boot-groovytemplates and actuator project.
However, when adding springloaded to buildscript/dependencies block, I get the following stracktrace when recompiling in IDEA
java.lang.NoSuchFieldException: classCache
at java.lang.Class.getDeclaredField(Class.java:1918)
at org.springsource.loaded.agent.SpringPlugin.clearCachedIntrospectionResults(SpringPlugin.java:162)
at org.springsource.loaded.agent.SpringPlugin.reloadEvent(SpringPlugin.java:127)
at org.springsource.loaded.TypeRegistry.fireReloadEvent(TypeRegistry.java:1767)
at org.springsource.loaded.ReloadableType.loadNewVersion(ReloadableType.java:405)
at org.springsource.loaded.TypeRegistry.loadNewVersion(TypeRegistry.java:845)
at org.springsource.loaded.agent.ReloadableFileChangeListener.fileChanged(ReloadableFileChangeListener.java:51)
at org.springsource.loaded.agent.Watcher.determineChangesSince(FileSystemWatcher.java:235)
at org.springsource.loaded.agent.Watcher.run(FileSystemWatcher.java:219)
at java.lang.Thread.run(Thread.java:695)
Any clues?
Source: (StackOverflow)
I have a Spring Boot application using a Gradle multi-project build. The basic setup is that we have two web services with on depending on the other. The Gradle builds run correcly, but when running bootRun
the application does not pick up changes to resource files or re-compiled source code (via Spring Loaded).
The project structure looks like:
main-application-project
-- web-app-1
-- web-app-2
The project web-app-2
depends on web-app-1
. That dependency is controlled in a build.gradle
file in web-app-2
.
dependencies {
compile project(':web-app-1')
}
The problem I'm looking to solve is to get bootRun
to pick up changes to resource files and to hot-swap compiled code changes. This did work before making the multi-project setup.
Source: (StackOverflow)
I'd like to change port number of my spring boot application using 'Debug Configurations' in Eclipse.
I have configured 'springloaded' using spring-boot-maven-plugin.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.2.7.RELEASE</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.4.RELEASE</version>
</dependency>
</dependencies>
</plugin>
I am using 'Maven Build' and running spring-boot application using 'spring-boot:run' goal.
To override default port '8080', I set 'server.port' to 8085 in 'Debug Configurations' parameter list.
But, the concern is the server is yet run on 8080.
Below are some logs I found,
[DEBUG] properties used {... -Dserver.port=8086 -B ... server.port=8086 ...}
...
INFO org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 8080 (http)
...
INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
INFO org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
INFO org.apache.tomcat.util.net.NioSelectorPool - Using a shared selector for servlet write/read
INFO org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat started on port(s): 8080 (http)
INFO org.demo.springloaded.Application - Started Application in 14.231 seconds (JVM running for 15.535)
Below are the cases when it works as expected.
- When I override same property in application.properties file, the application run on the desired port number.
- When I removed support of 'springloaded', the application run on the desired port number.
Can anybody help me to explain the behavior?
Source: (StackOverflow)
I am trying to use spring-loaded in my project. For that, in order to configure the javaagent and other VM options, in <tomcat-directory>/bin/catalina.sh
file, I put in an entry for the spring-loaded jar and other VM options.
Existing configurations :
#JAVA_OPTS="$JAVA_OPTS -javaagent:/home/Sam/Documents/apache-tomcat/ExistingJar.jar -Xms500m -Xmx500m -XX:MaxPermSize=256M "
Changed Configurations :
JAVA_OPTS="$JAVA_OPTS -javaagent:/home/Sam/Documents/apache-tomcat/ExistingJar.jar
-javaagent: /home/Sam/Downloads/Jar/springloaded-1.2.4.RELEASE.jar
-Xms500m -Xmx500m -XX:MaxPermSize=256M -Dspringloaded=verbose -noverify"
The permissions on the jar are set to 777.
Sam@L-21TWH32:~/Downloads/Jar$ ll
total 444
drwxrwxr-x 2 Sam Sam 4096 Oct 8 20:09 ./
drwxr-xr-x 6 Sam Sam 16384 Oct 8 20:09 ../
-rwxrwxrwx 1 Sam Sam 427010 Oct 8 20:08 springloaded-1.2.4.RELEASE.jar*
However, the tomcat does not even start with the new changes. It fails with no entry in the logs and I get no output when I do ps -aef | grep tomcat
.
What am I doing wrong ? Even if I try to start tomcat only with spring-loaded.jar javaagent, then it fails immediately, but it works fine with older configurations.
Once I have it started, I want to make hot swap changes using Remote Debug connections with IntelliJ.
Source: (StackOverflow)
I have a project that will run fine with mvn spring-boot:run
, and I would like the ability to hot swap automatically after compiling. I setup the dependency as follows:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.2.5.RELEASE</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.4.RELEASE</version>
</dependency>
</dependencies>
</plugin>
However, I'm not seeing changes in response to a recompile. Is something more needed?
Source: (StackOverflow)
I would like to use, on a new projet, spring-loaded.
I parametered the java agent on Eclipse in VM settings for Tomcat 8.
-javaagent:L:/APPLI_PW/.m2/repository/org/springframework/springloaded/1.2.1.RELEASE/springloaded-1.2.1.RELEASE.jar -noverify
I get the following error on Tomcat 8 startup
févr. 20, 2015 9:48:16 AM org.apache.catalina.core.StandardContext startInternal
GRAVE: Error during ServletContainerInitializer processing
javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:160)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
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:408)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1002)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassNewInstance(ReflectiveInterceptor.java:989)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:157)
... 8 more
Caused by: java.lang.NullPointerException
at org.springsource.loaded.TypeRegistry.getReloadableType(TypeRegistry.java:1681)
at specific.apache.web.tech.config.ServletInitializer.<clinit>(ServletInitializer.java)
... 15 more
Anybody have an idea to solve this problem ?
Thx.
Source: (StackOverflow)
I downloaded spring-loaded.jar and tried to set it up for IntelliJ but unfortunately it did not work.
So, here is my questions:
1) What needs to be done exactly to set it up?
2) How do I trigger hot-swap?
Source: (StackOverflow)
I was doing hot deployment using spring loaded, with setup command line arguments it is working fine. But I want to do it using properties file, so how can I configure spring loaded using properties file?
Source: (StackOverflow)
I would like to configure spring-loaded in Eclipse JUNO. I have downloaded the spring-loaded.jar and put it in the eclipse directory where the eclipse.exe is located.
I have opened the jetty build.xml
file and added the following to the target.
<jvmarg value="-javaagent:D:/eclipse/springloaded-1.2.0.RELEASE.jar"/>
Now, the spring-loaded is scanning even the pre-defined libraries (the jar files which are included in my project) which I don't want to, since I don't make any changes to them. So, I need to pass it an argument to scan only custom folders of my project. How could I do that?
I am getting the following error, when I simply include the above line.
[artifact:mvn] constituent[0]: file:/D:/maven/lib/aether-api-0.9.0.M2.jar
[artifact:mvn] Exception in thread "main" java.lang.VerifyError: (class: org/eclipse/aether/util/repository/DefaultProxySelector, method: getProxy signature: (Lorg/eclipse/aether/repository/RemoteRepository;)Lorg/eclipse/aether/repository/Proxy;) Illegal use of nonvirtual function call
Source: (StackOverflow)
I'm using windows 8.1 x64 Swedish. I tried to follow this https://www.youtube.com/watch?v=GTrNkhVnJBU guide on how to get STS to hot swap. I have Eclipse set to autobuild and I've checked that the class files are actually replaced in the target directory. I've added the javaagent parameter. I've also tested to start it from the commandline (a simple hello world) with my VM parameters and it starts although my username contains spaces. I've tried to move the springloaded.jar to a folder which doesn't contain spaces. Still no hot swap. To test it I rebuild my commandline hello world or in STS I alter a string and save the file. The class auto-builds but the web page still prints the old message. The STS installation directory is C:\dev\Apps\STS. The path of the .m2 repository has spaces in it. I've tried jdk 1.7.0_25, jdk 1.7.0_55 and springloaded-1.1.5.RELEASE.jar, springloaded-1.2.0.RELEASE.jar
Source: (StackOverflow)