Tuesday, December 11, 2012

Fix: Add Apache Derby Nature in Eclipse does nothing

Tonight I had a strange issue with Eclipse: adding the Apache Derby nature to an Eclipse project wasn't working. Ordinarily, (provided that the Apache Derby Eclipse plugin is already installed) right-clicking a project and choosing Apache Derby->Add Apache Derby Nature to a project will do just that, enabling additional features such as starting or stopping the Derby network server.

This time, however, choosing that option appeared to do nothing. Rather than a menu full of commands, I was given only the option "Add Apache Derby Nature" in the Apache Derby context menu, which is what I had previously selected. I tried several times to add the nature in this manner, but to no avail.

The fix turned out to be simple. After grepping the directory of another project where I had successfully used Derby, I found that the change should have been reflected in my project's .project file.

The fix: if the Apache Derby nature isn't correctly added to a project through the Apache Derby menu, it can be done manually by editing the .project file (which is in the root directory the project). This is an XML file.

Find the <natures> node and add this line:

<nature>org.apache.derby.ui.derbyEngine</nature>

Here's how the entire <natures> node looks after the change in my project:



<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.apache.derby.ui.derbyEngine</nature>
</natures>

Then, just save the file. Problem solved.

7 comments:

  1. My god I searched all over the web for a quick fix and this is is! ++ mate!

    ReplyDelete
  2. Man, you are a true jenius!
    cant believe you have such an elegant solution for this annoying problem, Thanks a bunch!!!!

    ReplyDelete
  3. when i tried to startup derby network the following error was occured.
    Error: Could not find or load main class org.apache.derby.drda.NetworkServerControl.What should i do now?

    ReplyDelete
    Replies
    1. Add the Derby jar files (derby_home/lib) to projects build path

      Delete
  4. Yo just genius buddy. Awesome. Man You rock!! Double thumbs up!!!

    ReplyDelete
  5. people like you are an inspiration!

    ReplyDelete