Search
Calendar
May 2017
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
28293031  
Your widget title
Archives

PostHeaderIcon Hot Redeploy EJBs on JOnAS

Case

I ogten have to redeploy my JEE application on JOnAS. Basically, I stopped the server, copied the files (EAR, JAR, etc.), then started up again the server. I was fed up with implementing this method.
How to speed up?

Solution

Below is a proposal of solution, without any pretention (I am not fond of JOnAS…), based on an Ant script running under Maven. The code is commented, in a summary: build the EAR (or JAR, WAR, etc.), then copy it to JOnAS deploy folder, undeploy the beans, check which beans are still deployed, deploy the new version of the beans, check which beans are deployed:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>copyToJonas</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="jonas.root" value="${env.JONAS_ROOT}"/>
                                <property name="jonas.base" value="${env.JONAS_BASE}"/>
                                <echo>Copy files</echo>
                                <copy todir="${jonas.base}/deploy" overwrite="true">
                                    <fileset dir="${build.directory}/">
                                        <include name="*.*ar"/>
                                    </fileset>
                                </copy>
                                <echo>Undeploy beans</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -r ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
                                </exec>
                                <echo>Currently deployed beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -j"/>
                                </exec>
                                <echo>Deploy beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -a ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
                                </exec>
                                <echo>Currently deployed beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -j"/>
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

At first glance I assume I should swap the phases of copying file and undeploying beans. Anyway, this scripts works for me and allows to redeploy after each mvn clean install 😉

Leave a Reply