Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Remote object with java.

Avatar

Level 3
I am trying to do something that should be really simple. I
am trying use an MXML RemoteObject control to access a java class.
This class works fine with data services, so I am assuming I have a
configuration problem. It does not appear that a call to the java
class method is being made.



Here is my configuration for my flex-remoting-services.xml



<?xml version="1.0" encoding="UTF-8"?>

<service id="remoting-service"

class="flex.messaging.services.RemotingService"

messageTypes="flex.messaging.messages.RemotingMessage">



<adapters>

<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true"/>

</adapters>



<default-channels>

<channel ref="my-amf"/>

</default-channels>



<destination id="ContactAddressTypeRO" >

<properties>


<source>com.gcloans.dao.flex.ContactAddressTypeAssembler</source>

</properties>

</destination>

</service>



The class is in a jar file that is in the lib directory.



here is my application MXML file.



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">

<mx:Script>

<![CDATA[

import mx.rpc.events.*;

import mx.collections.*;

import mx.controls.*;

[Bindable]

public var contactAddressList:Object;

private function getDatabasesHandler(event:ResultEvent):void

{

contactAddressList=event.result;

}

private function faultHandler(event:FaultEvent):void

{

Alert.show(event.fault.faultstring + " : " +
event.fault.message, "The Error: " + event.fault.faultCode);

}

]]>

</mx:Script>

<mx:RemoteObject id="ro"
destination="ContactAddressTypeRO" fault="faultHandler(event);">

<mx:method name="find"
result="getDatabasesHandler(event);" />

</mx:RemoteObject>



<mx:Button id="btnGet" label="Get" click="ro.find();"
/>



<mx:DataGrid id="dg" dataProvider="{contactAddressList}"
editable="true" width="100%" height="800" y="30">

<mx:columns>

<mx:DataGridColumn dataField="contactAddressTypeId"
headerText="ID" editable="false" />

<mx:DataGridColumn dataField="contactAddressType"
editable="true" />

</mx:columns>

</mx:DataGrid>

</mx:Application>

17 Replies

Avatar

Level 2
Sorry, there is not enough information to determine the
issue.



The configuration and the mxml for calling the code look
correct.



To troubleshoot the issue, I would recommend that you do the
following -



(a) Enable logging on the server by editting the logging
section in services-config.xml to 'info' or 'debug' level.

Restart your server and check for these messages on the
server console.

(b) Enable logging on the client by adding <mx:TraceTarget
level="2"/> for debug level trace on the client.

You must have the debug version of the flash player installed
and you'll find the log at C:\Documents and
Settings\username\flashlog.txt for windows.



By enabling both of these, hoping you're issue should become
clear. It will be able to help you determine if the message is
getting to FDS on the back-end.



Avatar

Level 1
If you compile your MXML application locally in Flex Builder,
maybe you should define the channelSet property of your
RemoteObject instance, using ChannelSet and AMFChannel classes. If
you don't, your client app will not be able to reach the remote AMF
broker (the flex remoting gateway).



Hope this helps.

Avatar

Level 2
Hi sanclementetech,



The name of the file flex-remoting-services.xml has been
rename to remoting-config.xml for the final release fo Flex2. And
other config xml files have been changed as well. You may rename
those files and try agian.



This may solve your problem.



Jeffrey

Avatar

Level 3
I caught that, but it still does not work. Would be nice if
the documentation actually gave you a step by step full
configuration example. It may have something to do with the compile
issue, but I wonder why if it is running on a server, that I would
not be able to access the default channel?

Avatar

Level 3
After playing with this JFAM is correct. However if I set the
endpoint for the remote object to /flex/messageborker/amf then I am
working fine. I did not get into what it would take to setup a
channel and channelSet programmatically, but I guess that work as
well. Seems lame that I have to do this however, of course I don't
necessarily understand how channels work either.

Avatar

Level 1
Hi,



I've got the same problem. How did you change the endpoint of
the remote object. I don want to hardcode the ChannelSet and
AMFChannel. I have tried to change the amf channels endpoint in
services-config.xml in different ways but the client does not seem
to pick that up. (Data-management-services make no problems.)



