1

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

2 Answers2

0

What do you see in the Console view in STS when you launch your app with spring loaded agent attached? Do you notice any messages about springloaded-1.2.0.RELEASE.jar not found or not able to open? Can you paste here your launch configuration VM arguments?

Once you modify the code and save looks like the successful hot swap should result in a message in the Console view that looks like this: [Loader@5cfab5b1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)

aboyko
  • 1,337
  • 1
  • 9
  • 11
  • If I start Tomcat using the "Debug As" option, hot swap of class files works and my hello world message changes. I want to get it to work for my production development setup. It uses Java 1.6.0_27 and I start Jetty (an old version from 2009) from the commandline using $mvn jetty:run -o. I then bulild my .war and upload it to the production server. I thought you could use spring-loaded to hot swap hello world messages using the most primitive hello world program without a web server at all. No Tomcat or Jetty. Mine is called ReadString.java and stops to get input from the user. I then recompile – user1312568 May 03 '14 at 14:19
  • Launch configuration VM arguments as requested -Dspring.liveBeansView.mbeanDomain -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=38900 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -javaagent:C:/Users/Anna\ Ohlsson/.m2/repository/org/springframework/springloaded/1.2.0.RELEASE/springloaded-1.2.0.RELEASE.jar -noverify – user1312568 May 05 '14 at 19:46
0
Lauch configuration arguments as requested:
-Dspring.liveBeansView.mbeanDomain
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=38900
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

Program arguments:
-javaagent:C:/Users/Anna\ Ohlsson/.m2/repository/org/springframework/springloaded/1.2.0.RELEASE/springloaded-1.2.0.RELEASE.jar -noverify

This is what the boot up messages look like. Someone requested to see them.
  .   ____          _            __ _ _                                                                         
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \                                                                           
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \                                                                          
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )                                                                        
  '  |____| .__|_| |_|_| |_\__, | / / / /                                                                         
 =========|_|==============|___/=/_/_/_/                                                                          
 :: Spring Boot ::        (v1.0.2.RELEASE)                                                                          

2014-05-03 16:11:42.407  INFO 7620 --- [           main] demo.Application                         : Starting Application on WindowsBurken with PID 7620 (C:\dev\STS_Workspace\demo\target\classes started by Anna Ohlsson in C:\dev\STS_Workspace\demo)
2014-05-03 16:11:42.447  INFO 7620 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@495d950b: startup date [Sat May 03 16:11:42 CEST 2014]; root of context hierarchy
2014-05-03 16:11:42.774  INFO 7620 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'org.springframework.boot.autoconfigure.AutoConfigurationPackages': replacing [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-05-03 16:11:43.530  INFO 7620 --- [           main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-05-03 16:11:43.741  INFO 7620 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2014-05-03 16:11:43.742  INFO 7620 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.52
2014-05-03 16:11:43.851  INFO 7620 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2014-05-03 16:11:43.851  INFO 7620 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1407 ms
2014-05-03 16:11:44.290  INFO 7620 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2014-05-03 16:11:44.293  INFO 7620 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-05-03 16:11:44.607  INFO 7620 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-05-03 16:11:44.680  INFO 7620 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto java.lang.String demo.SampleController.home()
2014-05-03 16:11:44.680  INFO 7620 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto java.lang.String demo.SampleController.greeting(java.lang.String)
2014-05-03 16:11:44.700  INFO 7620 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-05-03 16:11:44.701  INFO 7620 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-05-03 16:11:44.818  INFO 7620 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2014-05-03 16:11:44.841  INFO 7620 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
2014-05-03 16:11:44.843  INFO 7620 --- [           main] demo.Application                         : Started Application in 2.745 seconds (JVM running for 3.163)