The reason for the Java.lang.UnsatisfiedLinkError:CC error in the Java EE engine

Source: Internet
Author: User
Tags throw exception


There are several reasons and how to Java.lang.UnsatisfiedLinkError:CC errors in running the JSP Report Program page:

1. Please check the console for error messages

A: If the console message is similar

Java.lang.UnsatisfiedLinkError:no mrchklib in Java.library.path,error loading library mrchklib

This error message, it is because the MRChkLib.dll is not copied to the Windows System32 directory. (MRChkLib.dll is the Java interface file for the encryption lock, which can be found under the report installation directory DOGDRIVER/JAVAAPI) and


Be aware that the PATH environment variable contains the System32 directory. (If the server operating system is Linux, use the libmrchklib.so file under report installation directory Dogdriver/javaapi to copy libmrchklib.so to webserver


The Startup Bin directory. If the can not load LIBRARY error still occurs under this directory, set the system environment variable Ld_library_path value to the directory where libmrchklib.so resides.

For example: If Libmrchklib.so is in the/somedir directory, export ld_library_path= $LD _library_path:/somedir)

B: If the console message is similar

Java.lang.unsatisfiedLinkError:native libery C:/winnt/system32/mrchklib.dll already loaded in another ClassLoader Error loading Mrchklib.dll

This error message is because WebApp cannot load the dynamic library again after it is restarted, which is a Java constraint, and Java does not allow an instance to load multiple dynamic libraries. This can be resolved by copying the Mr.jar to webserver


The Lib directory, delete the Mr.jar under the/web-inf/lib directory, and then restart webserver.


2. If you have more than one report application on a webserver, please/web-inf/lib/ Mr.jar move to Webserver's Lib directory, make sure that there are no mr.jar in each Web application directory, and that only the webserver Lib directory has the text


Restart the webserver.


3, a webserver can only have a Mr.jar file, delete the redundant mr*.jar files, and then clear webserver temporary files, restart webserver.

===================================================================================

The recent project used the JNI, so installed eclipse of the CDT and MinGW to use, not how to move the C language, the Internet to find the next tutorial, it is quite easy, all the way down there is no hint of error, but in the last call to the local method is


Encountered the * * * annoying, always prompt to find the method. Even a simple HelloWorld is the same

Exception in thread "main" Java.lang.UnsatisfiedLinkError:HelloWorld.print () V

Strange, loadLibrary () No problem, how can not find a method? With DLL export Viewer, the method of export is

Address offset of function name

[Email protected] 0x67741250 0x00001250


There is no way, had to install a huge Visual Studio re-compile, the call succeeded!

Again with the DLL Export Viewer, we find that the function name is preceded by an underscore

Address offset of function name

[Email protected] 0x67741250 0x00001250

It seems to give MinGW a few parameters, after online access to data, finally found a solution: to MinGW ld command to specify a parameter--kill-at can

GCC-WL,--kill-at-shared-o Jnihello.dll helloworld.c

Use DLL export viewer again to see that the exported function name changes to

Address offset of function name

Java_helloworld_print 0x67741250 0x00001250


The--KILL-AT directive removes the @ of the function name suffix and does not have an underscore that adds a prefix like msvc

========================================================================

Phenomenon: Java.lang.UnsatisfiedLinkError:Native Library Xxx.dll already loaded in another classloader at Java.lang.ClassLoader . LOADLIBRARY0 (classloader.java:1551)


At Java.lang.ClassLoader.loadLibrary (classloader.java:1511) at Java.lang.Runtime.loadLibrary0 (runtime.java:788) at Java.lang.System.loadLibrary (system.java:834)


Analysis: This error occurs when we use a hot-boot approach to publish a Web application that uses JNI technology, and the jar package that calls the year native method is deployed independently under the application, and when our web app has an update, it is called to the jar


This error is thrown when the native method is encapsulated by the package. (The above OS is Windows, if Linux or UNIX, it should be xxx.so error) This is because the Web server has already loaded the DLL when the application was load for the first time, when the application was


