christian-schlichtherle / truelicense

An open source engine for license management on the Java Virtual Machine.
https://truelicense.namespace.global
Apache License 2.0
319 stars 66 forks source link

java.io.FileNotFoundException: public.ks #29

Open tied opened 1 year ago

tied commented 1 year ago

Hello,

I'm building a Java plugin for Atlassian Jira (On-Premise) and try to implement truelicense to license our plugin.

Everything works in the local testing / development from IntelliJ / Maven and the public.ks file is visible in target/classes/public.ks. If I extract my *.jar file I also can see the file.

I've installed the public in my standalone server instance and the truelicense libraries / dependencies are correctly loaded and can be used.

It always throw FileNotFoundException on manager.install(source).

I've also did some research... https://developer.atlassian.com/server/confluence/what-is-the-best-way-to-load-a-class-or-resource-from-a-plugin/

I've tried multiple variants.

InputStream inputStream = ClassLoaderUtils.getResourceAsStream("public.ks", this.getClass());
        int value = inputStream.available();
        log.debug("inputStream.available() " + value);

final URL publicKsURL = ClassLoaderUtils.getResource("public.ks", getClass());

URL resource1 = getClass().getClassLoader().getResource("public.ks");
URL resource2 = ConsumerLicenseManager.class.getClassLoader().getResource("public.ks");
URL resource3 = getClass().getResource("/public.ks");
URL resource4 = ConsumerLicenseManager.class.getResource("/public.ks");
2022-09-10 11:03:47,311+0200 inputStream.available() 1378
2022-09-10 11:03:47,311+0200 Loading publicKsURL from bundle://295.0:1/public.ks
2022-09-10 11:03:47,312+0200 Loading resource1 from bundle://295.0:1/public.ks
2022-09-10 11:03:47,312+0200 Loading resource2 from bundle://295.0:1/public.ks
2022-09-10 11:03:47,312+0200 Loading resource3 from bundle://295.0:1/public.ks
2022-09-10 11:03:47,312+0200  Loading resource4 from bundle://295.0:1/public.ks

If I replace the filename with something different if failes with a NullPointerException. So for me it looks like that the public.ks is in the classpath. truelicense doesn't picks it.

Did I miss something? I'm slowly running out of ideas and I hope you can give me some hint.

Kind Regards, Tim