flex2.compiler.mxml.lang.TypeCompatibility.checkSingleton

Categories: flex
Written By: sebi

Just a quick reminder after running the same cryptic error twice in a row.

!ENTRY com.adobe.flexbuilder.project 4 43 2011-01-11 13:05:06.488
!MESSAGE Uncaught exception in compiler
!STACK 0
java.lang.NullPointerException
	at flex2.compiler.mxml.lang.TypeCompatibility.checkSingleton(TypeCompatibility.java:98)
	at flex2.compiler.mxml.lang.TypeCompatibility.check(TypeCompatibility.java:79)
	at flex2.compiler.mxml.builder.Builder.checkTypeCompatibility(Builder.java:1015)
	at flex2.compiler.mxml.builder.Builder.checkTypeCompatibility(Builder.java:993)
	at flex2.compiler.mxml.builder.Builder.processRValueNodes(Builder.java:804)
	at flex2.compiler.mxml.builder.Builder.processPropertyNodes(Builder.java:605)
	at flex2.compiler.mxml.builder.Builder.processPropertyNodes(Builder.java:561)
	at flex2.compiler.mxml.builder.ComponentBuilder$ComponentChildNodeHandler.property(ComponentBuilder.java:221)
	at flex2.compiler.mxml.lang.ChildNodeHandler$CoreDeclarationHandler.property(ChildNodeHandler.java:188)

Looks familiar?

Using the – by the way loved and soo comfortable – new feature of the Flash Builder 4, to auto-generate event handler methods for mxml controls can lead to some unexpected result.
If you have states, or in my case custom mxml tags, and you hit the Generate blablabla handler popped up by the autocomplete, you can end up with some generated code in a completely wrong place in your code – the IDE can inject the code (with proper mx:Script markups) inside the state tags, chasing the compiler and itself to a crazy cycle with an un-cleanable internal build error. Simply moving that code out from the internal markup block, up, to the rest of the scripts solved the problem.

If you examine the workspace log (.metadata/.plugins/org.eclipse.ui.workbench/log), you can find the exception quoted in the post’s title. It’s annoying, quite hard to spot, and the error message doesn’t really tell anything about the cause – at least for me.

In this particular case the IDE put that import statement there …

<popups:content>
	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
		]]>
	</mx:Script>
	<mx:VBox id="questionHolder" height="300">
		<mx:Label text="{form.text}" color="#cccccc" fontSize="12" />
		<mx:Repeater id="questionsRepeater" dataProvider="{form.questions}" creationComplete="questionsRepeater_creationCompleteHandler(event)">
			<controls:FeedbackFormQuestionView question="{questionsRepeater.currentItem as FeedbackQuestion}" />
		</mx:Repeater>
	</mx:VBox>
</popups:content>

PS: someone also found this irritating: http://forums.adobe.com/thread/765436

Leave a Reply