I use Eclipse WTP + Tomcat 5. The FDS webapp is deployed on
http://localhost:8080/shopweb
. The flex-app is compiled locally with FlexBuilder. I have the
following 'standard' configuration:

---------------------------------------------

## file [services-config.xml]:

<channel-definition id="my-amf"
class="mx.messaging.channels.AMFChannel">

<endpoint uri="
http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
class="flex.messaging.endpoints.AMFEndpoint"/>

<properties>

<polling-enabled>false</polling-enabled>

</properties>

</channel-definition>

-------------------------------

## file: [remoting-config.xml]

<default-channels>

<channel ref="my-amf"/>

</default-channels>



<destination id="org.shop.services.ImageService">

<adapter ref="java-object"/>

<properties>

<source>org.shop.services.ImageService</source>

<scope>application</scope>

</properties>

</destination>

------------------------------

## AS class ImageService

var imagesRO:RemoteObject = new
RemoteObject("org.shop.services.ImageService");

imagesRO.getTagNames.addEventListener(ResultEvent.RESULT,onGetTagNames);

imagesRO.addEventListener(FaultEvent.FAULT,onFault);

------------------------------



Now when I call the imagesRO.getTagNames I get a
Net.Connect.Call.Failed error. The flex-log is:



'my-amf' channel endpoint set to
http://localhost:8080/messagebroker/amf

'my-amf' channel settings are:

<channel id="my-amf"
type="mx.messaging.channels.AMFChannel">

<endpoint uri="
http://{server.name}:{server.port}/messagebroker/amf"/>

<properties>

<polling-enabled>false</polling-enabled>

</properties>

</channel>

'61E9894D-9D3F-5DEE-8B27-5BB350AAB574' producer sending
message '6B48B2EA-410C-41C9-837B-5BB350C9B67F'

'my-amf' pinging endpoint.

'my-amf' channel got status. (Object)#0

code = "NetConnection.Call.Failed"

description = "HTTP: Failed"

details = "
http://localhost:8080/messagebroker/amf"

level = "error"

'my-amf' channel polling stopped.

'my-amf' channel connect failed.

'61E9894D-9D3F-5DEE-8B27-5BB350AAB574' producer channel
faulted with Channel.Connect.Failed NetConnection.Call.Failed:
HTTP: Failed

'61E9894D-9D3F-5DEE-8B27-5BB350AAB574' producer fault for
'DE194498-4C38-3129-7C63-5BB350B98623'.

'61E9894D-9D3F-5DEE-8B27-5BB350AAB574' producer fault for
'6B48B2EA-410C-41C9-837B-5BB350C9B67F'.

'my-amf' pinging endpoint.

'my-amf' channel got status. (Object)#0

code = "NetConnection.Call.Failed"

description = "HTTP: Failed"

details = "
http://localhost:8080/messagebroker/amf"

level = "error"

'my-amf' channel polling stopped.

'my-amf' channel connect failed.

'61E9894D-9D3F-5DEE-8B27-5BB350AAB574' producer channel
faulted with Channel.Connect.Failed NetConnection.Call.Failed:
HTTP: Failed

----------------------------------



As said I have changed the endpoint definition by hardconding
the host,port and context but this does not work.



Thanks for the help,

Christian

Avatar

Level 3
I had to hard code it in the remote object



<mx:RemoteObject endpoint="/flex/messagebroker/amf"
id="ro" destination="myRO" fault="faultHandler(event);" >

<mx:method name="find"
result="getDatabasesHandler(event);" />

</mx:RemoteObject>



I am trying to figure out a better way, because this method
is not right!

Avatar

Employee
Hi Ken & Christian,



From the debug output posted, it looks like the problem is
that Flex Builder can't resolve {context.root} for the endpoint:

'my-amf' channel endpoint set to
http://localhost:8080/messagebroker/amf



In Flex Builder:

1. right click on the project and select properties



2. click on "Flex Compiler" in the list on the left



