Re: [2.0-scala] Loading native library (DLL)

397 views
Skip to first unread message

James Roper

unread,
Aug 23, 2012, 9:35:45 AM8/23/12
to play-fr...@googlegroups.com
My understanding of native code is that it gets loaded using a different mechanism to the classpath.  Put your library somewhere (possibly outside of the play dist zip), and then supply this argument to the play start command:

-Djava.library.path=D:\path\to\your\dll\directory

To do the same during development is a bit harder, you'll probably need to modify the play start script to supply custom arguments to the SBT JVM.

Hope this helps,

James

On Thursday, 23 August 2012 09:49:33 UTC+2, Ronald wrote:
Hey there, 

I'm trying to integrate tapi functionality into a play app, but I have trouble loading the native library (TapiProvider.dll) that is needed for this to work. TapiProvider.dll is used by GJTAPI. As of now, I'm able to communicate with the telephone system through a standalone scala application

For play, this is the approach I tried. I use the same object and call initTerminals in onStart of the Global object. As it seems  the dll is not loaded as the tapi3 service isn't available inside the play application. If I try to load it manually (System.load("D:\\play-projects\\autepro\\lib\\Tapi3Provider.dll")) I get the following on the second request:
UnsatisfiedLinkError: Native Library D:\play-projects\autepro\lib\Tapi3Provider.dll already loaded in another classloader
and still the service is missing.

I know that my request seems rather special. :/ Any suggestion from your side is much appreciated and if you need any information feel free to ask for it. If play doesn't support this scenario I'll have to try to stick with the standalone scala application.

Gustavo Hexsel

unread,
Aug 24, 2012, 7:11:05 PM8/24/12
to play-fr...@googlegroups.com
  Is this only on dev mode or on prod mode as well?

  Dev mode does call the onStart method every time you touch any file, which will probably lead to the error you're seeing.  If that's the only case you're getting this error, you can probably put it in a hacky try-catch that checks for UnsatisfiedLinkError with "already loaded" as a message, and just ignores that message.  Rethrow if the message is not that...

Gustavo Hexsel

unread,
Aug 24, 2012, 7:52:53 PM8/24/12
to play-fr...@googlegroups.com
  Oh wow, on a side note, I never gave google any personal information OR picture picture (directly, at least), so I'm kinda pissed they added my name and picture to a profile and to this post, automatically...

  Do no evil, now with a less "no evil"!


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/ufQPgZtnJucJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Ronald

unread,
Aug 31, 2012, 9:05:51 AM8/31/12
to play-fr...@googlegroups.com
Thank you for your answers and sorry for the late reply.

I played around with your suggestion but it seems that there is still something wrong. VisualVM shows that the argument is actually passed to the JVM. 

Ronald

unread,
Sep 3, 2012, 6:28:18 AM9/3/12
to play-fr...@googlegroups.com
For anyone having similar issues with this or other libraries.
GJTAPI needs the file Tapi3.gjtapi. In my standalone app the file was at the application root besides the DLL. In play I just forgot to add it. After pasting it into the root directory the TAPI3 service loads without a problem. 

Thank you and have a nice day :)
Reply all
Reply to author
Forward
0 new messages