When the heat starts again, the DLL will be reloaded and an error occurs. Solution: First, the jar package containing the JNI call is deployed in the public Lib library of the Web server. The Web application can be re-released without loading, and the jar package is deployed unchanged in the


Implement a listener in the Web to listen for the first time, not the first boot, the load of the DLL contained in the jar package is blocked.

========================================================================

Class loading problem: Unsatisfiedlinkerror


Unsatisfiedlinkerror

The class loader plays an important role when a native call is linked to the corresponding native definition. If the program attempts to mount a non-existent or misplaced native library, the parsing process during the link phase occurs unsatisfiedlinkerror. JVM rules


Van designation Unsatisfiedlinkerror is:

For a method declared as native, the exception is thrown if the Java virtual machine cannot find the native language definition that corresponds to it.

When a native method is called, the class loader attempts to load the native library that defines the method. If this library is not found, this error will be thrown.

Listing 6 shows the test cases that throw Unsatisfiedlinkerror:



Listing 6. Unsatisfiedlinkerror.java

public class Unsatisfiedlinkerrortest {

public native void Call_a_native_method ();

static {

System.loadlibrary ("Mynativelibrary");

}

public static void Main (string[] args) {

New Unsatisfiedlinkerrortest (). Call_a_native_method ();

}

}


This code calls the native method Call_a_native_method (), which is defined in native library mynativelibrary. Because the library does not exist, the following error occurs when the program is running:

The Java class could not being loaded. Java.lang.UnsatisfiedLinkError:

Cant Find Library Mynativelibrary (MyNativeLibrary.dll)

In Sun.boot.library.path or Java.library.path

Sun.boot.library.path=d:/sdk/jre/bin

Java.library.path= D:/sdk/jre/bin

At Java.lang.classloader$nativelibrary.load (Native Method)

At Java.lang.ClassLoader.loadLibrary0 (classloader.java:2147)

At Java.lang.ClassLoader.loadLibrary (classloader.java:2006)

At Java.lang.Runtime.loadLibrary0 (runtime.java:824)

At Java.lang.System.loadLibrary (system.java:908)

At Unsatisfiedlinkerrortest.<clinit> (unsatisfiedlinkerrortest.java:6)


The loading of the native library is initiated by the class loader of the class calling the System.loadlibrary () method-in Listing 6, the Unsatisfiedlinkerrortest class loader. Depending on the class loader used, a different location is searched:

For classes loaded by the Bootstrap class loader, search for Sun.boot.library.path.

For classes loaded by the Extension class loader, search for java.ext.dirs first, then Sun.boot.library.path, and then Java.library.path.

For classes loaded by the System class loader, search for Sun.boot.library.path, then Java.library.path.

In Listing 6, the Unsatisfiedlinkerrortest class is loaded by the System class loader. To mount the referenced native library, the class loader looks for Sun.boot.library.path first, and then looks for Java.library.path. Because in


There are no libraries required in the two locations, so the class loader throws Unsatisfiedlinkageerror.

==========================================================================

Java.lang.UnsatisfiedLinkError This error occurs because the Java Virtual machine cannot find an error when it declares a local language definition for the native method. In my understanding, I generally think it is due to the import DLL or


The incorrect import Lib file is caused. Some need static import there is no problem (that is, before adding static to import the Lib file), if the non-static import is the dynamic import, then you need to add catch throw exception to solve


In a decision, such as

try{

System.loadlibrary ("Vtkcommonjava");

System.loadlibrary ("Vtkfilteringjava");

System.loadlibrary ("Vtkiojava");

System.loadlibrary ("Vtkimagingjava");

System.loadlibrary ("Vtkgraphicsjava");

System.loadlibrary ("Vtkrenderingjava");

}catch (Throwable e)

{

SYSTEM.OUT.PRINTLN ("The Load Problem");

}

This way to judge, or directly before the class to add

