Posted by: George Christopher | August 4, 2009

Flex returning ManagedObjectProxy instances instead of your Flex/Java Classes

Adobe-Flex-CS3-256x256

During my Flex-Java integration work I got the following error:

ERROR org.hibernate.property.BasicPropertyAccessor  – IllegalArgumentException in class: <classname>, getter method of property: <property>

When I analyzed this problem I found that flex was returning instances of mx.data.ManagedObjectProxy instead of my Java info objects. I tried for hours together to solve this problem but none of the sites could provide me an answer. After a long search I ended up here and found the answer.

Solution by Bill White:

If you find that the DataService is returning managedobjectproxy instances rather than the strongly typed actionscript objects you have created, make sure you have declared an instance of the actionscript class in your flex code, even if you are not going to use it. You need a reference to the class to create a dependency on it so that it will stay in the swf like this:

public var myclass:MyClass;

Having this statement in your Flex code should be enough to get the DataService to correctly translate your MyClass.java class into the corresponding Myclass.as class rather than the managedobjectproxy class.

This error could also get manifested as a ClassNotFoundException for the ManagedObjectProxy in the Java side. The solution to those problems are also the same as given above.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: