Drag-and-Drop Deployment to JBoss in NetBeans IDE 4.1

In a previous blog entry (Efficient Deployment via Ant Scripts from NetBeans IDE 4.1), I suddenly understood what deployment really means, thanks to my having to write an Ant script for this purpose:

 <target name="jboss-deploy" description="Deploy to JBoss">
      <copy file="${dist.dir}/${jar.name}" todir="${jboss.deploy.dir}"/>
 </target>

Since this target clearly does nothing more than copy an archive file (EAR, WAR, or EJB-JAR) to the server's deployment directory, it is 100% identical to manually copying the archive file from the directory where it is created to the directory from which the server can deploy it. Were it not for the fact that manually digging through the filesystem to find those directories is more cumbersome than creating the Ant script that does the same thing automatically, there'd be no point in writing the Ant script in the first place. But what if there were an easy way of finding those directories, from inside the IDE? Ah, but there is... thanks to the Favorites window! Three simple steps to set everything up:

  1. Click Ctrl-3 in the IDE and the Favorites window appears.
  2. Drag the window to the right side of the Source Editor.
  3. Right-click the Favorites node, which is the highest node in the window, select Add to Favorites, and browse to the JBoss server's deploy directory.

The result of the above steps should be the following (click to enlarge):

And now, after you've built the application, you can just drag the archive file from the Files window, across the Source Editor, and into the server's deploy directory. That's it! Mission accomplished -- you've deployed your application! (Note that the Source Editor has a cool vertical split-screen in the illustration above.)

It's a good idea to only start the server after you've dragged the archive file into the server's deployment directory. This way, you get the benefit of any application-related error messages that the server outputs into the IDE's Output window during start up. For example, if you start the JBoss server after you've dragged the application into it's deployment directory, the JBoss server will produce errors during start up when it can't find a jboss-web.xml file, if needed, or if a database server hasn't been started up.

Another cool thing that results from this setup is that undeployment is as simple as right-clicking an archive file in the Favorites window and choosing Delete. On top of that, any text files in the Favorites window can be opened in the Source Editor. This is particularly useful for XML files, because you can then use the Source Editor's XML validation. This is even more particularly useful when you're setting up a connection pool on JBoss, because the data source is defined in an XML file which you not only have to dig through the filesystem to locate, but -- if you open the file in a plain text editor -- which you also cannot validate. So far, though, the most significant advantage I've found to this way of working is that all the files I need are really accessible and everything is snugly integrated in the IDE -- without even a single Ant script.


Question of the Day. Charles Ditzel asks: "Could I add a menu item to kick off dbVisualizer from NetBeans?"

Answer: Of course. Any application that can be started by an operating system can be started by Ant. That's because Ant can call an application's executable. For example, an Ant script for starting dbVisualizer goes as follows:

  <target name="Start-App-DbVisualizer">
    <exec executable="C:\\Program Files\\DbVisualizer-4.2.2\\dbvis.exe" />
  </target> 

FYI, here are all my IDE-wide targets: ide-wide-targets.xml

After you create the Ant target for starting the dbVisualizer, right-click the target's node in the Files window, and choose Create Shortcut. Then you can add a menu item, toolbar button, or shortcut key which you can use to invoke the dbVisualizer.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today