Acessando o javax.smartcardio do Linux 64 bits

Estou tentando carregar os terminais de cartão inteligente usando a API javax.smartcardio com o seguinte código:

public CardTerminal getReadyCardTerminal() throws CardException {

    TerminalFactory factory = TerminalFactory.getDefault();
    CardTerminals terminals = factory.terminals();
    List<CardTerminal> list = terminals.list(State.CARD_PRESENT);

    while (list.isEmpty()) {
        terminals.waitForChange(1000);
        list = terminals.list(State.CARD_PRESENT);
    }
    CardTerminal cardTerminal = list.get(0);
    return cardTerminal;
}

... e sempre recebo a seguinte exceção:

java.lang.IllegalStateException: no terminals
at javax.smartcardio.TerminalFactory$NoneCardTerminals.waitForChange(TerminalFactory.java:145)

No Windows Vista / 7 tudo funciona bem, mas não consigo fazê-lo funcionar no Linux. Estou usando o Ubuntu 12.04 64 bits.

Eu instalei o serviço pcscd usando o seguinte comando:

sudo apt-get install libccid pcscd libpcsclite-dev libpcsclite1
sudo service pcscd start

E o comando pcsc_scan imprime isso:

PC/SC device scanner
V 1.4.18 (c) 2001-2011, Ludovic Rousseau <[email protected]>
Compiled with PC/SC lite version: 1.7.4
Using reader plug'n play mechanism
Scanning present readers...
0: OMNIKEY CardMan 3x21 00 00

Tue Sep 11 15:44:49 2012
Reader 0: OMNIKEY CardMan 3x21 00 00
  Card state: Card inserted, 
  ATR: <some hexa codes>
  ...

Então tudo parece ok, mas o smartcardio simplesmente não funciona. Estou tentando com o Oracle e OpenJDK 1.7.0_05, 32 e 64 bits.

O código roda ok com o OpenJDK (mas não com o Oracle JDK, não sei exatamente por quê) em um ambiente Ubuntu de 32 bits. Então eu acho que é um problema com a ponte de 64 bits do Java para a biblioteca PC / SC.

Alguma ideia?

Obrigado.

questionAnswers(7)

yourAnswerToTheQuestion