webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

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

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

    Posted Thu October 27, 2016 12:35 AM

    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


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


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

    Posted Mon October 31, 2016 12:22 PM


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

    Posted Mon October 31, 2016 01:51 PM

    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


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


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

    Posted Mon October 31, 2016 04:00 PM

    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


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


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

    Posted Mon October 31, 2016 04:04 PM

    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


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


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

    Posted Thu November 17, 2016 01:05 PM

    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.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods