Java Compilation : java.lang.reflect.InvocationTargetException: Link Error **


I have a java program to do encryption and the same will be decrypted using a voltage api.

Here the issue is the java program is working fine

  • Load the java bindings. This requires the simplejava.dll library to be
    * in java.library.path. On Windows, put simplejava.dll in C:\WINDOWS.


and the API Jar file for this is imported on my Windows 64 bit . Havind JDK version 1.8

JAVA_HOME=C:\Program Files\Java\jdk1.8.0_92

The prgram works in JAVA application on Eclipse


The same program is giving an error in webMethods when run from the same as java service.

Error : -

Could not run ‘Sample’
java.lang.reflect.InvocationTargetException: Could not initialize class com.encrypt.toolkit.LibraryContext

I have placed the .dll file in


and the jar are under C:\SoftwareAG\IntegrationServer\instances\SAG99default\packages\Samples\code\jars

As well as tried by placing the .dll under C:\SoftwareAG\lib

Nothing works and it keeps giving the same error.

This is a working JAVA program but when run from SAG java it is throwing an error.

Can you please help. This is urgent


can you try to place the dll in IntegrationServer\lib or IntegrationServer<instance>/\ib?

Remember to shutdown and start the IS otherwise the dll will not be loaded.


Hello Holfer

Yes I have done the same restarted IS but still stuck on the same issue

Gives the same error

  1. Placed it on IntegrationServer\lib restarted IS later

  2. C:\SoftwareAG\IntegrationServer\instances\SAG99default\support\win32


Please help still on the same issue

Hi Mickey,

please name the native library and where exactly you have placed it.

I am using SAP JCo API for connecting to SAP R/3 Systems.
This API contains a native dll and a wrapper jar which encapsulates the native methods via JNI into java methods.

The lib I have placed under IntegrationServer/lib, the jars is placed under IntegrationServer/packages/WmSAP/code/jars/static (as per Adapters documentation).
Please note the static portion in the path as this is required to load the jar statically during startup.

OK, I am not doing Java development on this directly, but it might help to understand the different layer.

In your case the jar should be placed under IntegrationServer/lib/jars/custom.

Shutdown and start the IntegrationServer otherwise the dll and the jar will not be picked up correctly during startup.

Not sure if this is working in Local Service Development Scenario.


Great thanks Holget let me try that option out.

Here it the sample java that works well with the dll and jar on java program but when we code it in SAG it throws the below error

Could not run ‘Sample’
java.lang.reflect.InvocationTargetException: Link Error: Native Library C:\SoftwareAgl\IntegrationServer\instances\default\lib\java.dll already loaded in another classloader

DLL file is there only in SAG location I tried by placing on win32 earlier and changed the wrapper config too. It gives this error whenevr we make any changes on the code

Placed the DLL using System.Load.

Code :-

try {
String URL = “testpolicy.xml”;
String emailAddress = “”;

	Encrypt en= null;
				String text;
	byte[] textBytes, EncrypVal, resultVals;
	plaintext = "Apply policy";
	textBytes = plaintext.getBytes();
	EncrypVal = en.Encrypt(newVal, Info, null, textBytes);
	String newIdentity =en.EncrptionEncrypVal);

	resultVals =en.EncryptVal(new Val, Info, SHA, EncrypVal);

Nope :frowning: still same issue

Now it is giving error stating

Could not run ‘Sample’
java.lang.reflect.InvocationTargetException: Could not initialize class com.val.EncryptContext