Using Gephi inside a Play Application

依然范特西╮ 提交于 2019-12-12 04:26:00

问题


I am currently building a Play Framework application in Scala that requires the use of the Gephi Java library.

I tried adding Gephi as a managed dependency in SBT, but SBT cannot resolve all of Gephi's dependencies. This is a known issue. I then simply tried to add the whole Gephi JAR in my lib/ folder as an unmanaged dependency. IntelliJ detects the library just fine and I can compile my application perfectly fine. The problem is an exception occurs immediately upon starting the application, and it seems to be related to dependency injection:

    play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;]
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:174)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    at com.google.common.cache.CacheBuilder.getKeyStrength(CacheBuilder.java:529)
    at com.google.common.cache.LocalCache.<init>(LocalCache.java:242)
    at com.google.common.cache.LocalCache$LocalManualCache.<init>(LocalCache.java:4718)
    at com.google.common.cache.CacheBuilder.build(CacheBuilder.java:807)
    at com.google.inject.internal.WeakKeySet.<init>(WeakKeySet.java:55)
    at com.google.inject.internal.InheritingState.<init>(InheritingState.java:67)
    at com.google.inject.internal.InjectorShell$Builder.getState(InjectorShell.java:209)
    at com.google.inject.internal.InjectorShell$Builder.lock(InjectorShell.java:115)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
    at com.google.inject.Guice.createInjector(Guice.java:96)

I tried removing all mention of Gephi in the code, while still having the JAR sitting in my lib/ folder, but it results in the same exception.

Gephi is really important for this project, so I can't just move on to another library. Any ideas?


回答1:


Remove that jar fom lib, add those two additional resolvers (in build.sbt)

resolvers += "NetBeans" at "http://bits.netbeans.org/nexus/content/groups/netbeans/"

resolvers += "gephi" at "https://raw.github.com/gephi/gephi/mvn-thirdparty-repo/"

and run activator update



来源:https://stackoverflow.com/questions/39685344/using-gephi-inside-a-play-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!