I've installed the turnkey installation of blazeds.
I've started the sampledb, started the tomcat server, chosen the correct configs in my flex client application.
I made a simple javaclass "MyTestClass" with a getString method and put it in [turnkeyinstallationfolder]/tomcat/webapps/samples/WEB-INF/classes/fl ex/samples
I configured a destination in the remoting-config.xml of the samples with source flex.samples.MyTestClass.
When I run my flex client application I always get this error message: (below is the code of my java class, flex air client app and the remoting-config.xml)
| error message |
|---|
| [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://lazeTestRemoting.swf/samples/messagebroker/amf'"] at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\AbstractInvok er.as:345] at mx.rpc::Responder/fault()[E:\dev\gumbo_beta2\frameworks\projects\rpc\ src\mx\rpc\Responder.as:68] at mx.rpc::AsyncRequest/fault()[E:\dev\gumbo_beta2\frameworks\projects\r pc\src\mx\rpc\AsyncRequest.as:113] at mx.messaging::ChannelSet/faultPendingSends()[E:\dev\gumbo_beta2\frame works\projects\rpc\src\mx\messaging\ChannelSet.as:1614] at mx.messaging::ChannelSet/channelFaultHandler()[E:\dev\gumbo_beta2\fra meworks\projects\rpc\src\mx\messaging\ChannelSet.as:1206] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.messaging::Channel/connectFailed()[E:\dev\gumbo_beta2\frameworks\p rojects\rpc\src\mx\messaging\Channel.as:1128] at mx.messaging.channels::PollingChannel/connectFailed()[E:\dev\gumbo_be ta2\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.a s:406] at mx.messaging.channels::AMFChannel/statusHandler()[E:\dev\gumbo_beta2\ frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:444] |
| java class |
|---|
| public class MyTestClass { public MyTestClass(){} public String getString() { return "test"; } } |
| flex app |
|---|
| <?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> <s:RemoteObject id="myService" destination="testbestemming"/> </fx:Declarations> <s:Label text="{myService.getString()}"/> </s:WindowedApplication> |
remoting-config.xml |
|---|
| <?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService"> <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="product"> <properties> <source>flex.samples.product.ProductService</source> </properties> </destination> <destination id="chat-room-service"> <properties> <source>flex.samples.runtimeconfig.ChatRoomService</source> <scope>application</scope> </properties> </destination> <destination id="census"> <properties> <source>flex.samples.census.CensusService</source> </properties> </destination> <destination id="flex-client-qos-config" channels="per-client-qos-polling-amf"> <properties> <source>flex.samples.qos.FlexClientConfigService</source> </properties> </destination> <destination id="testbestemming"> <properties> <source>flex.samples.MyTestClass</source> </properties> </destination> </service> |
You need to make sure you are running the SWF file that is served up from the application server via HTTP. Often times the connect will fail because the channel defined in the services-config.xml (in the case "my-amf") has the {server.name} and {server.port} tokens in it and when you run the SWF from the file system the Flash player does not have a server name (or port) to fill in to the channel URL. so the connection fails.
Hope that helps.
Thank you for replying!
I believe I am running the correct SWF file because in the fault detail the tokens are replaced with what seems like correct values. This is what I see in the debugger:
Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/web/messagebroker/amf'
Or perhaps this isn't the best way to test/confirm your suggestion?
You are correct about the tokens. The tokens wouldn't resolve if the swf was being run from the file system. A 404 is a page not found error. What do you get if you paste the url http://localhost:8080/web/messagebroker/amf into your web browser? You should get an empty/blank page and not a 404. If you're getting a 404 it's possible the message broker didn't start up successfully. If that's the case, you should see an error in the server console output or the server log. Also confirm that the port number is correct. Hope that helps.
-Alex
I've resolved my issue. Perhaps you are correct that my tokens were not resolving, but since you did not offer a way to fix that, I was still on my own. There was nothing helpful that I could find in the console or log.
I found this article, and after using his architecture (using an external config file to define the amf endpoint at runtime) I was able to connect to the back end. I was also looking for a good way to externalize information, so I recommend reading this article:
http://coenraets.org/blog/2009/03/externalizing-service-configuration- using-blazeds-and-lcds/
North America
Europe, Middle East and Africa
Asia Pacific