GlobalVariablesManager.getInstance() always returning null

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) {
	String s = gvv.getValue();

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);

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.


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?

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 javaSvc.testEnv_SVC.testEnv(testEnv_SVC.javaservice:26)
	at javaSvc.testEnv_TestHarness.invoke(
	at javaSvc.testEnv_TestHarness.main(
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.util.threadpool.ThreadFactory
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 4 more

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.

I checked and the file exists on the server

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%

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?

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?

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

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.


1 Like

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.

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?


1 Like

@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?

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

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.


1 Like

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.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.