java.lang.IllegalStateException: Card has been disconnected
at sun.security.smartcardio.CardImpl.checkState(Unknown Source)
at sun.security.smartcardio.CardImpl.beginExclusive(Unknown Source)
at be.fedict.commons.eid.client.BeIDCard.beginExclusive(BeIDCard.java:915)
at be.fedict.commons.eid.client.BeIDCard.readFile(BeIDCard.java:1034)
--
You received this message because you are subscribed to the Google Groups "eID Applet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eid-applet+...@googlegroups.com.
To post to this group, send email to eid-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/eid-applet.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Frank,
I am having this issue on Windows 7 x64, with an ACS ACR38U-CFC-BLi USB card reader.
Le mardi 22 octobre 2013 09:48:11 UTC+2, Frank Cornelis a �crit�:
Hi Didier,
I've added an integration test for this case based on your sample code:
http://code.google.com/p/commons-eid/source/browse/commons-eid-tests/src/test/java/test/integ/be/fedict/commons/eid/client/DisconnectConnectTest.java
Under Linux I can disconnect and reconnect my card reader without any problem. The second identity read out works just fine.
Which operating system are you using?
Kind Regards,
Frank.
On 10/21/2013 06:46 PM, didier....@gmail.com wrote:
Hi all,
We are building a fat client which has to read beID's when the user clicks on a button. For this, we instantiate a BeIDCards, call getAllBeIDCards() and then read the data.
This works pretty well, except after a reader disconnection and reconnection. In that case, we cannot read cards any more and have to restart the application. When trying to read a card we get the following exception:
(if no card is present we get a �No card found� instead)java.lang.IllegalStateException: Card has been disconnected
� � � at sun.security.smartcardio.CardImpl.checkState(Unknown Source)
� � � at sun.security.smartcardio.CardImpl.beginExclusive(Unknown Source)
� � � at be.fedict.commons.eid.client.BeIDCard.beginExclusive(BeIDCard.java:915)
� � � at be.fedict.commons.eid.client.BeIDCard.readFile(BeIDCard.java:1034)
The attached file demonstrates the issue. Notice we don't use getOneBeIDCard() because it makes several dialogs flicker before crashing so this is even worse.
The problem seems to be that BeIDCards.close() does not stop the CardAndTerminalManager. However re-using the BeIDCards instance does not work either (getAllBeIDCards() returns an empty set). The only thing that seems to work is accessing the CardAndTerminalManager by reflexion and stop it�
Are we doing something wrong or is this a bug in the synchronous api ?
Best regards,
Didier Loiseau
--
You received this message because you are subscribed to the Google Groups "eID Applet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eid-applet+...@googlegroups.com.
To post to this group, send email to eid-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/eid-applet.
For more options, visit https://groups.google.com/groups/opt_out.
2013-10-22 12:59:56,573 [DEBUG] BeidServiceImpl$BeidLogger - subsystem not initialized
2013-10-22 12:59:56,574 [DEBUG] BeidServiceImpl$BeidLogger - Cannot enumerate card terminals [1] (No Card Readers Connected?): list() failed
2013-10-22 12:59:56,574 [DEBUG] BeidServiceImpl$BeidLogger - no card readers connected?
2013-10-22 12:59:56,574 [DEBUG] BeidServiceImpl$BeidLogger - cause: SCARD_E_NO_READERS_AVAILABLE
2013-10-22 12:59:56,574 [DEBUG] BeidServiceImpl$BeidLogger - cause type: sun.security.smartcardio.PCSCException
2013-10-22 12:59:56,574 [DEBUG] BeidServiceImpl$BeidLogger - cleared
2013-10-22 13:06:48,223 [DEBUG] BeidServiceImpl$BeidLogger - subsystem not initialized
2013-10-22 13:06:48,227 [DEBUG] BeidServiceImpl$BeidLogger - Cannot wait for card terminal events [2] (No Card Readers Connected?): waitForChange() failed
2013-10-22 13:06:48,227 [DEBUG] BeidServiceImpl$BeidLogger - no card readers connected?
2013-10-22 13:06:48,227 [DEBUG] BeidServiceImpl$BeidLogger - cause: SCARD_E_NO_READERS_AVAILABLE
2013-10-22 13:06:48,227 [DEBUG] BeidServiceImpl$BeidLogger - cause type: sun.security.smartcardio.PCSCException
2013-10-22 13:06:48,227 [DEBUG] BeidServiceImpl$BeidLogger - cleared
2013-10-22 13:06:48,477 [DEBUG] BeidServiceImpl$BeidLogger - subsystem not initialized
----- card inserted now
2013-10-22 13:06:49,082 [INFO ] BeidServiceImpl - Card inserted in ACS ACR38U 0
2013-10-22 13:06:49,083 [DEBUG] BeidServiceImpl$BeidLogger - ---begin exclusive---
2013-10-22 13:06:49,200 [DEBUG] BeidServiceImpl$BeidLogger - selecting file
2013-10-22 13:06:49,316 [DEBUG] BeidServiceImpl$BeidLogger - read binary
2013-10-22 13:06:49,471 [DEBUG] BeidServiceImpl$BeidLogger - ---end exclusive---
2013-10-22 13:06:49,473 [DEBUG] DateOfBirthDataConvertor - "XXXXXXXX"
2013-10-22 13:06:49,473 [DEBUG] DateOfBirthDataConvertor - day: "XX"
2013-10-22 13:06:49,473 [DEBUG] DateOfBirthDataConvertor - month: "XXXX"
2013-10-22 13:06:49,474 [DEBUG] DateOfBirthDataConvertor - year: "XXXX"
2013-10-22 13:06:49,474 [DEBUG] DocumentTypeConvertor - # bytes for document type field: 2
2013-10-22 13:06:49,474 [DEBUG] BeidServiceImpl$BeidLogger - ---begin exclusive---
2013-10-22 13:06:49,474 [DEBUG] BeidServiceImpl$BeidLogger - selecting file
2013-10-22 13:06:49,592 [DEBUG] BeidServiceImpl$BeidLogger - read binary
2013-10-22 13:06:49,718 [DEBUG] BeidServiceImpl$BeidLogger - ---end exclusive---
2013-10-22 13:06:49,720 [DEBUG] BeidServiceImpl$BeidLogger - ---begin exclusive---
2013-10-22 13:06:49,863 [DEBUG] BeidServiceImpl$BeidLogger - selecting file
2013-10-22 13:06:49,985 [DEBUG] BeidServiceImpl$BeidLogger - read binary
2013-10-22 13:06:51,506 [DEBUG] BeidServiceImpl$BeidLogger - ---end exclusive---
2013-10-22 13:06:51,507 [INFO ] BeidServiceImpl - Card read in 2424ms
2013-10-22 13:06:51,526 [DEBUG] BeidServiceImpl$BeidLogger - Cannot wait for card terminal events [2] (No Card Readers Connected?): waitForChange() failed
2013-10-22 13:06:51,526 [DEBUG] BeidServiceImpl$BeidLogger - no card readers connected?
2013-10-22 13:06:51,526 [DEBUG] BeidServiceImpl$BeidLogger - cause: SCARD_E_NO_READERS_AVAILABLE
2013-10-22 13:06:51,526 [DEBUG] BeidServiceImpl$BeidLogger - cause type: sun.security.smartcardio.PCSCException
2013-10-22 13:06:51,526 [DEBUG] BeidServiceImpl$BeidLogger - closing eID card
2013-10-22 13:06:51,527 [INFO ] BeidServiceImpl - Card removed from ACS ACR38U 0
2013-10-22 13:06:51,527 [DEBUG] BeidServiceImpl$BeidLogger - cleared
2013-10-22 13:06:51,777 [DEBUG] BeidServiceImpl$BeidLogger - subsystem not initialized
2013-10-22 13:06:51,778 [INFO ] BeidServiceImpl - Card inserted in ACS ACR38U 0
2013-10-22 13:06:51,778 [DEBUG] BeidServiceImpl$BeidLogger - ---begin exclusive---
2013-10-22 13:06:51,779 [DEBUG] BeidServiceImpl$BeidLogger - selecting file
2013-10-22 13:06:51,892 [DEBUG] BeidServiceImpl$BeidLogger - read binary
2013-10-22 13:06:52,043 [DEBUG] BeidServiceImpl$BeidLogger - ---end exclusive---
…
So it seems that the reader is detected by the JVM but is not properly handled.
BTW, there are issues with the Logger handling:
SCARD_E_NO_READERS_AVAILABLE.��� @Test
��� public void testPCSC() throws Exception {
������� JOptionPane.showMessageDialog(null, "Connect reader.");
������� TerminalFactory terminalFactory = TerminalFactory.getDefault();
������� LOG.debug("number of readers: "
��������������� + terminalFactory.terminals().list().size());
������� JOptionPane.showMessageDialog(null, "Disconnect and reconnect reader.");
������� terminalFactory = TerminalFactory.getDefault();
������� LOG.debug("number of readers: "
��������������� + terminalFactory.terminals().list().size());
��� }From the second terminals() call I receive SCARD_E_SERVICE_STOPPED. So under Windows 8 it seems that it's the JVM itself that does not properly recover from the PC/SC going (temporary) down.
I think the problem is that the CardTerminals instance gets somehow corrupted after a terminal gets disconnected. I have tested this with 2 readers: you can disconnect 1 without issue, but even if you reconnect it, after disconnecting the second you begin to have the repeatingSCARD_E_NO_READERS_AVAILABLE.
As a workaround, I added a CardTerminalEventsListener which, on terminalDetached, spawns a new thread that stops and recreates the CardAndTerminalManager and BeIDCardManager (this must be done on a separate thread, otherwise it interrupts itself when calling stop()). This seems to work without issues.
Le mardi 22 octobre 2013 13:20:19 UTC+2, Didier Loiseau a �crit�:
�
So it seems that the reader is detected by the JVM but is not properly handled.
BTW, there are issues with the Logger handling:
- the BeIDCardManager does not transmit the provided Logger when it instantiates the CardAndTerminalManager so I had to instantiate it myself
- the DateOfBirthDataConvertor and DocumentTypeConvertor are using ACL instead (it would actually be great if the entire API relied only on JCL, ACL or another standard logging framework btw - SLF4J maybe?)
Le mardi 22 octobre 2013 11:03:54 UTC+2, Frank Cornelis a �crit�:
Hi Didier,
I can confirm that there is an issue with the card reader reconnection under Windows 8, 64 bit, Java 7u45. But the exception that I'm getting is totally different.
Kind Regards,
Frank.
On 10/22/2013 10:05 AM, didier....@gmail.com wrote:
Hi Frank,
I am having this issue on Windows 7 x64, with an ACS ACR38U-CFC-BLi USB card reader.
--
FYI... it's already reported at:
https://bugs.openjdk.java.net/browse/JDK-8026326
On 10/22/2013 05:14 PM, Frank Cornelis wrote:
Hi Didier,
Interesting. Under Windows 8, even the following fails for me:
@Test
public void testPCSC() throws Exception {
JOptionPane.showMessageDialog(null, "Connect reader.");TerminalFactory terminalFactory = TerminalFactory.getDefault();LOG.debug("number of readers: "+ terminalFactory.terminals().list().size());
JOptionPane.showMessageDialog(null, "Disconnect and reconnect reader.");
terminalFactory = TerminalFactory.getDefault();LOG.debug("number of readers: "+ terminalFactory.terminals().list().size());
}From the second terminals() call I receive SCARD_E_SERVICE_STOPPED. So under Windows 8 it seems that it's the JVM itself that does not properly recover from the PC/SC going (temporary) down.
BTW: about the design choices behind the used logging framework: commons-eid-client is using its own logging interface as the client library cannot have any 3rd dependency (since we want to be able to construct very lightweight applets), while for commons-eid-consumer it doesn't really matter.
Kind Regards,
Frank.
On 10/22/2013 03:54 PM, Didier Loiseau wrote:
I think the problem is that the CardTerminals instance gets somehow corrupted after a terminal gets disconnected. I have tested this with 2 readers: you can disconnect 1 without issue, but even if you reconnect it, after disconnecting the second you begin to have the repeatingSCARD_E_NO_READERS_AVAILABLE.
As a workaround, I added a CardTerminalEventsListener which, on terminalDetached, spawns a new thread that stops and recreates the CardAndTerminalManager and BeIDCardManager (this must be done on a separate thread, otherwise it interrupts itself when calling stop()). This seems to work without issues.
…
--
You received this message because you are subscribed to a topic in the Google Groups "eID Applet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eid-applet/N1mVFnYJ3VM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eid-applet+...@googlegroups.com.
To post to this group, send email to eid-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/eid-applet.
For more options, visit https://groups.google.com/groups/opt_out.