Arch2Arch Tab BEA.com
Syndicate this blog (XML)

Configuring Eclipse for Automatic Deployment of Event Server Applications

Bookmark Blog Post

del.icio.us del.icio.us
Digg Digg
DZone DZone
Furl Furl
Reddit Reddit

Seth White's Blog | February 22, 2008   8:26 PM | Comments (0)


In my last entry, Configuring Eclipse to launch WebLogic Event Server, I described how to configure Eclipse so that one could easily launch a WL EvS server instance within the IDE.  In this entry, I will show how to configure Eclipse to build and automatically deploy an Event Server application to a running Event Server instance.  I have found that configuring Eclipse in this way makes it a great environment for doing iterative development of Event Server applications. In particular, it allows one to make full use of the Eclipse debugger to debug application code and quickly test code changes.

Before going any further, I would like to mention that BEA provides some nice tooling for the Event Server.  You may want to set things up yourself, however, if for some reason you cannot use the Event Server Eclipse plug-in.  In my case, I like to use Eclipse 3.3, but the plug-in requires Eclipse 3.2. 

I'm going to show how to automate deployment of the HelloWorld sample application that ships with the Event Server 2.0 release, but the same technique is applicable to any application that is using ant as its build tool.  First, I created an Eclipse project that contains the HelloWorld sample application.  The screenshot below shows this project's contents in the Package Explorer.  Next, I opened the ant build file for the project and added two new targets: install and uninstall.  Like the name implies, these targets uninstall and install the HelloWorld app.  They do this by invoking the command line deployment utility for the Event Server.

image


The code sample below shows a close-up of the install target. The URL port is the same as the netio port that is specified in the top-level server config.xml configuration file.  The username and password default to "wlevs" for the sample applications.  The install target assumes that the application bundle is available and ready to be deployed.  We shall rely on the existing dist target to create the application bundle in the "dist" subdirectory.

<property name="bundle.file.name" value="com.bea.wlevs.example.helloworld_2.0.0.0.jar"/>
<property name="wlevs.home.dir" value="${base.dir}/../../../.." />
<target name="install">
    <java classname="com.bea.wlevs.deployment.Deployer"
          classpath="${wlevs.home.dir}/bin/com.bea.wlevs.deployment.client_2.0.jar">
        <arg value="-url" />
        <arg value="http://localhost:9002/wlevsdeployer" />
        <arg value="-user" />
        <arg value="wlevs" />
        <arg value="-password" />
        <arg value="wlevs" />
        <arg value="-install" />
        <arg value="${dist.dir}/${bundle.file.name}" />
    </java>
</target>

After updating the ant build file, the next step is to configure Eclipse to invoke the new ant targets.  The figure below shows how to open the ant task configuration window.  Begin by right clicking the build.xml file in the Package Explorer view.

 

image

I recommend giving the ant run configuration a nice name since you will want to add the run configuration to your favorites list.  Here, I have chosen the name "helloworld_src install".  I have also selected three ant targets to be run: uninstall, all, and install.  I want them run in that order when this configuration is invoked, so I used to the"Target execution order" box to specify this.  In other words, the task will first uninstall the application, then run the all target to build a new application bundle, and finally deploy the new application bundle to the running server.  After making your changes, click Apply and then Close to save the changes without running the ant build yet.

image 

Next, let's add our new ant task to the favorites list.  The figure below shows how to open the "Organize Favorites" window.

image

Click "Add..." and then select the ant task that you want to add.  Click OK twice.

image

 

Next, open the run box and run the helloworld server.

image

You should see the output from the server in the Eclipse Console view.

image

 

Now, let's make a simple code change before redeploying the application.  I have added some text, " After redeploy: ",   to the message printed by the HelloWorld application.

image

Now, select the "helloworld_src install" and target from the favorites menu.

image

You should see the message printed by the application change once the application is redeployed, as in the figure below.

image

 

Eclipse remembers the last task run from the favorites list, so you can build and automatically redeploy the application repeatedly by simply clicking the favorites icon on the menu bar.  If you want to shut down the server, simply close the console view.  To summarize, the basic steps  were:

  1. Add the install and uninstall targets to the ant build file.
  2. Create an ant run configuration to invoke the new targets.
  3. Add the run configuration to the favorites menu.
  4. Invoke ant to build and redeploy the application within Eclipse.

I have been using this style of eclipse config for several months and found that it works well.  I can generally rebuild and redeploy my applications in 10 seconds or so, but this will vary depending on the application complexity, of course.  

Technorati Tags: ,

Comments

Comments are listed in date ascending order (oldest first) | Post Comment



Only logged in users may post comments. Login Here.

Powered by
Movable Type 3.31