java.rmi.RemoteException: Protocol error reported by the card
Hi,
I am trying the "SecureRMIDemo" in JC2.2.1 samples, everything went perfectly till the calling ofmyPurse.getBalance(). I got the following:
java.rmi.RemoteException: Protocol error reported by the card
I am using:
- JCKit2.2.1
- OCF1.2
- Eclipse 3.2.1
- JCOP3.1.1b tools
-JCOP31SHARP card.
- Windows XP
please guys, I need your help.
Mike.
# 1
What line does the method throw the exception? (debug)
# 2
Lexdabear,
Thanks a lot for your reply.
in debug, I get
$Proxy0.getBalance() line: not available [local variables unavailable]
I think that the problem is not in the method itself; because I tried calling all other methods (i.e. setAccountNumber, credit, debit,..) and still getting the same error
BTW, the code in getBalance() is very simple; (return balance;)
but I beleive it does not enter the method for some reason!
any other ideas? I need your help please.
thanks again.
# 3
Hope this also will help,
I have enabled debugging in the code, and here is the output:
Uses ISOTPDU
accessor: select command
0 a4 4 10 d 52 4d 49 74 65 73 74 41 70 70 6c 65 74 7f
90 0 6f 39 6e 37 5e 35 2 2 38 81 68 92 0 1 26 63 6f 6d 2f 73 75 6e 2f 6a 61 76 61 63 61 72 64 2f 73 61 6d 70 6c 65 73 2f 53 65 63 75 72 65 52 4d 49 44 65 6d 6f 5 50 75 72 73 65
90 0 6f 39 6e 37 5e 35 2 2 38 81 68 92 0 1 26 63 6f 6d 2f 73 75 6e 2f 6a 61 76 61 63 61 72 64 2f 73 61 6d 70 6c 65 73 2f 53 65 63 75 72 65 52 4d 49 44 65 6d 6f 5 50 75 72 73 65
Authenticating as app provider... 80 39 0 0 4 12 34 0 46 7f
90 0 0 0
Le=2
csum1=0
csum2=0
90 0
done.
Receiving initial reference... OK
Getting the balance... 80 38 2 2 6 68 92 ec a8 ff 8e 7f
90 0 99 0 6 ff 9f
Le=5
csum1=-97
csum2=-97
90 0 99 0 6
java.rmi.RemoteException: Protocol error reported by the card
[WARNING ] opencard.core.service.CardServiceScheduler.closeDown
messageclosing opencard.core.service.CardChannel@129f3b5, is open, not jammed
threadThread[main,5,main]
sourceopencard.core.service.CardServiceScheduler@1815859, not alive
++ channel is allocated
# 4
You are using OpenCard Framework. I do not have much experience with it. Did you try JCOP Tools? There is RMI support as well.
# 5
May you provide me with some sample code showing how to use JCOP's RMI ?and BTW, does that mean that OCF doesn't work with JCOP cards ?Thanks for your help!
# 6
This is an example code for accessing RMI with JCOP. I assume that your Javacard applet or another object on the card implements YourJavaCardInterface.
JCTerminal terminal = JCTerminal.getInstance("pcsc:1", terminalName);
JCard card = new JCard(terminal, null, 0);
JCApplet applet = new JCApplet(card,yourAppletID);
applet.select();
Object o = RMIObjectFactory.getInitialReference(applet);
YourJavaCardInterface myAppletRef = (YourJavaCardInterface) o;
myAppletRef.executeMethodXYZ(...);
# 7
Hi,
your few lines of code you posted here helped me a lot! Thank you for that!
But I still have some troubles addressing my RMI method.
For the line
Object o = RMIObjectFactory.getInitialReference(applet);
I get a "Zero interface name length" error.
Any idea why is that?
Thank you so much!
# 8
> I get a "Zero interface name length" error.
>
> Any idea why is that?
First, are you sure that your java card/emulator supports JC-RMI?
Second, do you have a class that extends CardRemoteObject on your javaCard and have you "registered" correctly on the Javacard?
public class MyApplet extends Applet {
private Dispatcher disp;
private RemoteService serv;
private MyImpl myImplementation;
public MyApplet() {
super();
// Create the implementation for my applet.
myImplementation = new MyImpl();
// Create a new Dispatcher that can hold a maximum of 1
// service, the RMIService.
disp = new Dispatcher((short) 1);
// Create the RMIService
serv = new RMIService(myImplementation);
disp.addService(serv, Dispatcher.PROCESS_COMMAND);
// Complete the registration process
register();
}
}
public class MyImpl extends CardRemoteObject {
...
}