How to hot reload bundles without Nuxeo IDE?

I've been using JSF facelets autorefresh and JBoss Seam hot reload to provide some hot reload abilities but I've read that Nuxeo IDE is able to hot reload bundles.

Are there any limitations and how can we do it using Ant or Maven ?

1 votes

2 answers

3040 views

ANSWER



Ok, I've been doing some research into this and I'll be updating this answer according to my findings:

I've been using release-5.4.2 but I found that starting on release-5.4.2-HF07 they backported “org.nuxeo.runtime.tomcat.dev.NuxeoDevWebappClassLoader”.

You can read some details in the NXP-7389

Basically to enable hot reload you should modify the conf/Catalina/localhost/nuxeo.xml l context configuration file and replace:

<Loader className="org.nuxeo.runtime.tomcat.NuxeoWebappLoader"
loaderClass="org.nuxeo.runtime.tomcat.NuxeoWebappClassLoader" />

by

<Loader className="org.nuxeo.runtime.tomcat.NuxeoWebappLoader"
loaderClass="org.nuxeo.runtime.tomcat.dev.NuxeoDevWebappClassLoader" />

Then you will be able to reload jars or bundles that ARE NOT in nxserver/bundles or nxserver/lib by specifyin the list of these bundles in the file nxserver/dev.bundles.

The format of this file is one file path per line (the file corresponding to the bundle JAR or directory). Thus, you can point to project bin directories in your Eclipse IDE, or on JARs outside nuxeo server.

To specify a third party JAR that is not a BUNDLE you must prepend its path with a !. YOu can use blank lines or lines starting with # for comments. Example:

/path/to/may/project1/bin
/path/to/may/project2/bin
!/path/to/may/thirdparty.jar
...

Please notice that if you're using the 5.4 branch according to NXP-7629 the automatic hot-reloading (which checks dev bundles every 2 seconds) was disabled by default. To re-activate, just edit the launcher.properties template file and set the timer property org.nuxeo.app.installReloadTimer to true. A JMX a bean is exposed for controlling the reset instead.

If you ant to use ant to update the dev.bundles file, you can use something like this:

    <target name="hotreload">
        <condition property="file.matches">
            <resourcecontains resource="${nxserver.dir}/dev.bundles" substring="${basedir}/target/classes" />
        </condition>
        <antcall target="update-dev-bundles"/>
        <antcall target="touch-dev-bundles"/>
    </target>

    <target name="update-dev-bundles" unless="file.matches">
        <echo message="Adding ${basedir}/target/classes to dev.bundles"/>
        <echo file="${nxserver.dir}/dev.bundles" append="true"
              message="${basedir}/target/classes"/>
    </target>

    <target name="touch-dev-bundles">
        <touch file="${nxserver.dir}/dev.bundles"/>
    </target>
3 votes



Note: if you use the SDK distribution of Nuxeo the classloader configuration is already setup for the dev mode.

To build the SDK distribution instead of the regular (production) you build:

cd nuxeo/
mvn install -Dmaven.test.skip=true  # build the bundles as usual

cd nuxeo-distribution/nuxeo-distribution-tomcat
mvn install -Psdk,nuxeo-dm  # build the SDK for DM

The resulting zip distribution is in the target/ subfolder. Once unzipped will just need to chmod +x the scripts in the bin/ folder (as maven is does not keep the executable flag when zipping).

10/12/2011

I've only seen the sdk profile in 5.4.3-I20111003_1046 will it be backported in a HF?
10/12/2011

No as this is not a bugfix.
10/12/2011

Well, I've got the hot reload working… should it run the deployment fragment and do a Seam hot reload as well ? It not a sample build.xml with these tasks would be great!
10/12/2011

I work with nuxeo-dm-5.4.3-I20111024_2229-tomcat. Format of the dev.bundles entries must be like this: Bundle:/path/to/may/project1/mybundle.jar

Check values of DevBundleType enum.

I've been through the source and it looks like you can not reference folders, only jar files. Can anybody clarify this?

11/21/2011


Though you might already be aware of this, hot reload with ant is presented in the following documentation entry: How to do incremental deployment (hot reload) in the JSF-Seam layer.

You also have to make sure that the bundles you want to reload are configured to be hot-reloadable: How to make a bundle able to hot-reload

0 votes



Thank you. I'm aware of that. I was looking for a way to reload all sorts of bundles, this would really take the pain out of development and constant restarts.
10/11/2011