Results 1 to 7 of 7

Thread: RemoteObjects: TypeError:

  1. #1

    Default RemoteObjects: TypeError:

    Hey there,

    I am using remoteobjects and configured it in application-context properly. Now it executes while my application is initializing and whenever this call happens, I am receiving this below error:

    TypeError: Error #1034: Type Coercion failed: cannot convert Object@203be679 to mx.messaging.messages.IMessage.

    Now I am unable to understand where should I put this type casting.

    Although, if I make this call on a button click or on any other event after application initialization, it executes successfully.

    Any pointers in here..

    Thanks,
    Manu.

    Revision:
    Just by putting an empty <mx:RemoteObject/> resolves this issue.
    Apart from that, I tried to put "ClassXYZ = ClassReference("mx.rpc.remoting.mxml.RemoteObject" )" in properties file, but still no luck.
    Last edited by manuraj.dhanda; Apr 13th, 2010 at 01:52 PM. Reason: Revision

  2. #2
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default class inclusion problem

    Hey there,

    this is a class inclusion problem, apparently the RemoteObject class doesn't get included properly, even when using "ClassXYZ = ClassReference("mx.rpc.remoting.mxml.RemoteObject" )" in your properties file.

    You can try adding a dummy variable somewhere in your source:
    Code:
    private var dummyRemoteObject:mx.rpc.remoting.mxml.RemoteObject;
    that should force the class to be linked.

    hope that helps,

    cheers,

    Roland

  3. #3
    Join Date
    Apr 2008
    Posts
    13

    Default

    Strange, I'm having the same problem with the same class, RemoteObject, adding the class to my code doesn't seem to fix it.

    btw: is'nt <mx:RemoteObject> really a different class then the one you usually use?

    there are:

    mx.rpc.remoting.RemoteObject
    mx.rpc.remoting.mxml.RemoteObject

    any way, I tried to include both and it did not work.

    my context

    Code:
    	<object id="myService" class="mx.rpc.remoting.RemoteObject">
    		<property name="destination" value="deviceService"/>
    		<property name="channelSet">
    			<object id="myChannelSet" class="mx.messaging.ChannelSet">
    				<method-invocation name="addChannel">
    					<arg>
    						<object class="mx.messaging.channels.AMFChannel">
    							<constructor-arg value="my-amf"/>
    							<constructor-arg value="http://localhost:8080/myapp/messagebroker/amf"/>
    						</object>
    					</arg>
    				</method-invocation>
    			</object>
    		</property>
    	</object>
    	
    	<object id="myDelegate" class="com.mypath.MyDelegate">
    		<property name="service" value="myService"/>
    	</object>
    when I run this, it complains that

    Code:
    TypeError: Error #1034: Type Coercion failed: cannot convert "myService" to mx.rpc.remoting.mxml.RemoteObject.
    Any ideas?
    thanks
    Lior

  4. #4
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default typing

    It seems you have typed the service property on your delegate to mx.rpc.remoting.mxml.RemoteObject, yet the service that is defined in the XML is of type mx.rpc.remoting.RemoteObject.

    Since mx.rpc.remoting.mxml.RemoteObject inherits from mx.rpc.remoting.RemoteObject you can't cast the mx.rpc.remoting.RemoteObject to mx.rpc.remoting.mxml.RemoteObject.

    So, the solution in your case would be to either type the service property to mx.rpc.remoting.RemoteObject or change the XML config to mx.rpc.remoting.mxml.RemoteObject.

    I know this sounds confusing, but in the end it makes sense, just swap the mx.rpc.remoting.mxml.RemoteObject and mx.rpc.remoting.RemoteObject with Apple and Orange and it'll make more sense

    hope that helped,

    cheers,

    Roland

  5. #5
    Join Date
    Apr 2008
    Posts
    13

    Default

    Thanks Ronald, all these tests I've made while switching from the mxml remoteObject to the parent one really made my code messed up, but unfortunately this is not the issue, I've fixed the code to contain only references of one of the remoteObjects and no matter what I do I keep getting the the type error.

  6. #6
    Join Date
    Dec 2008
    Location
    Brussels
    Posts
    407

    Default sample app

    Hey there,

    could you post a small sample app here so we can have a look at the project? I'm convinced that something very simple is wrong, but having a bit of context will greatly help.

    thanks in advance,

    Roland

  7. #7
    Join Date
    Apr 2008
    Posts
    13

    Default

    thanks, I'll setup a sample and send you or post here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •