I'm trying to run a simple hello world flex application using RemoteObject and
I get the following error:
(mx.rpc::Fault)#0
errorID = 0
faultCode = "InvokeFailed"
faultDetail = "Couldn't establish a connection to 'helloworld'"
faultString = "[MessagingError message='Destination 'helloworld' either does
not exist or the destination
has no channels defined (and the application does not define any default
channels.)']"
HelloWorld Java class is as follows:
package example;
public class HelloWorld {
public HelloWorld() {
}
public String getHelloWorld() {
return "Hello From Java!";
}
}
remoting-config.xml is as follows:
<?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="helloworld">
<properties>
<source>example.HelloWorld</source>
</properties>
</destination>
</service>
HelloWorld.mxml is as follows:
<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import mx.utils.StringUtil;
private function resultHandler(event:ResultEvent):void
{
//used for debugging - shows details about result
//returned by the Java class method
Alert.show( ObjectUtil.toString(event.result) );
}
private function faultHandler(event:FaultEvent):void
{
Alert.show( ObjectUtil.toString(event.fault) );
}
]]>
</mx:Script>
<mx:RemoteObject id="ro" destination="helloworld" source="example.HelloWorld"
result="resultHandler(event)" fault="faultHandler(event)"/>
<mx:Panel x="10" y="10" width="440" height="200" layout="vertical" title="Test
Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold"
fontSize="13">
<mx:Text text="Click The Button To Test Getting Data Into Flex From A Java
Class" fontWeight="bold" width="250"/>
<mx:Spacer height="20"/>
<mx:Button label="Get Hello World!" click="ro.getHelloWorld()"/>
</mx:Panel>
</mx:Application>
I'm running the application on tomcat. Am I missing something? The BlazeDS
samples work just fine but
for some reason this simple helloworld example created doesn't work. By the
way, I'm using Textpad as
my editor and Eclipse 3.2 to compile my java source. I compile the mxml file
using command line mxlmc
since I don't have Flex Builder.
mxmlc HelloWorld.mxml
Any help will be appreciated.
Thanks.
Gabsaga