We have already seen how to compile and run a basic GeoNetwork instance. Although we know that real developers will probably skip this step too, for new developers in GeoNetwork, it will be relief to have an IDE to work with. I know that many GeoNetwork developers use NetBeans or Intellij but as I am used to work with Eclipse, that’s what we are going to explore on this post.
First of all: Eclipse has better support for Maven projects on each version. So, to avoid headaches, just download the latest eclipse available.Eclipse has many installer tutorials, so I won’t stop here explaining how to run eclipse. I will just assume you know how to do it.
To run GeoNetwork from eclipse is very very easy. Just right click on the Package Explorer view to import -> As Maven Project over the folder you already had cloned on the last post:
There is still something Eclipse does not support right about GeoNetwork: we have a classes folder that Eclipse tends to misconfigure. So, go to that folder, right click and remove as source folder. To do this, go to the “web-app” project and right click on src/main/webapp/WEB-INF/classes. Select Build Path > Remove From BuildPath.
Then, completely remove the folder from the source code. Don’t worry, it’s git, you can recover it later. You can also do this by right-clicking on the folder and selecting Delete. Yes, you are sure you want to delete folder “classes“.
Now, update as maven project right clicking on the project “web-app” and selecting Maven > Update Project …
Once this finishes, you can restore the folder we previously removed. Go to the “web-app” project, right click on src/main/webapp/WEB-INF and select Replace With >HEAD Revision. Yes, you are sure.
Congratulations! You are ready to use Eclipse to modify GeoNetwork.
But wait, how do we run GeoNetwork inside Eclipse to be able to debug?
We have several approaches here. Remember the jetty command to run GeoNetwork from the console? It is available also inside Eclipse (right click on web-app and Run As > Maven Build) and you can add some maven variables to be able to run in parallel a debug watch to debug your code. You can also set up a Tomcat server inside Eclipse and run GeoNetwork from it. This second option is more easy for beginners, so that’s what we are going to do now.
First, you have to create a Tomcat server inside Eclipse. So, search for the “Servers” tab and right click on it. Select New > Server. You will see a windows offering different types of servers. We will select the Tomcat v.7.0 Server one. You will probably won’t have any server runtime environment configured for it, but you can “Add…” a new one. There are many tutorials for this, so we won’t stop here.
On the following window, you can select which applications to run. Obviously, you choose the one called “web-app” and Finish.
Now, you will have a new Server on the Servers tab. select it (left-click) and click on the green arrow just on the top of that tab. You will see on the “Console” tab all the output of GeoNetwork starting up. Once it is started, you can enter GeoNetwork the same way as before, using http://localhost:8080/geonetwork
Have fun customizing GeoNetwork!