-->

JNotify preventing execution of Play Application

2019-07-19 22:23发布

问题:

Prior to upgrading, our application was at v2.1.1 and I was getting warnings about the absence of JNotify. No harm no foul as far as I could tell. However, after migrating to v2.3.1, the warning has turned into a show-stopping exception. I compile and then attempt to run and receive the following output:

java.lang.NoClassDefFoundError: Could not initialize class net.contentobjects.jnotify.JNotify
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at play.PlayReloader$$anon$1$$anon$7.removeWatch(PlayReloader.scala:113)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at play.PlayReloader$$anon$1.liftedTree1$1(PlayReloader.scala:119)
    at play.PlayReloader$$anon$1.jnotify$lzycompute(PlayReloader.scala:60)
    at play.PlayReloader$$anon$1.jnotify(PlayReloader.scala:40)
    at play.PlayReloader$$anon$1$$anonfun$10.apply(PlayReloader.scala:155)
    at play.PlayReloader$$anon$1$$anonfun$10.apply(PlayReloader.scala:155)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at play.PlayReloader$$anon$1.<init>(PlayReloader.scala:155)
    at play.PlayReloader$class.newReloader(PlayReloader.scala:24)
    at play.Play$.newReloader(Project.scala:17)
    at play.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$1.reloader$lzycompute$1(PlayRun.scala:175)
    at play.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$1.play$PlayRun$class$$anonfun$$anonfun$$reloader$1(PlayRun.scala:175)
    at play.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$1.apply(PlayRun.scala:198)
    at play.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$1.apply(PlayRun.scala:98)
    at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:35)
    at scala.Function9$$anonfun$tupled$1.apply(Function9.scala:34)
    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.NoClassDefFoundError: Could not initialize class net.contentobjects.jnotify.JNotify

I did a bit of digging and I know that the JNotify library should be available as I found a v0.94 jar in both the activator/repository/ as well as the user/.ivy2/cache/ repository (along with all my custom dependencies which are getting picked up). [Additionally, I have it in a local Maven repository and added it as a dependency in Build.scala which it also seems to find without issue during compilation.) Is there some kind of manual process I missed that's required? As far as I can tell, it should be available to the application.

(I know there was a note about JNotify in the release notes for v2.3.2, but it appears to be a different issue and there's no mention of a critical bug in v2.3.1.)

回答1:

After further investigation, it appears that this is due to a bug in v2.3.1 which has been addressed in v2.3.2. The bug report is here: https://github.com/playframework/playframework/issues/2946. The bug manifests itself differently than what is described in the bug report, but the process to repeat it involves some of the same steps. A workaround for those stuck using v2.3.1 for now is simply to avoid using the 'reload' command from within the activator console. Exit activator and restart it if a reload is needed as this workflow does not result in this problem.

EDIT: Found additional bug reports -- one of which describes outlines the problem encountered.

https://github.com/playframework/playframework/issues/3170 https://github.com/playframework/playframework/pull/2620