IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

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

GlobalVariablesManager.getInstance() always returning null

  • 1.  GlobalVariablesManager.getInstance() always returning null

    Posted Thu April 28, 2022 05:43 PM

    I am unable to determine why GlobalVariablesManager mgr = GlobalVariablesManager.getIntance() returns null. I am trying to get a Global Setting value from the integration server similar to a Flow Service setting a variable %stringValue% and setting the global variable substitution. Any thoughts? Some of the variable I want pulled directly into my Java Service vs. sending as input parms.

    Test code:

    public static final void testEnv(IData pipeline) throws ServiceException {
    GlobalVariablesManager mgr = GlobalVariablesManager.getInstance();
    GlobalVariables.GlobalVariableValue gvv = null;
    try {
    gvv = mgr.getGlobalVariableValue("myVariableInGlobalSettings");
    } catch (GlobalVariablesException | PasswordManagerException e) {
    e.printStackTrace();
    }
    String s = gvv.getValue();
    }
    

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


  • 2.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 03:13 AM

    I have the exact same code in my tools package

    public static final void getGlobalVariable(IData pipeline) throws ServiceException {
    // pipeline
    
    IDataCursor cursor = pipeline.getCursor();
    String key = IDataUtil.getString(cursor, "key");
    String value = IDataUtil.getString(cursor, "defaultValue");
    String ignoreError = IDataUtil.getString(cursor, "ignoreErrors");
    
    // process
    
    String isSecure = "false";
    
    try {
    GlobalVariablesManager manager = GlobalVariablesManager.getInstance();
    GlobalVariables.GlobalVariableValue gvValue = manager.getGlobalVariableValue(key);
    
    value = gvValue.getValue();
    isSecure = "" + gvValue.isSecure();
    }
    catch (Exception e) {
    if (value == null && (ignoreError == null || ignoreError == "false"))
    throw new ServiceException(e);
    }
    
    // pipeline out
    
    IDataUtil.put(cursor, "value", value);
    IDataUtil.put(cursor, "isSecure", isSecure);
    
    cursor.destroy();
    }
    

    and it works fine, what version of webMethods are you using ?
    Also I see that you catch follows through, are you sure that the exceptions are not being triggered ?
    I would put a throw new ServiceException(e) into the catch to make sure and move the .getValue() into the try clause.

    regards,
    John.


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


  • 3.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 01:08 PM

    Are you invoking this service after IS is up and running? As John mentioned this should not throw any exceptions. Just to see if it makes any difference, if you are getting NPE, can you try adding GlobalVariablesManager.initialize() before you invoke .getInstance() and see if it makes any difference?


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


  • 4.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 02:28 PM

    I must have something off in my configuration. Baffling… I am running 10.3 for the IS.

    Error from the initialize():

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/util/threadpool/ThreadFactory
    at com.wm.app.b2b.server.globalvariables.GlobalVariablesManager.initialize(GlobalVariablesManager.java:44)
    at javaSvc.testEnv_SVC.testEnv(testEnv_SVC.javaservice:26)
    at javaSvc.testEnv_TestHarness.invoke(testEnv_TestHarness.java:217)
    at javaSvc.testEnv_TestHarness.main(testEnv_TestHarness.java:131)
    Caused by: java.lang.ClassNotFoundException: org.apache.axis2.util.threadpool.ThreadFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 4 more
    

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


  • 5.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 02:47 PM

    This class is part of WS-Stack\lib\axis2-kernel-1.6.2.jar. Please see if it is in server’s classpath. You can check this from the About page for Integration Server Admin UI. In addition, please make sure that file actually exists in your env.


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


  • 6.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 03:16 PM


  • 7.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 04:21 PM

    That’s bit strange. Can you please check if class actually exists in axis2-kernel*.jar file? In addition, can you please check what entry do you have in ini.cnf file located under
    IntegrationServer\instances{instanceName}\bin\ini.cnf for application.classpath.additions?

    If it is something different, can you please change it to application.classpath.additions=%WSSTACK_LIB%


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


  • 8.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Fri April 29, 2022 06:42 PM

    I checked and the class is present in the jar file and the ini.cnf has the %WSSTACK_LIB%. One question is I notice under ~\WS-Stack\bin there are several files with a few like axis2.* and axis2server.*. Does one of the other startup config files kick this off or is this a separate process?


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


  • 9.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Wed May 04, 2022 03:04 PM

    I suspect if it works for others then its a missing package or configuration. All the suggestions have been checked and tried with no success. Would this be a case to open a trouble ticket with SAG?


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


  • 10.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Wed May 04, 2022 04:51 PM

    @christopher.fryett , yes please raise a support ticket to identify the root cause.


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


  • 11.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Wed May 04, 2022 11:22 PM

    Hi @christopher.fryett ,
    May be you would still need to open a ticket after this, but have you checked if you are able to create and view global variables through the IS Administrator UI , might help narrow down the cause.

    -NP


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


  • 12.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Thu May 05, 2022 11:22 AM

    Thanks for jumping in on this issue. Yes I am able to see all the global variables in the admin UI. I can also pull in the global variables within my flow service, but I am not able to do it through the java service. I am running 10.3 with the latest patches installed provided to me by the vendor who sold IS and UM to the organization. Support through them has been interesting so I shall see where things go. To summarize:

    • I have used the same code as posted in this thread and others to access the global variables in IS Global Setting
    • I have checked the axis2-kernel-1.6.2.jar resides in the server’s classpath
    • I have checked the ThreadFactory exists in the jar file
    • I have checked the application.classpath.additions is set in the ini.cnf to %WSSTACK_LIB%
    • I have check that I can access the global variables through a flow service and IS console

    Is there any additional out of the box packages I require? I saw a package mentioned in one of the threads on WmAdmin which I do not have installed.


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


  • 13.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Thu May 05, 2022 12:53 PM

    The WmAdmin refers to the new Admin API in later versions , but that doesn’t apply to 10.3.
    I do not see a connection between the GlobalVariables and the axis2 ThreadFactory class. Can you check if you have any jars in your test package under package/code or package/lib?
    Also can you try creating a new package , create a folder with a new name and try writing the same code in the java service and see if it changes things for you?

    -NP


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


  • 14.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Thu May 05, 2022 02:14 PM

    @Nagendra_Prasad your recommendation works. A new package was successful in getting global variables in a Java Service. Where is the flaw then in my original package? Is it the build path or other external jars I am referencing?


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


  • 15.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Thu May 05, 2022 02:19 PM

    @Nagendra_Prasad it works but not in debug mode to be more specific. So, the test handler is throwing my testing off.


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


  • 16.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Mon May 09, 2022 10:57 AM

    Hi Chris,

    when running in debug mode code is executed sligthly different then during running it directly.

    Remember that i.e. explicit transaction handling is not debuggable in Designer.
    Might be similar in your case.

    Regards,
    Holger


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


  • 17.  RE: GlobalVariablesManager.getInstance() always returning null

    Posted Mon May 09, 2022 11:44 AM

    I think you hit it right on the mark @Holger_von_Thomsen and that is what I am seeing in the behavior. I’ll just update my Java Service to take optional input values which I would retrieve from the global settings in IS. It is annoying but actually allows me the override ability if needed down the road. Thank you all for the help, suggestions, and keeping me on my toes.


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