Hotswap hot reloading (javascript, freemarker files, ...)

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

Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

I have a test project in Eclipse generated with maven archetype (allinone option).

I followed some tutorial on webscript in alfresco platform.

The example work fine but unfortunately the hot reloading ( configuration) of freemarker template or javascripts file does not work.

Hot reload of regular java class, also work fine, but hot reload of other resource does not work.

I can see (in the console) the hotswap message:

message Watch event 'ENTRY_MODIFY'

but when I try to test non change I do not see any changes.

For every small change (except java changes), I am forced to perform the whole procedure

clean install -DskipTests = true alfresco: run

I would appreciate your suggestions to solve the problem before starting with a serious development project.

Thank you for your help!

Best regards.

1 Solution

Accepted Solutions
ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

I #solved the problem!. Follow the solution (for others with the same problem).

1. I followed Using HotSwapAgent | Alfresco Documentation 

2. Setup a new AllInOne project whit eclipse 

3. Check patch the JVM whith DCEVM (Quick Start | HotswapAgent ) but is ok 

4. Setup in Eclipse a new Maven Build "Run Configuration" whith goal

clean package -DskipTests=true alfresco:run

VM arguments:

-Xms256m -Xmx2G -javaagent:[PATH_TO_HOTSWAP_AGENT]/hotswap-agent-1.0.jar -XXaltjvm=dcevm

In previous configuration I had used "hotswap-agent-core-1.3.0.jar" because the "hotswap-agent-1.3.0.jar" library did'nt work (a handful of exceptions after launch). I this case Alfresco doc. suggests to use 1.0 version of agent.  

I think this was the main problem!

5. Create a new configuration file named "hotswap-agent.properties" in the folder $PLATFORM_PROJECT_FOLDER/src/main/resource whith only the following line

autoHotswap=true

6. Run the Maven Build (prepared before: step 4)

7. The All-In-One project contains an HelloWorld Web Script implemented in Java and JS. Point the browser to http://localhost:8080/alfresco/s/sample/helloworld and we can see messages from Java and from JS.

Now I can edit and hot-reload:  Java class (HelloWorldWebScript), FreeMarker file (helloworld.get.html.ftl), Javascript file (helloworld.get.js).

When I save on eclipse the hot-reload happens immediately and I can see the changes on the browser !!

Thank you to Krutik for help.

 

View solution in original post

11 Replies
krutik_jayswal
Senior Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

As a temporary solution.

Refresh Webscript : http://localhost:8081/share/service/index //For share

Refresh Webscript : http://localhost:8080/alfresco/service/index //For alfresco repository

Clear Cache : http://localhost:8081/share/page/caches/report?clear=true //For share client side script...

I am also facing the same issue, but freemarker and javascript file are gettting hot reloaded on repository server.But facing same issues in share for freemarker and javascript file.

ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

Thank you for the answer.

I tried your solution but nothing has changed.

I got the same results: I changed a freemarker string but on the browser I saw the old version of string. The same happens on javascript files.

I tried also to insert the <cache> section on the xml descriptor for the web script:

<webscript>
  <shortname>Get all whitepapers</shortname>
  <description>Returns a list of active whitepapers</description>
  <url>/someco/whitepapers</url>
  <url>/someco/whitepapers.json</url>
  <url>/someco/whitepapers.html</url>
  <format default="json">extension</format>
  <authentication runas="admin">guest</authentication>
  <transaction>none</transaction>
  <cache>
    <never>true</never>  
    <mustrevalidate/>
  </cache>
</webscript>

I'm following the Jeff Potts's tutorial https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html

Bye.

krutik_jayswal
Senior Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

You need to hit refresh webscript button on bottom of URL...pt : http://localhost:8080/alfresco/service/index.....have you done that?

ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

Thanks a lot.

Yes, I have done it.

Nothing has changed.

I'm stuck on this problem!

ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

Thanks a lot.

Yes, I have done it.

 

Nothing has changed.

 

I'm stuck on this problem!

Like (0)  Reply Actions 
krutik_jayswal
Senior Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

Which alfresco SDK version you are using?

ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

I'm using Alfresco community edition 5.2 (the last version downloaded 1 month ago about)

ssciacca
Active Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

I #solved the problem!. Follow the solution (for others with the same problem).

1. I followed Using HotSwapAgent | Alfresco Documentation 

2. Setup a new AllInOne project whit eclipse 

3. Check patch the JVM whith DCEVM (Quick Start | HotswapAgent ) but is ok 

4. Setup in Eclipse a new Maven Build "Run Configuration" whith goal

clean package -DskipTests=true alfresco:run

VM arguments:

-Xms256m -Xmx2G -javaagent:[PATH_TO_HOTSWAP_AGENT]/hotswap-agent-1.0.jar -XXaltjvm=dcevm

In previous configuration I had used "hotswap-agent-core-1.3.0.jar" because the "hotswap-agent-1.3.0.jar" library did'nt work (a handful of exceptions after launch). I this case Alfresco doc. suggests to use 1.0 version of agent.  

I think this was the main problem!

5. Create a new configuration file named "hotswap-agent.properties" in the folder $PLATFORM_PROJECT_FOLDER/src/main/resource whith only the following line

autoHotswap=true

6. Run the Maven Build (prepared before: step 4)

7. The All-In-One project contains an HelloWorld Web Script implemented in Java and JS. Point the browser to http://localhost:8080/alfresco/s/sample/helloworld and we can see messages from Java and from JS.

Now I can edit and hot-reload:  Java class (HelloWorldWebScript), FreeMarker file (helloworld.get.html.ftl), Javascript file (helloworld.get.js).

When I save on eclipse the hot-reload happens immediately and I can see the changes on the browser !!

Thank you to Krutik for help.

 

krutik_jayswal
Senior Member II

Re: Hotswap hot reloading (javascript, freemarker files, ...)

Jump to solution

Its the alfresco version, SDK version is the one in which you are making the development.

 Below property represents the SDK version, It is in POM.xml.

<alfresco.sdk.version>

If above property is not there, than add the information about the parent pom.