The method on your java class appears to be called "doTest", but your MXML method for your RemoteObject is called "createTest"... but that aside, I think something else is wrong with your connectivity because the client can't seem to connect to the channel endpoint.

When you compile your mxml file, did you remember to specify a --services command line switch to point to your services-config.xml file (which is typically in /WEB-INF/flex/services-config.xml)? Also, it appears your remoting service destination is using the "my-amf" channel... can you check this channel definition in services-config.xml and if the endpoint uri attribute has a {context.root} token you'll either need to replace this with the web application context root "/myapp" or specify it on the command line as --context-root=/myapp

Note that if you change services-config.xml or any of the included services files (such as remoting-config.xml) you'll need to restart the server and recompile your mxml. If you're using Flex Builder you may also want to force a recompile by doing a clean first.



From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of jonathan_merey
Sent: Wednesday, September 27, 2006 12:49 PM
To: [email protected]
Subject: [flexcoders] Problem with RemoteObject Java

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.mess! aging.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"?>

&l! t;mx:App lication 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.*;
                                                            
       !           &n! bsp;&nbs p;  [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()
   &nb! sp;at mx.rpc::AsyncRequest/fault()
    ! at mx.me ssaging::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.

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to