SDK3 - HOTSWAP - Doesn't work

cancel
Showing results for 
Search instead for 
Did you mean: 
gawel
Active Member II

SDK3 - HOTSWAP - Doesn't work

Hi, Hotswap seen doesn't work on any artifact genration :


HOTSWAP AGENT: 15:37:42.619 RELOAD (org.hotswap.agent.config.PluginManager) - Reloading classes [com.xxx.xx.controller.SiteCustomPostController] (autoHotswap)
Exception in thread "Thread-240" java.lang.IllegalStateException: Unable to redefine classes
        at org.hotswap.agent.config.PluginManager.hotswap(PluginManager.java:272)
        at org.hotswap.agent.plugin.hotswapper.HotswapperPlugin$1.executeCommand(HotswapperPlugin.java:94)
        at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:25)
Caused by: java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
        at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
        at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:170)
        at org.hotswap.agent.config.PluginManager.hotswap(PluginManager.java:269)
        ... 2 more

Anywhere, I don't try to create new method or classe, just add new space on java code.

Have you the same bug?

2 Replies
krutik_jayswal
Senior Member II

Re: SDK3 - HOTSWAP - Doesn't work

AFAIK with hotswap agent you will be only able to hot reload thing which are not modifying the schema of classes.

For example if you are modifying the code inside method it will work.But if you are renaming/adding new method then it will not be able to reload it.

You can use jrebel for that i guess.

gawel
Active Member II

Re: SDK3 - HOTSWAP - Doesn't work

Thinks you for your response.

I know this point. Step to reproduce :

1) create javadir-context.xml with this content :

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:component-scan base-package="com.xx.ged" />
    <context:annotation-config />

</beans>

2) Create Class :

@Component
public class YourClass{

    @Autowired
    SiteBusiness siteBusiness;

    public void importCsvDataToAlfresco(String text) {
        System.out.println("This is message from Alfresco : " + text);
    }
}

3) Start embedded server with hotswap

4) change the content text of printLn, and you have this error :

Exception in thread "Thread-240" java.lang.IllegalStateException: Unable to redefine classe