3. in the textField under "Additional compiler arguments",
add an argument for the context root

-compiler.context-root /flex



(* for Christian it would be /shopweb)



4. In the debug, you should now see the context root included
in the endpoint:

'my-amf' channel endpoint set to
http://localhost:8080/flex/messagebroker/amf





Please post back if that resolves the problem.



regards,

peter

Avatar

Level 1
Hi Peter,



Thank you so much. Setting the compiler-argument solves the
problem, which took me a lot of frustrating time. (After the fact
it is quite logical that flex needs to know the context-path.)



Thanks,

Christian

Avatar

Level 3
Peter -



Thanks for the reply. I no longer get the error message, but
I also no longer get an data. In fact it doesn't even look like the
server is getting called. However, I noticed in my browser window
that there was a message "Looking up crossdomain.xml". I do not
have a crossdomain.xml. Do I need one?

Avatar

Employee
Hi Ken,



You should not need a crossdomain.xml policy file because by
default mx:RemoteObject uses the FDS remoting proxy.



So you are saying that you get data back when you set the
enpoint your mx:RemoteObject to "/flex/messagebroker/amf" right?



But when you remove that attribute and add the
-compiler.context-root /flex argument to Flex Builder project
properties - you don't get a connection error, but it doesn't
return data, correct?



Have you implemented the debug settings suggested by Cathy
ealier in this thread? If not, please do and post back all info in
the console and the client error message, just snippets make it
hard to determine exactly what's happening - thanks.



You should be seeing something like this in the
serverconsole:

[Flex] Channel endpoint my-amf received request.

.....



What is the URL that flexbuilder is launching in the browser?

What is the full URL to your FDS application?



regards,

peter



Avatar

Level 3
Peter -




quote:



So you are saying that you get data back when you set the
enpoint your mx:RemoteObject to "/flex/messagebroker/amf" right?

Yes




quote:



Have you implemented the debug settings suggested by Cathy
ealier in this thread?

Yes, I have debug on. That is how I know that I
am not seeing anything. When making a call using DataService it
works fine.




quote:



What is the URL that flexbuilder is launching in the browser?

I am not launching from flexbuilder.


quote:



What is the full URL to your FDS application?


http://localhost:8080/flex/TestArea/TestArea.html



Avatar

Employee
Hi Ken,



I'm somewhat confused as to why my suggested change to the
FlexBuilder compiler setting would have any effect on your
situation considering that you are compiling on the server? It
shouldn't have any impact becuase the IDE compiler isn't being
utilized.



I understand that you are not getting any debug info for the
request/response - what I'm interested in seeing is the info from
the
attempt to make the request. Please include error messages
and any relevent debug output that will help us determine what the
issue is.



When the server instance starts up, what is the output for
the "my-amf' channel?



It should look someting like this:

[Flex] Adobe Flex Data Services Build: 143451

[Flex] Endpoint my-amf created with security: None

at URI:
http://{server.name}:{server.port}/{context.root}/messagebroker/amf



My best guess is that the {context.root } portion of the
endpoint is being resolved incorrectly.

To debug, let's try hardcoding that value in the
/WEB-INF/flex/services-config.xml configuration file:



<channel-definition id="my-amf"
class="mx.messaging.channels.AMFChannel">

<endpoint uri="
http://{server.name}:{server.port}/flex/messagebroker/amf"



Is the change reflected in the server console when it
restarts?



[Flex] Endpoint my-amf created with security: None

at URI:
http://{server.name}:{server.port}/flex/messagebroker/amf





This is the equivilent of setting the endpoint attribute in
the mxml tag.

Does the RO call work now?



regards,

peter

Avatar

Level 1
One of the solution is - While creating the project , use the
option 'Compile Application on the server when the page is viewed.'
under Flex Data Services.

I tried this and its working fine.

You should compile on the server

Avatar

Level 3
That is a solution, but then why have the option of compiling
and publishing? Which BTW runs much faster since I do not have to
wait for the compile. At the end of the day, the better option is
to not use remote objects and instead use Data Services.