Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Note:

  • These instructions assume you are using DSpace 1.5.x in the NetBeans IDE.
  • DSpace 1.4.x and previous are not covered.

Table of Contents:

Installing NetBeans

NetBeans 6.8 (or latest version) is recommended for both performance and features. Download it from http://www.netbeans.org/.

Choose either the 'Java SE' or 'Java' version. The 'Java' version has more features (such as editing JSPs), and although the GlassFish / Tomcat runtimes will be downloaded, you don't have to install them. If you choose the 'Java SE' version, you can always install those extra features later (as plugins).

Now simply run the downloaded installer.

Note: If you are running on Linux/Unix, you will need to make the downloaded script executable (e.g. chmod +x netbeans-version-full-linux.sh).

Subversion Client

Subversion support is already included in NetBeans. However, it requires that the command line client is installed and available on your local machine.

  • For most Linux distributions, you should be able to just install the Subversion client available in your distribution's repositories.
  • For Windows, there is now a 'Bundled Subversion Client for Windows' Plugin which you can install from within NetBeans
    • Go to Tools -> Plugins to install the plugin.
  • For Windows/RedHat/Solaris, CollabNet also offers free Subversion downloads that are specifically tested with NetBeans: http://www.collab.net/downloads/netbeans/ (Free to download, but require that you register first. Registration is also free, but requires a valid email address)

Install Maven Support

NOTE: For NetBeans 6.7 and above, Maven support comes out of the box. So, you do not need to install any Plugins!

From the "Tools" menu, select the "Plugins" entry. This will open the Plugin Manager - from here, select the "Available Plugins" tab. This should list an entry for "Maven" - check the box next to it, and click on 'install'.

Integrate an External Installation of Maven