static{

System.loadlibrary ("Vtkcommonjava");

System.loadlibrary ("Vtkfilteringjava");

System.loadlibrary ("Vtkiojava");

System.loadlibrary ("Vtkimagingjava");

System.loadlibrary ("Vtkgraphicsjava");

System.loadlibrary ("Vtkrenderingjava");

}

================================================================================

About Java.lang.UnsatisfiedLinkError (JNI)



Goal: Move pbp1.0 Java packages and native into the gem and make the gem work on the new virtual machine

Background: GEM (1) has a bunch of Java packages and native functions, pbp1.0 is a virtual machine and Java Basic package, to move pbp1.0 's virtual machine away from its Java basic package and native function.

Problem: After generating a dynamic library for the native function of the gem and pbp1.0, the system.loadlibrary () cannot be loaded in the program, and the report Java.lang.UnsatisfiedLinkError

Resolution process:

1, theory

We know that when Java calls the native function, it must be loaded into the virtual machine with the dynamic library where its native function is system.loadlibrary () or system.load. And at run time indicate-djava.library.path or-


Dsun.boot.library.path, point to the location of the dynamic library that contains the native function.

2, implementation

When I follow this step, I cannot load the dynamic library libgem.so I generated, and the other dynamic libraries used in this library include: Rt,pthread,freetype,dl, DIRECTFB, and the dynamic library used by DIRECTFB.


Rt,dl,pthread,freetype,jpeg,png, these libraries exist in the/lib directory in addition to the DIRECTFB to generate the rest.

3, Ideas

A test case for Hello is written first. When other dynamic libraries are used in native, they cannot be loaded, regardless of whether they exist in the relevant directory. Then, after modifying the compilation options, dynamically connect the dynamic libraries used to the target


Library, as follows:

$ (GCC)-fpic-shared-o libdirectfb.so ...-lpng-ljpeg-lpthread-lrt-ldl,-lfreetype

After such a modification, the DIRECTFB can be loaded.

This also indicates that all symbols referenced by the dynamic library loaded by System.loadlibrary () are to be found. If there is one that cannot be found, it cannot be loaded. You can write an empty main () function to connect to your dynamic library if the dynamic


If the symbol referenced in the library cannot be compiled by the specified dynamic library and cannot be found by itself, then the dynamic library must not be loaded.

4, Problem solving

According to this idea, the compilation of libgem.so makefile make corresponding changes, solve the problem! And in the Ld_library_path to join the dynamic Library directory.


(1) MHP (multimedia Home Platform) was developed by the DVB Project as the world's first open standard for interactive tel Evision. It is a java-based environment


which defines a generic interface between interactive digital applications and the terminals on which those applications E Xecute. MHP is designed to run on DVB


Platforms But there is a demand to extend the interoperability it offers to other digital television platforms. This demand gave rise to GEM, or globally


Executable MHP, a framework which allows other organisations to define specifications based on MHP.

====================================================================================

In addition, the DLL itself may be a problem, use the release version, and do not use the debug version of the

=============================================================================

About the Unsatisfiedlinkerror error when writing JNI--


This error also let me depressed for a long time, now I write it, can let everyone less go a little detour. There are generally two kinds of this error:

1. Unsatisfiedlinkerror:dll name, that means you do not put the DLL in the appropriate location, generally with the class to invoke the native function is put together, of course, if you successfully generated the DLL

2. Unsatisfiedlinkerror: Method Name, this time you actually DLL has been successfully generated, and the location is also correct, it means that you do not define that function, you may say, I clearly defined, in fact, when you find the problem lies,


You have to be self-inflicted. Some letters are wrong when you define a function in a C file, because other places are automatically generated and do not go wrong. This problem often occurs when copying source programs directly from the Web, and some authors are irresponsible,


Put up the wrong program.


This article is from the "lake and Laughter" blog, please make sure to keep this source http://hashlinux.blog.51cto.com/9647696/1736878

The reason for the Java.lang.UnsatisfiedLinkError:CC error in the Java EE engine

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.