netbeans - matisse - fix invalid components

Saturday, May 23, 2009

Netbeans' Matisse Swing editor is a great tool. Keeping it running is the challenge. That is, carefully ensuring that .form files are kept in sync with the .java files, and no external editing gets too trigger-happy. The other challenge, it turns out, can be when migrating to a different dev box / dev environment.
I was getting an error when trying to open forms that had opened fine in my previous environment, and I knew they were committed to my version control.

The error:

Error in loading component xxxx... no such property exists.

And then if you carry on to view the form, in navigator you get [invalid component] instead of classnames next to those components.

Infuriating when you know it should work. But I've found it to be only caused by one of 2 reasons:

  1. Compile the class! Ensure that every one of the beans that the form is trying to load is currently compiled (do 'clean and build' on the whole project if in doubt).
  2. Netbeans' JRE incompatible For example, my current project is in Java 6, and the projects were configured fine in Netbeans to use Java 6. However, Netbeans itself was launching in Java 5, which is fine, except that you then get the above error. It would be so easy for the Netbeans team to add this compatbility check one would think, but oh well. So, if Netbeans' JRE (tools> Java Platforms) is lower than your project JRE, change Netbeans' default runtime by either (as of NB 6.5):
    • running the IDE with the --jdkhome switch on the command line
    • or by entering the path to the JDK in the netbeans_jdkhome property of your INSTALLATION_DIRECTORY/etc/netbeans.conf file.


If these don't help, check out [user directory]/var/log/messages.log (eg. for OSX, user dir is '~/.netbeans/[version]/'), and your answer should lie in an exception thrown in there.