How to use custom .JAR Mid server packages?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2015 10:22 AM
Hi all,
i uploaded my custom jar as per this page MID Server - ServiceNow Wiki but it doesnot say how to use it. can any one help?
The jar is uploaded to the extlib folder using the JAR Files module. When I call the methods in the package using the Javascript Probe, I get the output in the ECC queue as :
TypeError: [JavaPackage org.demo.test] is not a function.
However, when I place the jar in the lib folder and invoke the package call using the Javascript Probe, I get the proper results in the ECC queue.
Can you please help me what needs to be done to make the packages call work for the jar placed in extlib folder ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 07:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 08:12 AM
.. because you need to do something with the output.
Try: document.write(returnValue) or ms.log("The value is:" + returnValue) - something that writes it out, rather than holds it within JavaScript.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 10:07 AM
Hi Dave,
I have tested ms.log("The value is:" + returnValue) and it ´s showed on the MID Server log, but still the /output tag is empty.
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2017 12:41 PM
In your JavascriptProbe the return should be the last javascript object referenced.
So try:
var doSomething = new Packages.com.reed.mid.DoSomething(); var returnValue = doSomething.doIt(); ms.log('Hello World'); returnValue;
On a side note:
If you include these imports in your java classes:
import com.snc.core_automation_common.logging.Logger;
import com.snc.core_automation_common.logging.LoggerFactory;
and define a logger:
private static final Logger log = LoggerFactory.getLogger(ProjectHelper.class);
Then your log messages in you custom jar will should up in the agent.log.
The other thing I to do is setup a development mid server on the box you are developing on. Update the wrapper-override.conf and enable JDP which allows you to debug your code with the ServiceNow instance providing triggering of running your methods.
V/r,
Gene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2017 01:52 AM
Hi Gene,
Thanks for your suggestion. I will use the logger on the MID Server, really useful!
I have found that </output> tag was empty because I call to the probe as follows:
jspr.setJavascript("var doSomething = new Packages.com.reed.mid.DoSomething(); doSomething.doIt();ms.log('Hello World');");
I have moved ms.log before the call to the JAR:
jspr.setJavascript("var doSomething = new Packages.com.reed.mid.DoSomething();ms.log('Hello World');doSomething.doIt();");
Now the <Output> has the message from the JAR file!
Best regards,
Oscar