Eclipse Auto Deploy does not include native libraries

I have a Java webapp in eclipse. I have automatic deployment enabled, so whenever I make changes, eclipse automatically reconfigures the webapp to my local Tomcat server, and all I have to do is refresh the page. It still worked fine and dandy.

However, I recently added this dependency:

<dependency> <groupId>com.eclipsesource.j2v8</groupId> <artifactId>j2v8_win32_x86_64</artifactId> <version>3.1.6</version> </dependency> 

This dependency includes some native libraries ( .dll files on my Windows machine). When I manually deploy (by right-clicking the project, clicking "run as", and then "run on server"), this works fine. I can use the library as I expected.

If I make a change (any change, even adding a comment), eclipse will automatically redistribute. But when I try to use this library (just refreshing the page and running the same code again), I get this error:

 java.lang.UnsatisfiedLinkError: Could not load J2V8 library. Reasons: no j2v8_win32_x86_64 in java.library.path 

Thus, it seems that eclipse does not load its own libraries during automatic deployment, even if it works fine in manual deployments.

The value of java.library.path is the same in both cases:

 C:\Program Files\Java\jdk1.8.0_65\bin; C:\WINDOWS\Sun\Java\bin; C:\WINDOWS\system32; C:\WINDOWS; C:\ProgramData\Oracle\Java\javapath; C:\Program Files\ImageMagick-6.9.0-Q16; C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common; C:\Program Files\ImageMagick-6.8.9-Q16; C:\Program Files\Java\jdk1.8.0_65; c:\Program Files (x86)\Intel\iCLS Client\; c:\Program Files\Intel\iCLS Client\; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; C:\Program Files\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL; C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT; C:\Program Files\WIDCOMM\Bluetooth Software\; C:\Program Files\WIDCOMM\Bluetooth Software\syswow64; C:\Program Files\TortoiseSVN\bin; C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin; C:\Program Files (x86)\leJOS NXJ\bin; C:\Program Files (x86)\Windows Live\Shared; C:\Program Files\OpenVPN\bin; C:\Program Files\Java\jdk1.8.0_65\bin; C:\Program Files\apache-ant-1.9.3\bin; C:\Program Files\apache-maven-3.2.1\bin; C:\Users\Kevin\Desktop\gradle-2.2.1\bin; ; C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell; . 

In both cases, the location . equal to C:\Users\Kevin\Desktop\eclipse\. , and in both cases it contains the same files:

 #log.txt#save# .eclipseproduct artifacts.xml configuration crawl.log derby.log dropins eclipse.exe eclipse.ini eclipsec.exe epl-v10.html features notice.html p2 plugins Queue.zip readme server StaticVoidGames.log StaticVoidGames_SystemErr.txt StaticVoidGames_SystemOut.txt 

The line of code that throws the exception:

 V8 runtime = V8.createV8Runtime(); 

This code works fine when deployed manually, but it does not work on subsequent automatic deployments.

My googling drew me to this forum post , which only says "about problems with the reboot", but does not offer any solutions. So my questions are:

  • Why is there no eclipse, including native libraries, when redistributing automatically?

  • Can I tell eclipse to enable my own libraries when automatically redistributing? Is there some kind of setting that I don't see?

  • If automatic redeployment just doesn't support native libraries, is there an official source saying that?

+5
source share
1 answer

DLLs are bound to a specific class loader. When redeployed, this means that the class loader used for our application will be destroyed. Unfortunately, the Java virtual machine does not allow the second class loader to reload the DLL again.

I think that it is possible to create a Jar file that loads the DLL and adds it to the classpath of Tomcat itself, rather than adding it to our application. Typically, Tomcat has a “shared” directory into which jar files can be added that will be used by all applications.

Demo:

1. Change the area of ​​the jar with the condition that it can only be used at compile time.

  <dependency> <groupId>com.eclipsesource.j2v8</groupId> <artifactId>j2v8_win32_x86_64</artifactId> <version>3.1.6</version> <scope>provided</scope> </dependency> 
  1. Create a shared folder inside the tomcat folder
  2. Paste j2v8_win32_x86_64-3.1.6.jar into the shared folder

  3. Add $ {catalina.home} / shared / *. jar to the shared.loader property in catalina.properties

Link:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4225434 http://grokbase.com/t/tomcat/users/06acn8f491/jni-native-libraries-and-tomcat-reloading-web-apps

+1
source

Source: https://habr.com/ru/post/1245782/


All Articles