Skip to content

Instantly share code, notes, and snippets.

@shkhln
Last active August 29, 2015 14:07
Show Gist options
  • Save shkhln/cbad4c62dc886ade1b40 to your computer and use it in GitHub Desktop.
Save shkhln/cbad4c62dc886ade1b40 to your computer and use it in GitHub Desktop.
package controllers
import play.api._
import play.api.mvc._
import org.opencv.core.Mat
import org.opencv.core.CvType
import play.api.Play.current
object Application extends Controller {
System.load(Play.getFile("./lib/libopencv_java247.so").getPath)
def getField(obj: Object, clazz: Class[_], fieldName: String) = {
val field = clazz.getDeclaredField(fieldName)
field.setAccessible(true)
field.get(obj)
}
def p(cl: ClassLoader): Unit = {
println(s" --- " + "%-50s".format(cl.getClass) + " [" + cl.toString.take(50) + "]")
val nativeLibraries = getField(cl, classOf[ClassLoader], "nativeLibraries").asInstanceOf[java.util.Vector[Object]]
for (i <- 0 until nativeLibraries.size) {
val lib = nativeLibraries.get(i)
println(getField(lib, lib.getClass, "name"))
}
val parent = cl.getParent
if (parent != null) {
p(parent)
}
}
def index = Action {
p(this.getClass.getClassLoader)
val m = Mat.eye(3, 3, CvType.CV_8UC1)
Ok("m = " + m.dump())
}
}
findNative: [null, Java_sun_nio_ch_ServerSocketChannelImpl_accept0, ]
--> 36488467888
findNative: [null, Java_sun_nio_ch_FileDispatcherImpl_read0, ]
--> 36488462208
findNative: [play.PlayRun$$anonfun$9$$anon$1@233e9780, Java_org_opencv_core_Mat_n_1eye, ]
--> 0
findNative: [play.PlayRun$$anonfun$9$$anon$1@233e9780, Java_org_opencv_core_Mat_n_1eye__III, ]
--> 0
findNative: [play.PlayRun$$anonfun$9$$anon$1@233e9780, Java_org_opencv_core_Mat_n_1eye, ]
--> 0
findNative: [play.PlayRun$$anonfun$9$$anon$1@233e9780, Java_org_opencv_core_Mat_n_1eye__III, ]
--> 0
findNative: [null, Java_sun_nio_ch_FileDispatcherImpl_write0, ]
--> 36488461952
findNative: [null, Java_sun_nio_ch_FileDispatcherImpl_close0, ]
--> 36488462384
import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace public class Probe {
@OnMethod(clazz="java.lang.ClassLoader", method="findNative", location = @Location(Kind.RETURN))
public static void printArgs(AnyType[] args, @Return long retVal) {
print("findNative: ");
printArray(args);
print(" --> ");
print(retVal);
println();
}
}
[info] play - Application started (Dev)
--- class play.PlayRun$$anonfun$10$$anon$2 [ReloadableClassLoader(v1){file:/usr/home/alex/play]
/usr/home/alex/playground/opencv-play-run/lib/libopencv_java247.so
--- class play.sbtplugin.run.AssetsClassLoader [play.sbtplugin.run.AssetsClassLoader@26d1bc87]
--- class play.PlayRun$$anonfun$9$$anon$1 [PlayDependencyClassLoader{file:/usr/home/alex/play]
--- class play.core.classloader.DelegatingClassLoader [DelegatingClassLoader, using parent: Common ClassL]
--- class play.PlayCommands$$anonfun$19$$anon$1 [Common ClassLoader: file:/usr/home/alex/.ivy2/cach]
[error] application -
! @6jodkcj6a - Internal server error, for (GET) [/] ->
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J]]
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.4.jar:2.3.4]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.4.jar:2.3.4]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.4.jar:2.3.4]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.1.jar:na]
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.11-2.3.4.jar:2.3.4]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.3.4.jar:2.3.4]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129) ~[play_2.11-2.3.4.jar:2.3.4]
Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
at org.opencv.core.Mat.n_eye(Native Method) ~[opencv-247.jar:na]
at org.opencv.core.Mat.eye(Mat.java:1467) ~[opencv-247.jar:na]
at controllers.Application$$anonfun$index$1.apply(Application.scala:40) ~[classes/:na]
at controllers.Application$$anonfun$index$1.apply(Application.scala:37) ~[classes/:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$17.apply(Action.scala:464) ~[play_2.11-2.3.4.jar:2.3.4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment