4

I recently started working at a new place where they're using scala and play for this legacy app. Unfortunately no one here is familiar with this error and I'm hoping that some much more experienced scala person can shine a bit of light here.

On Mac OS (Catalina) I'm getting these errors, but when I put everything into a linux VM, I can get it working! So, it's specific to OS X.

Java 8 SBT .13

Here's a couple of stack traces from the SBT console when trying to run the program:

[info] Loading global plugins from /Users/me/.sbt/0.13/plugins
[info] Loading project definition from /Users/me/dev/.../projectDirectory/project
[info] Set current project to RedactedProjectName (in build file:/Users/me/dev/.../projectDirectory/)

[warn] Error loading JNotify watch service: null
--- (Running the application, auto-reloading is enabled) ---

java.lang.ExceptionInInitializerError
    at net.contentobjects.jnotify.macosx.JNotifyAdapterMacOSX.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at net.contentobjects.jnotify.JNotify.<clinit>(Unknown Source)
    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)
    at play.runsupport.JNotifyFileWatchService$JNotifyDelegate.ensureLoaded(FileWatchService.scala:188)
    at play.runsupport.JNotifyFileWatchService$$anonfun$5.apply(FileWatchService.scala:243)
    at play.runsupport.JNotifyFileWatchService$$anonfun$5.apply(FileWatchService.scala:199)
    at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
    at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
    at scala.util.control.Exception$Catch.apply(Exception.scala:102)
    at scala.util.control.Exception$Catch.withTry(Exception.scala:129)
    at play.runsupport.JNotifyFileWatchService$.apply(FileWatchService.scala:199)
    at play.runsupport.FileWatchService$$anon$1.delegate$lzycompute(FileWatchService.scala:80)
    at play.runsupport.FileWatchService$$anon$1.delegate(FileWatchService.scala:76)
    at play.runsupport.FileWatchService$$anon$1.watch(FileWatchService.scala:89)
    at play.runsupport.Reloader.<init>(Reloader.scala:310)
    at play.runsupport.Reloader$.reloader$lzycompute$1(Reloader.scala:210)
    at play.runsupport.Reloader$.play$runsupport$Reloader$$reloader$1(Reloader.scala:210)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
    at java.lang.Runtime.loadLibrary0(Runtime.java:871)
    at java.lang.System.loadLibrary(System.java:1124)
    at net.contentobjects.jnotify.macosx.JNotify_macosx.<clinit>(Unknown Source)
    at net.contentobjects.jnotify.macosx.JNotifyAdapterMacOSX.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at net.contentobjects.jnotify.JNotify.<clinit>(Unknown Source)
    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)
    at play.runsupport.JNotifyFileWatchService$JNotifyDelegate.ensureLoaded(FileWatchService.scala:188)
    at play.runsupport.JNotifyFileWatchService$$anonfun$5.apply(FileWatchService.scala:243)
    at play.runsupport.JNotifyFileWatchService$$anonfun$5.apply(FileWatchService.scala:199)
    at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
    at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
    at scala.util.control.Exception$Catch.apply(Exception.scala:102)
    at scala.util.control.Exception$Catch.withTry(Exception.scala:129)
    at play.runsupport.JNotifyFileWatchService$.apply(FileWatchService.scala:199)
    at play.runsupport.FileWatchService$$anon$1.delegate$lzycompute(FileWatchService.scala:80)
    at play.runsupport.FileWatchService$$anon$1.delegate(FileWatchService.scala:76)
    at play.runsupport.FileWatchService$$anon$1.watch(FileWatchService.scala:89)
    at play.runsupport.Reloader.<init>(Reloader.scala:310)
    at play.runsupport.Reloader$.reloader$lzycompute$1(Reloader.scala:210)
    at play.runsupport.Reloader$.play$runsupport$Reloader$$reloader$1(Reloader.scala:210)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
    at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1535)
    at io.netty.util.internal.ConcurrentSet.add(ConcurrentSet.java:48)
    at io.netty.channel.group.DefaultChannelGroup.add(DefaultChannelGroup.java:133)
    at play.core.server.NettyServer.bind(NettyServer.scala:140)
    at play.core.server.NettyServer.play$core$server$NettyServer$$bindChannel(NettyServer.scala:224)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:216)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:216)
    at scala.Option.map(Option.scala:146)
    at play.core.server.NettyServer.<init>(NettyServer.scala:216)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:279)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:278)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:235)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:65)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:64)
    at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:54)
    at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
    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)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 1 s, completed Apr 2, 2020 4:14:45 PM



If I sbt evicted then sbt run again, the project starts, everything looks fine:

git:(master) ✗ sbt run
[info] Loading global plugins from /Users/me/.sbt/0.13/plugins
[info] Loading project definition from /Users/me/dev/.../projectDir/project
[info] Set current project to theProject (in build file:/Users/me/dev/.../projectDir/ocpapi/)
[info] Updating {file:/Users/jonbuck/dev/.../projectDir/}root...
[info] Resolving jline#jline;2.14.3 ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn]  * com.typesafe.akka:akka-slf4j_2.11:2.4.20 -> 2.5.14
[warn]  * com.typesafe.akka:akka-actor_2.11:(2.4.20, 2.5.1, 2.3.13) -> 2.5.14
[warn] Run 'evicted' to see detailed eviction warnings

[warn] Error loading JNotify watch service: null
--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)



Then when I hit localhost:9000 I start seeing this:

[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

[warn] i.n.c.s.n.NioServerSocketChannel - Failed to create a new channel from an accepted socket.
java.lang.ExceptionInInitializerError: null
    at sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder.defaultOptions(SocketChannelImpl.java:239)
    at sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder.<clinit>(SocketChannelImpl.java:226)
    at sun.nio.ch.SocketChannelImpl.supportedOptions(SocketChannelImpl.java:248)
    at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:166)
    at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:284)
    at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:319)
    at io.netty.channel.socket.DefaultSocketChannelConfig.setTcpNoDelay(DefaultSocketChannelConfig.java:254)
    at io.netty.channel.socket.DefaultSocketChannelConfig.<init>(DefaultSocketChannelConfig.java:54)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:391)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:389)
Caused by: java.lang.NullPointerException: null
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
    at java.lang.Runtime.loadLibrary0(Runtime.java:871)
    at java.lang.System.loadLibrary(System.java:1124)
    at sun.net.ExtendedOptionsImpl.lambda$static$0(ExtendedOptionsImpl.java:48)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.ExtendedOptionsImpl.<clinit>(ExtendedOptionsImpl.java:47)
    at sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder.defaultOptions(SocketChannelImpl.java:239)
    at sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder.<clinit>(SocketChannelImpl.java:226)
    at sun.nio.ch.SocketChannelImpl.supportedOptions(SocketChannelImpl.java:248)
    at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:166)
[warn] i.n.c.s.n.NioServerSocketChannel - Failed to create a new channel from an accepted socket.
java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder
    at sun.nio.ch.SocketChannelImpl.supportedOptions(SocketChannelImpl.java:248)
    at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:166)
    at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:284)
    at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:319)
    at io.netty.channel.socket.DefaultSocketChannelConfig.setTcpNoDelay(DefaultSocketChannelConfig.java:254)
    at io.netty.channel.socket.DefaultSocketChannelConfig.<init>(DefaultSocketChannelConfig.java:54)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:391)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:389)
    at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:98)
    at io.netty.channel.socket.nio.NioServerSocketChannel.doReadMessages(NioServerSocketChannel.java:145)
[warn] i.n.c.s.n.NioServerSocketChannel - Failed to create a new channel from an accepted socket.
java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.SocketChannelImpl$DefaultOptionsHolder
    at sun.nio.ch.SocketChannelImpl.supportedOptions(SocketChannelImpl.java:248)
    at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:166)
    at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:284)
    at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:319)
    at io.netty.channel.socket.DefaultSocketChannelConfig.setTcpNoDelay(DefaultSocketChannelConfig.java:254)
    at io.netty.channel.socket.DefaultSocketChannelConfig.<init>(DefaultSocketChannelConfig.java:54)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:391)
    at io.netty.channel.socket.nio.NioSocketChannel$NioSocketChannelConfig.<init>(NioSocketChannel.java:389)
    at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:98)
    at io.netty.channel.socket.nio.NioServerSocketChannel.doReadMessages(NioServerSocketChannel.java:145)



  • I've tried changing the JVM I'm using, to going as far as wiping my disk and downgrading back to Mojave, thinking that because the native methods weren't signed, they couldn't be executed. I'm still lost. – CodingForFunAndProfit Apr 07 '20 at 23:07
  • What version of Play is this using? I have a similar, if not identical stack trace and have not yet been able to figure out what the issue is. I'm on play `2.6.20`. – sihil Apr 13 '20 at 13:25
  • I've now managed to recreate your second stack trace by removing ~/.ivy2 and starting over. I'm interested in knowing what JVMs you've tried. I've been using the Adopt OpenJDK 1.8.0_242. I ran across [this post](https://stackoverflow.com/questions/60415568/error-when-trying-to-run-a-play-scala-app-with-sbt-after-fresh-install-on-catali) that recommended trying 232 and suddenly the problem disappeared for me. – sihil Apr 13 '20 at 15:08

2 Answers2

3

I believe that this is a bug in OpenJDK version 1.8.0_242 which I assume you are running - see issue JDK-8240521 in the OpenJDK tracker.

Downgrading back to 1.8.0_232 or upgrading to 1.8.0_252 when it is released should solve this issue.

Both of the stack traces you posted show code paths that are tring to instantiate classes using reflection.

This is arguably a duplicate of Error when trying to run a Play Scala app with sbt after fresh install on Catalina: "Error loading JNotify watch service: null" although this question was a lot easier to find as it contained the stacktrace.

sihil
  • 2,563
  • 1
  • 17
  • 24
  • I did exactly this about 3 days ago. I wish that I had updated my question then and saved you the trouble! Thank you for taking the time post your own findings! – CodingForFunAndProfit Apr 14 '20 at 16:03
  • You are correct, I was using 242. I tried using other implementations of 242, like Azul 242, and Amazon's Corretto 242, all of which still had the same problem – CodingForFunAndProfit Apr 14 '20 at 16:22
0

I ended up getting this to work by downgrading my java back to Azul zulu 8.0.232.fx-zulu.

Though, I'm not sure what the exact cause of the problem is.