Using javax.smartcardio from openjdk7-darwin-i386-20080820
Hi, I have some code that uses javax.smartcardio that works on Windows, but fails when I try to run it on the version of Java 6 from Apple (same problems as described on http://lists.apple.com/archives/java-dev/2008/May/msg00144.html) , so I decided to give the binary version of openjdk7-darwin- i386-20080820 as built by Landon Fuller a try. Here follows my code for getting the list of configured readers: /** * * @return List of references to the readers configured in the environment * * @throws CardException */ private static List<CardTerminal> getTerminals() throws CardException { List<CardTerminal> terminals = null; try { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); // TerminalFactory factory = TerminalFactory.getDefault(); System.out.println("TerminalFactory Type: " + factory.getType()); // Get the list of readers configured in the environment terminals = factory.terminals().list(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } return terminals; } This fails with the following: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: PC/SC, provider: SunPCSC, class: sun.security.smartcardio.SunPCSC$Factory) at java.security.Provider$Service.newInstance(Provider.java:1257) at sun.security.jca.GetInstance.getInstance(GetInstance.java:243) at sun.security.jca.GetInstance.getInstance(GetInstance.java:190) at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java: 243) at com.ongelooflijk.chipknip.Chipknip.getTerminals(Chipknip.java:149) at com.ongelooflijk.chipknip.Chipknip.main(Chipknip.java:29) Caused by: java.lang.UnsupportedOperationException: PC/SC not available on this platform at sun.security.smartcardio.PCSC.checkAvailable(PCSC.java:48) at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun .reflect .NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:57) at sun .reflect .DelegatingConstructorAccessorImpl .newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:539) at java.security.Provider$Service.newInstance(Provider.java:1252) ... 5 more Caused by: java.io.IOException: No PC/SC library found on this system at sun.security.smartcardio.PlatformPCSC.getLibraryName(PlatformPCSC.java: 116) at sun.security.smartcardio.PlatformPCSC.access$000(PlatformPCSC.java: 43) at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:63) at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:59) at java.security.AccessController.doPrivileged(Native Method) at sun.security.smartcardio.PlatformPCSC.<clinit>(PlatformPCSC.java:59) at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun .reflect .NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:57) at sun .reflect .DelegatingConstructorAccessorImpl .newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:539) at java.security.Provider$Service.newInstance(Provider.java:1252) at sun.security.jca.GetInstance.getInstance(GetInstance.java:243) at sun.security.jca.GetInstance.getInstance(GetInstance.java:190) at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java: 243) at javax.smartcardio.TerminalFactory.<clinit>(TerminalFactory.java:106) ... 2 more When I browse the source I see that it most probably fails because it was unable to load the library "j2pcsc". I did some googling and found that on OS X this means that through JNI it is looking for libj2pcsc.jnilib. But the only file I can find in the code distributed by Landon Fuller is libj2pcsc.dylib, which I understand to be an OS X Dynamic Library similar to a DLL on windows. I have the feeling this is more of an issue with the build from Landon than with the OpenJDK 7 bsd port, but I'm a complete noob in these matters, so I think I'd best leave it up to the experts to figure this one out. I don't think this is relevant for this problem, but I'll mention it anyway: I'm using an Omnikey CardMan 3121 and have the Smart Card Services Update v1.1 from Shawn A. Geddis installed. The reader seems to work fine and running pcsctest gives the expected output for the reader as well as the inserted card. Thanks, Nick Hilhorst
On Aug 25, 2008, at 1:47 PM, Nick Hilhorst wrote:
Hi,
I have some code that uses javax.smartcardio that works on Windows, but fails when I try to run it on the version of Java 6 from Apple (same problems as described on http://lists.apple.com/archives/java-dev/2008/May/msg00144.html) , so I decided to give the binary version of openjdk7-darwin- i386-20080820 as built by Landon Fuller a try. Here follows my code for getting the list of configured readers:
/** * * @return List of references to the readers configured in the environment * * @throws CardException */ private static List<CardTerminal> getTerminals() throws CardException { List<CardTerminal> terminals = null; try { TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null); // TerminalFactory factory = TerminalFactory.getDefault(); System.out.println("TerminalFactory Type: " + factory.getType()); // Get the list of readers configured in the environment terminals = factory.terminals().list(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } return terminals; }
This fails with the following:
java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: PC/SC, provider: SunPCSC, class: sun.security.smartcardio.SunPCSC$Factory) at java.security.Provider$Service.newInstance(Provider.java:1257) at sun.security.jca.GetInstance.getInstance(GetInstance.java:243) at sun.security.jca.GetInstance.getInstance(GetInstance.java:190) at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java: 243) at com.ongelooflijk.chipknip.Chipknip.getTerminals(Chipknip.java:149) at com.ongelooflijk.chipknip.Chipknip.main(Chipknip.java:29) Caused by: java.lang.UnsupportedOperationException: PC/SC not available on this platform at sun.security.smartcardio.PCSC.checkAvailable(PCSC.java:48) at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun .reflect .NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:57) at sun .reflect .DelegatingConstructorAccessorImpl .newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:539) at java.security.Provider$Service.newInstance(Provider.java:1252) ... 5 more Caused by: java.io.IOException: No PC/SC library found on this system at sun .security.smartcardio.PlatformPCSC.getLibraryName(PlatformPCSC.java: 116) at sun.security.smartcardio.PlatformPCSC.access $000(PlatformPCSC.java:43) at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:63) at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:59) at java.security.AccessController.doPrivileged(Native Method) at sun.security.smartcardio.PlatformPCSC.<clinit>(PlatformPCSC.java: 59) at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun .reflect .NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:57) at sun .reflect .DelegatingConstructorAccessorImpl .newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:539) at java.security.Provider$Service.newInstance(Provider.java:1252) at sun.security.jca.GetInstance.getInstance(GetInstance.java:243) at sun.security.jca.GetInstance.getInstance(GetInstance.java:190) at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java: 243) at javax.smartcardio.TerminalFactory.<clinit>(TerminalFactory.java: 106) ... 2 more
When I browse the source I see that it most probably fails because it was unable to load the library "j2pcsc". I did some googling and found that on OS X this means that through JNI it is looking for libj2pcsc.jnilib. But the only file I can find in the code distributed by Landon Fuller is libj2pcsc.dylib, which I understand to be an OS X Dynamic Library similar to a DLL on windows. I have the feeling this is more of an issue with the build from Landon than with the OpenJDK 7 bsd port, but I'm a complete noob in these matters, so I think I'd best leave it up to the experts to figure this one out.
SoyLatte/OpenJDK and Apple's Java on Leopard both load dylib and jnilibs.
I don't think this is relevant for this problem, but I'll mention it anyway: I'm using an Omnikey CardMan 3121 and have the Smart Card Services Update v1.1 from Shawn A. Geddis installed. The reader seems to work fine and running pcsctest gives the expected output for the reader as well as the inserted card.
I'm not sure what the problem with SoyLatte is, but I do know why you had a problem using the Java SE 6 supplied by Apple. The problem is that the process that is loading the library has an architecture mis-match. Java SE 6 as provided by Apple is Intel 64-bit only: % file /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/ Libraries/libj2pcsc.jnilib /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libraries/ libj2pcsc.jnilib: Mach-O 64-bit dynamically linked shared library x86_64 but the library it's trying to load is only PPC/Intel 32-bit: % file /System/Library/Frameworks/PCSC.framework/PCSC /System/Library/Frameworks/PCSC.framework/PCSC: Mach-O universal binary with 2 architectures /System/Library/Frameworks/PCSC.framework/PCSC (for architecture i386): Mach-O dynamically linked shared library i386 /System/Library/Frameworks/PCSC.framework/PCSC (for architecture ppc7400): Mach-O dynamically linked shared library ppc Please file a bug at http://bugreporter.apple.com with a code example of how you can reproduce this problem, along with any suggestions on the best way to resolve it. Hope this helps explain what is going on, Mike Swingler Java Runtime Engineer Apple Inc.
Hi Mike, Thanks for your reply. I tried adding -Djava.library.path=/usr/local/ openjdk7-darwin-i386-20080820/jre/lib/i386 as a VM argument in Eclipse to help find the needed dylib, but this didn't help (didn't seem to change a thing actually). Is there anything else I could try or could do to help find the source of the problem with OpenJDK? I asked Shawn Geddis if it is possible to create a version of his Smart Card Services Update that also supports x86_64, which would probably fix the problem I have with Java SE 6. I also filed a bugreport with Apple as you suggested (Problem ID: 6175605). Thanks, Nick
participants (2)
-
Mike Swingler
-
Nick Hilhorst