How to execute DLL in Java code - java.lang.reflect.InvocationTargetException: DLL already loaded

jHi

Where do we place the DLL file to excecute a java code in SAG and what is the property to use in the service

How to call the dll from within the SAG java code ??

I get an errror :-

java.lang.reflect.InvocationTargetException: Link Error: Native Library C:\SAGlocal\IntegrationServer\instances\default\support\win32\java.dll already loaded in another classloader. I have the dll only in some test folders and not inside SAG location or C:\Windows then why do I see this error.

For the Java Program , it is sufficient to have it in C:\Windows but for the SAG service I just need to have it on the win32 location I suppose.

Pl Let me know if that is right .

Regards
Mickey

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.

Regards,
Holger

Hello Holger

Thank you. Let me try this out. It is working as a Java code when code in SAG throws up the error.

Let me use the option you provided

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

Sometimes there might be a reference within your Java code that is referring to a same jar as webMethods IS uses internally. For example, if you want to implement PGP Encryption using Bouncy Castle in webMethods IS using a Java service, you have to make sure that the package manifest.v3 has the entry “package” to tell that the class loader is at package level and not at IS level. It seems that IS not able to initialize EncryptContext class in the jar. Did the files in Jar it compile alright in Java Eclipse?

Copy the jar file in to your package\code\jars folder.
Add the above mentioned entry in the Package manifest file.
Reload the package.
If you are debugging from Designer then add the jar to your Designer workspace as well.