Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBT JNI Classes not available after publishing jar(s) #134

Closed
chitralverma opened this issue Jan 4, 2023 · 4 comments
Closed

SBT JNI Classes not available after publishing jar(s) #134

chitralverma opened this issue Jan 4, 2023 · 4 comments
Labels

Comments

@chitralverma
Copy link

SBT JNI Classes not available after publishing jar(s) even though the following is set,

sbtJniCoreScope := Compile,

Any solutions for this except for using assembly plugin ?

Exception in thread "main" java.lang.NoClassDefFoundError: com/github/sbt/jni/syntax/NativeLoader
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at org.a.b.c..version(Test.scala)
	at org.a.b.c.Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: com.github.sbt.jni.syntax.NativeLoader
	at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	... 26 more
@pomadchin
Copy link
Member

Hello @chitralverma, sbtJniCoreScope := Compile setting should be enough.
I'm using this plugin here and it keeps the dependency after the release.

Mb you could share the project structure that causes this problem? I.e. a minimized project that allows to reproduce the error happening.

@chitralverma
Copy link
Author

chitralverma commented Jan 4, 2023

Hi @pomadchin , If you download the jar from here, and run the command below, you will see that the class NativeLoader does not exist in the jar. Am I doing something wrong?

java -jar <path to downloaded jar>

im running + publishLocal in sbt shell and picking up my jar from ~/.ivy2/local/ ...

@pomadchin
Copy link
Member

pomadchin commented Jan 4, 2023

It is a transitive dependency, you can use SBT to configure the PDAL dependency in this case; and SBT JNI will pull down the sbt-jni-core from maven central and put it into your app classpath.

I'd recommend you to get familiar with https://www.scala-sbt.org/1.x/docs/Library-Dependencies.html#Managed+Dependencies

@chitralverma
Copy link
Author

yea I saw that it's present in the generated pom.

Thanks, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants