Using Spring loaded in spring mvc framework
Asked Answered
D

2

6

I am having some issues using spring loaded with spring mvc. I added the spring loaded jar as a java agent on the server.

Now when I added new methods for instance in my case I added a new method testHomes(), and it gives me with this dialog. enter image description here

Below is my config enter image description here

enter image description here

I also checked Build Automatically I am using spring framework 4.2.5.RELEASE.

I checked from the following link SpringLoaded

Unlike 'hot code replace' which only allows simple changes once a JVM is running (e.g. changes to method bodies), Spring Loaded allows you to add/modify/delete methods/fields/constructors. The annotations on types/methods/fields/constructors can also be modified and it is possible to add/remove/change values in enum types.

IS there any way I can make this work ?

Regards,

Dissoluble answered 29/4, 2016 at 17:14 Comment(5)
Your configuration is perfect. But their are some internal issues with Spring loaded. So it can't load new methods with out redeployment. Try to change some lines inside the method. I think, it would work fine.Berezina
Yeah, when I change the body of existing method, its fine. A quick look at the spring loaded description caught my attention where it says "Unlike 'hot code replace' which only allows simple changes once a JVM is running (e.g. changes to method bodies), Spring Loaded allows you to add/modify/delete methods/fields/constructors. The annotations on types/methods/fields/constructors can also be modified and it is possible to add/remove/change values in enum types.".Dissoluble
I see in their documentation that you need to pass -noverify argument to the JVM, but I don't see that in your JVM config. It appears to not be optional.Selfsame
Tried adding -Djavaagent:springloaded-1.2.5.RELEASE.jar -noverify but it's still sameDissoluble
The popup is from the default code replacement NOT from Spring Loaded. So it appears as if your Spring Loaded, regardless of the configuration is either not working or default Hot Code Replacement is still active, kicking in before Spirng Loaded can do its job.Imprecate
D
2

What is Hot Code Replace?:

Hot code replace (HCR) is a debugging technique whereby the Eclipse Java debugger transmits new class files over the debugging channel to another JVM. In the case of Eclipse development, this also applies to the VM that runs the runtime workbench. The idea is that you can start a debugging session on a given runtime workbench and change a Java file in your development workbench, and the debugger will replace the code in the receiving VM while it is running. No restart is required, hence the reference to "hot".

When it works:

HCR only works when the class signature does not change; you cannot remove or add fields to existing classes, for instance. However, HCR can be used to change the body of a method. HCR is reliably implemented only on 1.4.1 VMs and later, or using any version of the IBM J9 VM. J9 is available in IBM products such as Websphere Studio Device Developer.

Troubleshooting the problem:

  1. Check you are running the application on a supported VM (taking note that the JVM that runs Eclipse may not be the same as the JVM that is running your Java application).

  2. Check whether automatic building turned on. Make sure that 'Project> Build Automatically' is checked.

  3. Check the following option being selected on Eclipse Tomcat Server.

    enter image description here

References:wiki.eclipse

Disbranch answered 8/5, 2016 at 16:37 Comment(1)
That's very informative but according to the SpringLoaded wiki, adding a method should work with springLoaded unless the information given on the site is not right.github.com/spring-projects/spring-loadedDissoluble
E
1

javaagent is JVM option. So it should be passed without D prefix. i.e. you need

-javaagent:springloaded-1.2.5.RELEASE.jar -noverify
Ephor answered 11/5, 2016 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.