Although not required, it's recommended to install an external version of Apache Maven. This will ensure that you are using the version of Maven which DSpace supports. (DSpace 1.5.x works best with Maven 2.0.8. You should check the latest pre-requisites if you are using a later version of DSpace)

  • First, install Maven:
    • For most Linux distributions, you should be able to just install the Maven client available in your distribution's repositories.
    • For all other operating systems, you can install the latest version from the Apache Maven site.
  • Configure Netbeans to use your external Maven:
    • Go to the "Tools" menu, and select "Options" (on OS/X, this is "NetBeans" -> "Preferences")
    • Select the "Miscellaneous" section.
    • Select the "Maven" tab.
    • Directly under the "External Maven Home" field, you'll see a line that says "Using Default Maven Version:____". It's possible that Netbeans will already see your external version of Maven (if it's in your PATH). However, if it says that it is using the "embedded maven", then you'll want to fill out the "_External Maven Home" field with the location of your external installation of Maven.
    • Down near the bottom, you also need to fill out the location of your "Local Repository". This should be the location of the ".m2" directory under your user's home directory.
      • On Linux and OS/X, it should be located at ~/.m2/
      • On Windows, it should be located at C:\Documents and Settings\username\.m2 (Windows XP) or C:\Users\username\.m2 (Windows 7)
    • All the other Maven settings should be fine as their defaults. Press "OK" to save your changes.

Checkout DSpace from Subversion

NetBeans makes the checkout and configure process easy, as it does nearly everything for you.

  • Under the 'Team' menu, go to 'Subversion' and then 'Checkout'. Enter the URL for the DSpace Subversion repository: http://scm.dspace.org/svn/repo/dspace, and click on the next button.
  • Next to 'Repository Folder(s)', click on 'Browse', and browse to the version of DSpace you wish to checkout. A few hints:
    • Stable, tested versions of DSpace are available under tags (e.g. tags/dspace-1_5_2)
    • Latest Bug Fixes (though slightly less stable) are available under branches (e.g. branches/dspace-1_5_x)
    • Unstable code is available on trunk. It is not recommended that you checkout trunk unless you know what you are doing!
  • Choose a local folder to checkout to (or leave the default entry), and leave the 'Scan for NetBeans projects after Checkout' option selected, and click on 'Finish'.
  • When NetBeans completes the checkout, it will pop-up a dialog telling you that it found projects during the checkout. Choose 'Open Project' from the dialog. Select all the projects that you wish to open (hold down ctrl to select multiple), and click the OK button.

After the checkout has completed, you'll notice NetBeans considers each DSpace Maven "module" to be a separate project. So, you'll see separate projects for "DSpace XML-UI" and "DSpace JSP-UI", even though these are all checked out from the same source code.

Build DSpace from NetBeans

Remember, you build DSpace from within the dspace sub-folder (e.g. <dspace-src>/dspace). In NetBeans, this project is named "DSpace Assembly and Configuration", based on the name specified in its Maven configuration file (pom.xml).

If you do not see the "DSpace Assembly and Configuration" project opened (NetBeans may not have opened it by default), then open it manually:

  • Right click in your "Projects" window
  • Select "Open Project", and browse to the <dspace-src>/dspace/ directory. You should see the Project Name (on the right) specified as "DSpace Assembly and Configuration".
  • Click the "Open Project" button.

Once that project is opened, you can build DSpace by doing the following:

  1. Right-click on the "DSpace Assembly and Configuration" project
  2. Select the "Build" option (alternatively you may select "Clean & Build" to first clean out previous builds).
    You should be able to watch the status in the "Output" window at the bottom of NetBeans. The end result is that DSpace is built into the <dspace-src>/dspace/target/dspace-1.5.x-build.dir/ directory (you can verify this from the "Files" window in NetBeans, if you wish).

After building DSpace for the first time, you may still see red exclamation point icons (warning) next to some projects. In most cases, this is caused by NetBeans being unable to locate some of the DSpace third-party dependencies on your local file system. To fix this problem, do the follow for each project which has a red icon next to it:

  • Right click on the project
  • Select "Show and Resolve Problems..." (near bottom of pop-up menu)
  • Click on "Download Libraries" (assuming the problem is that "Some dependency artifacts are not in the local repository").
    NetBeans should then use Maven to find all the DSpace dependencies and download them to your local Maven repository (in your user's ~/.m2/ folder)

Install DSpace normally

After building DSpace, we need to use Apache Ant to install it. Unfortunately, this is an area where NetBeans is not very helpful (as we built DSpace using Maven, it will continue to assume all of our projects are Maven-based projects).

You have two options here:

  1. The easiest way to install DSpace may be to just follow the normal installation procedure in the DSpace System Documentation. NetBeans doesn't seem to have an efficient way to perform this installation, so it's easiest to just do it from the command line, as normal.
  2. Alternatively, you can use NetBeans to run the ant fresh_install command as follows:
    • Click over to the "Files" tab in the left hand window
    • Browse under the "DSpace Assembly and Configuration" project. You are looking for the target/dspace-<version>-build.dir/build.xml Ant configuration file.
    • Right click on the build.xml file and select "Run Target" => "fresh_install"
      • The above command will perform a fresh install of DSpace based on the settings specified in your target/dspace-<version>-build.dir/config/dspace.cfg file.
    • Finally, return to the normal installation procedure in the DSpace System Documentation for the commands to setup an initial DSpace Administrator, etc. from your newly created <dspace> installation directory.

Run DSpace from NetBeans with Tomcat

Once you have DSpace installed, you can run any DSpace web application (XMLUI, JSPUI, SWORD, LNI, etc.) from NetBeans after you integrate NetBeans with Apache Tomcat.

Integrate an External Installation of Tomcat

If you have Tomcat installed separately from NetBeans, you'll need to tell NetBeans where it's located.

  • First, you'll need to install the "Tomcat" plugin for NetBeans, if it isn't already installed.
    • Go to the "Tools" menu and select "Plugins".
    • Select the "Available Plugins" tab. This should list an entry for "Tomcat"
    • Check the box next to it, and click on 'install'.
    • Restart NetBeans
  • You'll now want to tell NetBeans where your Tomcat installation is located.
    • Go to the "Tools" menu and select "Servers".
    • Click the "Add Server.." button to add a new server
    • Select the type of Server (e.g. Tomcat 6.0) and click "Next >"
    • NetBeans will ask you for the "Catalina Home" location of this Tomcat Server. This is the location where Tomcat is installed (e.g. On Windows it may be "C:\Program Files\Apache Software Foundation\Tomcat-6.0"). You'll also need to give NetBeans your credentials for the "manager" role in Tomcat.
  • After configuring your Tomcat 6.0 server, you may want to reconfigure a few default settings.
    • Go to the "Tools" menu and select "Servers".
    • Select your "Tomcat 6.0" server.
    • On the "Connection" tab, you may wish to enable the HTTP Monitor option
      • This will start up HTTP Monitoring (in a new tab) in NetBeans, whenever you start this server. HTTP Monitoring may be useful to developers who wish to view all HTTP requests/responses that occur during their development process.

Run DSpace WebApp using Tomcat Integration

Once NetBeans knows about Tomcat, you can run your DSpace webapps through this Tomcat integration and even perform debugging of your DSpace web application. To do this, we'll need to perform some basic configuration of the web application project in NetBeans.

  • Select the project for the Web Application you wish to run through Tomcat (e.g. "DSpace XML-UI (Manakin) :: Web Application Resources (war)" for the XMLUI). This project*must* be a "(war)" based project, as Tomcat only runs WAR files.
  • Right click on your selected project and click "Properties"
  • From the Properties window, select the "Run" category.
    • From these Run settings, you'll want to specify the Server which this application should run on. Select your newly configured Tomcat server.
    • Also, specify a "Context Path". This should be the ending path on the URL. For example, specifying "/xmlui" will mean your web application will be available from "http://localhost:8080/xmlui"
  • Now, click over to the "Actions" category on the left.
    • You'll see a list of Actions on the right. Click on the "Run Project" action (as this is the one used to run your web application).
    • In that Action's "Set Properties" section, add a property to point it to your DSpace installation's configuration file (dspace.cfg). The following is an example on Windows, assuming that you've installed DSpace to "C:/Program Files/dspace-1_5/":
      • dspace.config="C:/Program Files/dspace-1_5/config/dspace.cfg" (make sure to include this entire line)
  • Finally, click "OK" at the bottom to save all your new project settings.

Now, test it out!

Right click on the project, and select "Run". This should re-build the project, start-up Tomcat, and open up your application in your default web browser.

BONUS: If you haven't already noticed, NetBeans will auto-rebuild your project in real-time while Tomcat is running. This means, if you want to edit a CSS or XSLT (for the XMLUI), you can edit it and just refresh your web browser. Your changes should show up in the browser almost immediately. (That being said, there are times when you will still have to restart Tomcat in NetBeans – usually after you haven't restarted it in a long time, or after an update to Java source code)

Debug DSpace WebApp using Tomcat Integration

Debugging a DSpace web application involves mostly the same setup as running it. The main difference here is that you need to configure the "Debug Project" settings (rather than the "Run Project" settings). So, similar to above, do the following:

  • Select the project for the Web Application you wish to run through Tomcat (e.g. "DSpace XML-UI (Manakin) :: Web Application Resources (war)" for the XMLUI). This project*must* be a "(war)" based project.
  • Right click on your selected project and click "Properties"
  • From the Properties window, select the "Actions" category on the left.
    • You'll see a list of Actions on the right. Click on the "Debug Project" action (as this is the one used to debug your web application).
    • In that Action's "Set Properties" section, add a property to point it to your DSpace installation's configuration file (dspace.cfg). Make sure to keep all existing properties in tact, and just add your new property. The following is an example on Windows, assuming that you've installed DSpace to "C:/Program Files/dspace-1_5/":
      • dspace.config="C:/Program Files/dspace-1_5/config/dspace.cfg" (make sure to include this entire line)
  • Finally, click "OK" at the bottom to save all your new project settings.

Now, we'll start our web application in Debug-mode. (Make sure to stop Tomcat first, if it is currently running)

  • Right click on the project, and select "Debug". This should re-build the project, start-up Tomcat in debug-mode, and open up your application in your default web browser. You should see a "Debugger Console" appear.
  • You can now add breakpoints to areas of your code. The debugger should automatically stop at those points and let you step through your code line-by-line.
    • * Note: Occasionally, the first time you perform debugging, the debugger doesn't connect properly with your Tomcat Server. If you find it's not stopping at your breakpoints, you may wish to "Attach" the debugger manually:
    • From the "Debug" menu, select "Attach Debugger.."
      • For the "Connector", specify "SharedMemoryAttach".
      • For the "Name", specify "tomcat_shared_memory_id" (without the quotes).
      • Click "OK" to save these settings
    • Finally, verify that Tomcat is specifying this "tomcat_shared_memory_id" field.
      • Go to the "Tools" menu and select "Servers"
      • Click on your Tomcat Server, and visit the "Startup" tab.
      • Make sure the "Shared Memory Name" setting is selected, and that the value is also "tomcat_shared_memory_id".
  • No labels