MacOS and JSVC: SCARD_E_NO_SERVICE: The Smart card resource manager is not running

5

I got a JAR file that needs to run as a daemon in MacOS Sierra and I decided to use Apache Commons Daemon and JSVC for that purpose. I am aware that maybe JSVC is not really needed for this purpose (it seems only allows to open ports in a low range) and it is possible to achieve the same with system/launch so any help/solution with or without JSVC is appreciated.

This is how I am running the jar from the command line, and it works properly. It opens a WebSocket connection using port 8085 and waits for an incoming connection. Then, it connects to a smart card reader and gets some data from the card.

java -cp "myjar.jar:jars/*" full_class_name

Now, when I try to run the same jar with the Apache Commons Daemon interface and JSVC, the jar starts properly and it starts listening in port 8085.

./jsvc -debug -cp commons-daemon-1.1.0.jar:myjar.jar:jars/* -cwd . -pidfile /tmp/file.pid full_class_name

The issue is that, for some reason, there is an exception when trying to connect to the smart card reader.

INFORMACIÓN: WebSocket Registered apps: URLs all start with ws://localhost:8085
may 15, 2018 10:04:37 AM org.glassfish.tyrus.server.Server start
INFORMACIÓN: WebSocket server started.
LISTENING
Daemon started successfully
java_start done
Waiting for a signal to be delivered
create_tmp_file: /tmp/541.jsvc_up
jnasmartcardio.Smartcardio$EstablishContextException: jnasmartcardio.Smartcardio$JnaPCSCException: SCardEstablishContext got response 0x8010001d (SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
    at jnasmartcardio.Smartcardio$JnaTerminalFactorySpi.engineTerminals(Smartcardio.java:81)
    at javax.smartcardio.TerminalFactory.terminals(TerminalFactory.java:351)
    at apdu4j.TerminalManager.getTheReader(TerminalManager.java:228)
    at com.st.middleware.a.a.b.connect(SourceFile:24)
    at com.st.middleware.a.b.connect(SourceFile:18)
    at com.st.middleware.a.b.getCertificates(SourceFile:1024)
    at com.st.middleware.MiddlewareImpl.a(SourceFile:113)
    at com.st.middleware.MiddlewareImpl.getAuthCertificates(SourceFile:151)
    at com.st.communication.card.websocket.a.handleMessage(SourceFile:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

The fact that the jar works properly when running with java -jar makes me believe that the issue is something with the configuration. Any ideas on why the service is not available using JSVC?

Thanks in advance.

macos
smartcard
jsvc
asked on Stack Overflow May 15, 2018 by Miguel Febres • edited May 29, 2018 by Mohammed Zayan

1 Answer

0

I had the same exception from jnasmartcardio under Linux. My solution was a missing native library. I installed pcscd and the exception was gone.

answered on Stack Overflow Feb 5, 2021 by bilderkiste

User contributions licensed under CC BY-SA 3.0