Hi, I have an application with flex 2.0, flex data services
and java and I want to access methods of my JAVA classes. So I use
the remoteObject.
Here is the code :
Test.java
package beans;
public class Test {
public Test()
{
System.out.println("-= Test start =-");
}
public String doTest()
{
return "-= This is a test =-";
}
}
remoting-config.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="test">
<properties>
<source>beans.Test</source>
<scope>application</scope>
</properties>
</destination>
</service>
index.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml" initialize="applicationInit()"
layout="absolute"
backgroundGradientColors="[#ffffff, #808080]"
viewSourceURL="srcview/index.html"
creationComplete="doTest()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.collections.ArrayCollection;
import flash.events.MouseEvent;
import mx.rpc.AsyncToken;
import mx.data.*;
import mx.managers.*;
[Bindable]
private function doTest():void
{
test.doTest();
}
]]>
</mx:Script>
<mx:RemoteObject id="test" destination="test">
<mx:method name="createTest"/>
</mx:RemoteObject>
When I launch the server " -= Test start =-" is printed on
tomcat so the remoteObject is good initialized but after there is
an error due to the method createTest.
Here is the final message when i launch the application :
[RPC Fault faultString="Send failed"
faultCode="Client.Error.MessageSend"
faultDetail="Channel.Connect.Failed error
NetConnection.Call.Failed: HTTP: Failed"]
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::faultHandler() at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at mx.messaging::ChannelSet/::faultPendingSends()
at mx.messaging::ChannelSet/channelFaultHandler()
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.messaging::Channel/mx.messaging:Channel::connectFailed()
at
mx.messaging.channels::PollingChannel/mx.messaging.channels:PollingChannel::connectFailed()
at
mx.messaging.channels::AMFChannel/mx.messaging.channels:AMFChannel::statusHandler()
Please help me.