Results 1 to 2 of 2
- 02-03-2011, 06:36 AM #1
Member
- Join Date
- Dec 2010
- Location
- New Engaland
- Posts
- 11
- Rep Power
- 0
IllegalArgumentException: argument type mismatch (parameters in remote methods w/RMI)
I am getting the following error code:
when attempting to pass an AccountInfo object from my Client to the ATMServer.$ java -jar project_Client.jar
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages( Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unk nown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invo keRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invo ke(Unknown Source)
at $Proxy2.getBalance(Unknown Source)
at class.project.Client.printBalances(Unknown Source)
at class.project.Client.testATM(Unknown Source)
at class.project.Client.main(Unknown Source)
Failed as expected: java.lang.IllegalArgumentException: argument type mismatch
Failed as expected: java.lang.IllegalArgumentException: argument type mismatch
Failed as expected: java.lang.IllegalArgumentException: argument type mismatch
Unexpected error: java.lang.IllegalArgumentException: argument type mismatch
Unexpected error: java.lang.IllegalArgumentException: argument type mismatch
Unexpected error: java.lang.IllegalArgumentException: argument type mismatch
Unexpected error: java.lang.IllegalArgumentException: argument type mismatch
Failed as expected: java.lang.IllegalArgumentException: argument type mismatch
Unexpected error: java.lang.IllegalArgumentException: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages( Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unk nown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invo keRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invo ke(Unknown Source)
at $Proxy2.getBalance(Unknown Source)
at class.project.Client.printBalances(Unknown Source)
at class.project.Client.testATM(Unknown Source)
at class.project.Client.main(Unknown Source)
Here is my AccountInfo.java code:
Java Code:package class.project; import java.rmi.RemoteException; public class AccountInfo extends java.rmi.server.UnicastRemoteObject { /** * */ private static final long serialVersionUID = 1L; private int account_number; private int pin_number; public AccountInfo(int account_number, int pin_number) throws RemoteException { super(); this.account_number = account_number; this.pin_number = pin_number; } public int getAccountNumber() { return this.account_number; } public void setAccountNumber(int account_number) { this.account_number = account_number; } public int getPinNumber() { return this.pin_number; } public void setPinNumber(int pin_number) { this.pin_number = pin_number; } }
My ATMImpl.java's getBalance method:
Java Code:public Float getBalance(AccountInfo account_info) throws java.rmi.RemoteException, ATMException, SecurityException, Exception { System.out.println("Entered getBalance()"); notifyListenersInit(); try { this.security.authenticateTransaction(account_info); this.security.authorizeTransaction(account_info, 'b'); } catch (SecurityException se) { throw se; } catch (Exception e) { throw e; } Account account = null; account = this.bank.getAccount(account_info); return account.getBalance(); }
and, the relevant Client.java methods causing this error:
andJava Code:public static void printBalances(ATM atm) { try { System.out.println("Balance(0000001): "+atm.getBalance(getAccountInfo(0000001, 1234))); System.out.println("Balance(0000002): "+atm.getBalance(getAccountInfo(0000002, 2345))); System.out.println("Balance(0000003): "+atm.getBalance(getAccountInfo(0000003, 3456))); } catch (Exception e) { e.printStackTrace(); } }
Java Code:public static AccountInfo getAccountInfo(int account_number, int pin_number) throws RemoteException { return new AccountInfo(account_number, pin_number); }
Any help is much appreciated! Thanks.Last edited by nicoeschpiko; 02-03-2011 at 06:15 PM. Reason: more descriptive issue title
- 02-03-2011, 05:43 PM #2
Member
- Join Date
- Dec 2010
- Location
- New Engaland
- Posts
- 11
- Rep Power
- 0
IllegalArgumentException: argument type mismatch (parameters in remote methods w/RMI)
This is quite confusing. An object of type AccountInfo is passed from the Client, and the ATM getBalance method is expecting an object of type AccountInfo via the ATM stub. AccountInfo extends java.rmi.server.UnicastRemoteObject which makes it serializable and able used in a remote method. I am wondering if this AccountInfo object needs to be cast as something else? Any ideas?
Last edited by nicoeschpiko; 02-03-2011 at 06:14 PM. Reason: more descriptive issue title
Similar Threads
-
Passing Parameters to servlet
By praveen_1987 in forum JavaServer Faces (JSF)Replies: 0Last Post: 06-30-2010, 11:30 AM -
passing parameters to next jsp using javascript
By sridevisala in forum New To JavaReplies: 0Last Post: 11-20-2009, 05:34 AM -
[SOLVED] Passing parameters
By robocop in forum New To JavaReplies: 3Last Post: 03-03-2009, 10:16 PM -
passing parameters between two applets
By veena1612 in forum Java AppletsReplies: 1Last Post: 05-27-2008, 09:29 AM -
JNI - passing and returning parameters by value
By java_to_c in forum New To JavaReplies: 0Last Post: 01-31-2008, 08:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks