The Employee class must implement Serializable, that's missing, try that and see if it fixes your problem.
 
Dimitrios "Jimmy" Gianninas
RIA Developer
Optimal Payments Inc.
 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of babulj2003
Sent: Sunday, November 20, 2005 1:54 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Error: Cannot invoke method

I get this error when trying to use Remote Object via AMF. The most
triffling thing is that there is not problem with the way code is
written and i cannot find any configuration issues. Moreover i do not
know how to get to the exact error.
It is a simple code in which i am using a VO there's a corressponding
AS file which registers with the java VO. i have configured the
whitelist properly. i tried configuring NetConnectionDebugger the way
its given in Macromedia's site, but even that is not getting configured.

I cannot see anythin in the panel.

I have been into this weird problem for sometime now. I replicated the
code and tried to run it by building a seperate war, the same example
got executed. i want to know how to debug these kind of problems. Is
there any way to know the exact error.

because "Error: Cannot invoke method 'methodName'"  doesn't help me in
any way.

Kindly respond soon.

i'm putting the code blocks here:

1. SimpleForm.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
initialize="initApp()">
      <mx:Script>
        import mx.managers.CursorManager;
        import mx.core.UIObject;
        import sample.data.*;
       
        var emp: Employee;
        var inputBlocker;

            function initApp() {
            emp=new Employee();
        }
       
      function update() {
            setBlockingCursor();
            //applyChanges();
                  emp.firstName=firstName.text;
            emp.lastName=lastName.text;
            srv.addEmployee(emp);
        }

        function addEmp_result(event) {
       
            setBlockingCursor();
        }
       
        function faultHandler(event) {
            removeBlockingCursor();
            mx.controls.Alert.show(event.fault.faultstring, 'Error');
        }
        function applyChanges(){
              emp.firstName=firstName.text;
              emp.lastName=lastName.text;
        }
          
       
        function setBlockingCursor() {
            inputBlocker = popupWindow(UIObject);
            CursorManager.setBusyCursor();
        }

        // Remove our blocking popup
        function removeBlockingCursor() {
            inputBlocker.deletePopUp();
            CursorManager.removeBusyCursor();
        }
      </mx:Script>
     
     
    <mx:RemoteObject id="srv" source="sample.data.SimpleService">
        <mx:method name="addEmployee" result="addEmp_result(event)"
fault="faultHandler(event)"/>
    </mx:RemoteObject>
     
            <mx:Form>
                        <mx:FormItem id="firstNameItem" label="First name" required="true" >
                                    <mx:TextInput  id="firstName" width="350" />
                        </mx:FormItem>
                        <mx:FormItem id="lastNameItem" label="First name" required="true" >
                                    <mx:TextInput  id="lastName" width="350" />
                        </mx:FormItem>
                       
              <mx:FormItem>
                  <mx:Button label="Add Employee" click="update()"/>
              </mx:FormItem>
            </mx:Form>
     
</mx:Application>

2. Employee.as

class sample.data.Employee {

    public var firstName : String;
    public var lastName : String;
   
    static var registered=Object.registerClass("sample.data.Employee",
sample.data.Employee);   

}

3. white-list
        <whitelist>
            <!-- whitelist config for unnamed objects -->
            <unnamed>
                <source>sample.*</source>
                <source>sample</source>
            </unnamed>
                  <named>
                              <object name="SimpleService">
                                  <source>sample.data.SimpleService</source>
                              <type>stateful-class</type>
                              <allow-unnamed-access>true</allow-unnamed-access>
                              </object>
                        </named>     
        </whitelist>

4. SimpleService.java
package sample.data;

public class SimpleService{
      public void addEmployee(Employee emp){
            System.out.println("***********************************\n\n");
            System.out.println(emp.getFirstName()+" : "+emp.getLastName());
            System.out.println("\n\n***********************************");
           
      }           

}
5. Employee.java

package sample.data;

class Employee {
      private String firstName;
      private String lastName;
     
    public Employee(){
      }
     
      public Employee(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
      }

      public String getFirstName() {
            return firstName;
      }

      public void setFirstName(String firstName) {
            this.firstName = firstName;
      }

      public String getLastName() {
            return lastName;
      }

      public void setLastName(String lastName) {
            this.lastName = lastName;
      }
     

}









--
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
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to