NetBeans Platform – Duplicate pair in treePair error
I have previously written about the NetBeans Platform
I’ve been using a lot recently at work and so have found a lot of pain points when using the APIs. I’ll try to document some of the more vexing problems here for other programmers who might be facing the same problem.
One problem you will probably face while using the NetBeans Platform is an inscrutable error message when you start up your application, something to the effect of:
java.lang.IllegalStateException: Duplicate pair in treePair1: java.lang.Object pair2: java.lang.Object index1: 55 index2: 55 item1: null item2: null id1: 16309239 id2: 4ecfe790 at org.openide.util.lookup.ALPairComparator.compare(ALPairComparator.java:83) at org.openide.util.lookup.ALPairComparator.compare(ALPairComparator.java:54) at java.util.TreeMap.put(TreeMap.java:530) at java.util.TreeSet.add(TreeSet.java:238) at org.openide.util.lookup.AbstractLookup.getPairsAsLHS(AbstractLookup.java:322) at org.openide.util.lookup.MetaInfServicesLookup.beforeLookup(Met…
While it’s impossible to know from this error message, this really indicates that you had some sort of exception in the initializer of one or more of your TopComponents, leading to duplicate null entries in some internal set that NetBeans Platform maintains, leading to this error message. Fortunately, there is usually a “Previous” button on the exception window so you can see what caused the real problem.