Deploy to JBoss4, Tomcat 4, JRun4... Debug from NetBeans IDE 4.1!

Yes, NetBeans IDE can follow you everywhere. The only thing it can't do is your laundry (believe me, I've tried). So even though you've deployed to servers that the IDE doesn't "officially" support (such as JBoss4, Tomcat 4 and JRun4), not only can you deploy to them from within the IDE (as explained in previous blog entries), but you can also use the NetBeans IDE debugger to step through the source code on the server.

Here's what I did to get it all working:

  1. Build the application to the server's deployment directory. (One disadvantage of an IDE is that when you're just using menu items to do things like 'Build', you don't need to know what's really going on. As a result, you don't know. Now, with Ant, you have to know, because otherwise you can't tell Ant what you want it to do.) This is the script that I've been using:
     <target name="aaa_Build-To-JBoss" description="Build to JBoss">
         <mkdir dir="${build.dir.jboss}/WEB-INF/classes"/>
         <javac srcdir="${src.root}"
                   destdir="${build.dir.jboss}/WEB-INF/classes"
                   debug="on"
                   deprecation="${compile.deprecation}"
                   optimize="${compile.optimize}">
             <classpath>
                <path path="C:\\nb41\\netbeans\\enterprise1\\jakarta-tomcat-5.5.7\\common\\lib\\servlet-api.jar"/>
             </classpath>
         </javac>
    
         <copy  todir="${build.dir.jboss}/WEB-INF/classes">
          <fileset dir="${src.root}" excludes="${build.classes.excludes.jboss}"/>
         </copy>
     
         <copy todir="${build.web.dir.jboss}">
            <fileset dir="${web.root}" excludes="${build.web.excludes.jboss}" />
         </copy>
     </target>

    What's very important is the debug setting. Without it, debug information is not generated and, even though the NetBeans IDE debugger will be happily attached to the server, it will not be able to do anything with your code. (I've hard-coded it above, but will change it to a property later.)

    Here are the properties referenced above:

    build.dir.jboss=C:/jboss/jboss-4.0.1sp1/server/default/deploy/${ant.project.name}
    build.classes.dir.jboss=${build.dir.jboss}/WEB-INF/classes
    build.classes.excludes.jboss=\*\*/\*.java,\*\*/\*.form
    build.web.dir.jboss=${build.dir.jboss}
    build.web.excludes.jboss=${build.classes.excludes.jboss}
    build.lib.dir.jboss=${build.dir.jboss}/WEB-INF/lib
    src.root=src/java web.root=web compile.deprecation="off" compile.optimize="on"

    To round off this step, go to JBoss's deployment directory and make sure that your application is really there. (If it's there, it's good to go, because the server automatically deploys it for you.

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
23
24
25
26
27
28
29
30
   
       
Today