________________________________ From: ahardy42 <adam.ha...@cyberspaceroad.com> Sent: Thursday, January 4, 2018 11:12 AM To: users@maven.apache.org Subject: ServiceLoader not loading FileTypeDetector implementation in jar
I created, tested and packaged a java.nio.file.spi.FileTypeDetector implementation in a utility jar for use by Files.probeContentType(path). So it works beautifully in my utility project. I'm now trying to use it in another project but despite hours of trying, I can't work out why the JVM can't find or load my implementation and keeps defaulting back to the JDK's RegisterFileTypeDetector. I have double checked that the utility jar is in my classpath with dependency:tree, contains the META-INF/services/java.nio.file.spi.FileTypeDetector file naming my implementation, and also the actual implementation class. The JDK javadoc documentation claims that it will seek it out anywhere on the application's classpath: https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html ServiceLoader (Java Platform SE 8 ) - Oracle Help Center<https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html> docs.oracle.com A simple service-provider loading facility. A service is a well-known set of interfaces and (usually abstract) classes. A service provider is a specific ... MG>*possible permissions error* on the maven user you are implementing MG>System.getSecurityManager<http://www.grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/System.java#System.getSecurityManager%28%29>().checkPermission<http://www.grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/SecurityManager.java#SecurityManager.checkPermission%28java.security.Permission%29>(new RuntimePermission<http://www.grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/RuntimePermission.java#RuntimePermission>("fileTypeDetector")); MG>what is the result of the above statement? http://www.grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/nio/file/spi/FileTypeDetector.java#FileTypeDetector GC: FileTypeDetector - java.nio.file.spi.FileTypeDetector (.java) - GrepCode Class Source<http://www.grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/nio/file/spi/FileTypeDetector.java#FileTypeDetector> www.grepcode.com java.nio.file.spi.FileTypeDetector - A file type detector for probing a file to guess its file type but I only see it searching on the system classpath during debugging. My efforts are hampered by the use of nested arrays of Enumeration<URL> with sun.misc.CompoundEnumeration. It's really convoluted and I haven't been able to see where it fails. What could I be doing wrong? -- Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html Maven - Maven - Users | Mailing List Archive<http://maven.40175.n5.nabble.com/Maven-Users-f40176.html> maven.40175.n5.nabble.com This forum is an archive for the mailing list users@maven.apache.org (more options) Messages posted here will be sent to this mailing list. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org