Passing Environment variable to Mainframe JVM - properties

I am running a JAVA Mainframe JAR. It is working successfully using the IBM JVMLDM fro z/OS. My next step was to integrate an in-house logging framework. I am required to pass several environment variables(user system properties) into the JVM using a STDENV DD statement in the JCL. I am using the environment variables provided by IBM (documentation) within a PARM file as follows:
IJO="$IJO -DCAR_PROP=6123548595"
EXPORT IBM_JAVA_OPTIONS="$IJO "
I am also using the following environment variable in a similar manner:
IJO="$IJO -DCAR_PROP=6123548595"
EXPORT JZOS_JVM_OPTIONS="$IJO "
Neither of these options are working as the property still fails to be captured by the JAR. Looking for some insight as to what might be the issue with the statement with which I may not be familiar.
DOCUMENTATION
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.iean500/bcdbatch.htm

Does using lower-case export work? i.e.
IJO="$IJO -DCAR_PROP=6123548595"
export IBM_JAVA_OPTIONS="$IJO "

Related

dbt - no output on variable flags.WHICH

My issue resides on the fact that when I invoke via Jinja the variable {{ flags.WHICH}} it returns no output.
I am trying to use this variable to get what type of command the DBT is running at the moment, either a run, a test, generate, etc.
I am using the version dbt 0.18.1 with the adapter SPARK
flags.WHICH was not introduced until dbt 1.0. You'll have to upgrade to get that feature. Here is the source for the flags module, if you're interested about the flags available in your version.
Note that in jinja, referencing an undefined variable simply templates to the empty string, and does not raise an exception.

Jmeter Beanshell: Accessing global lists of data

I'm using Jmeter to design a test that requires data to be randomly read from text files. To save memory, I have set up a "setUp Thread Group" with a BeanShell PreProcessor with the following:
//Imports
import org.apache.commons.io.FileUtils;
//Read data files
List items = FileUtils.readLines(new File(vars.get("DataFolder") + "/items.txt"));
//Store for future use
props.put("items", items);
I then attempt to read this in my other thread groups and am trying to access a random line in my text files with something like this:
(props.get("items")).get(new Random().nextInt((props.get("items")).size()))
However, this throws a "Typed variable declaration" error and I think it's because the get() method returns an object and I'm trying to invoke size() on it, since it's really a List. I'm not sure what to do here. My ultimate goal is to define some lists of data once to be used globally in my test so my tests don't have to store this data themselves.
Does anyone have any thoughts as to what might be wrong?
EDIT
I've also tried defining the variables in the setUp thread group as follows:
bsh.shared.items = items;
And then using them as this:
(bsh.shared.items).get(new Random().nextInt((bsh.shared.items).size()))
But that fails with the error "Method size() not found in class'bsh.Primitive'".
You were very close, just add casting to List so the interpreter will know what's the expected object:
log.info(((List)props.get("items")).get(new Random().nextInt((props.get("items")).size())));
Be aware that since JMeter 3.1 it is recommended to use Groovy for any form of scripting as:
Groovy performance is much better
Groovy supports more modern Java features while with Beanshell you're stuck at Java 5 level
Groovy has a plenty of JDK enhancements, i.e. File.readLines() function
So kindly find Groovy solution below:
In the first Thread Group:
props.put('items', new File(vars.get('DataFolder') + '/items.txt').readLines()
In the second Thread Group:
def items = props.get('items')
def randomLine = items.get(new Random().nextInt(items.size))

Calling java code from Apache Derby

I've written a simple method in Java:
package com.fidel.extensions;
public class Extensions {
public static String capitalize(String input) {
return input.toUpperCase();
}
}
I then registered it as a function in Apache Derby.
create function capitalize(inputString varchar(255))
returns varchar(255)
parameter style JAVA
no sql language JAVA
external name 'com.fidel.extensions.Extensions.capitalize'
In order to give the database access to that code, this page suggests I have two choices:
Install the jar into the database
Add the jar to CLASSPATH
This is the text from that article:
The compiled Java for a procedure (or function) may be stored in the
database using the standard SQL procedure SQLJ.INSTALL_JAR or may be
stored outside the database in the class path of the application.
If I use the INSTALL_JAR approach to embed the jar into the database, my queries work fine. For example:
select capitalize('hello') from SYSIBM.SYSDUMMY1
However I don't actually want to store the jar in the database. I would like derby to look in my CLASSPATH variable to find it.
So I've added it to my CLASSPATH using the following:
export CLASSPATH=${CLASSPATH}:/home/fidel/dev/DbExtensions/extensions.jar
But when I run the same query, I get this error message:
The class 'com.fidel.extensions.Extensions' does not exist or is
inaccessible.
I'm using Netbean's SQL editor, which I assume would pick up the CLASSPATH I've set.
Has anyone managed to reference code in an external jar, via the CLASSPATH?
ps. I know I can use the UCASE/UPPER methods. But the code above is just an example
pps. I am able to get the query to work by adding the jar to the Driver list, but I don't think that's the correct thing to do.
Services -> Drivers -> Java DB (Embedded) -> Customize -> Add

How to get the name of JMX Jmeter filename in a variable

I want to use the name of the jmeter test script (.jmx) in a listener so as to generate the result file in a dynamic way. Can you please tell me what is the Jmeter variable for that purpose?
Used ${fileName} which didn't work
You can do it via Beanshell scripting like:
GUI mode
import org.apache.jmeter.gui.GuiPackage;
String scriptName = GuiPackage.getInstance().getTestPlanFile();
vars.put("scriptName", scriptName);
non-GUI mode
import org.apache.jmeter.services.FileServer;
String scriptName = FileServer.getFileServer().getScriptName();
vars.put("scriptName", scriptName);
Put the code snippet of your choice into any "Beanshell" test element (sampler, pre/post processor, or assertion), it will get .jmx test script name and store it into ${scriptName} variable.
To learn more about Beanshell scripting in JMeter check out How to use BeanShell: JMeter's favorite built-in component guide.
The variable that holds the test plan name is ${__TestPlanName}
Ref: http://jmeter.apache.org/usermanual/functions.html#__TestPlanName
Below would work irrespective of GUI / Non GUI mode:
import org.apache.jmeter.services.FileServer;
import java.io.File;
String testPlanFile = FileServer.getFileServer().getBaseDir() +
File.separator +
FileServer.getFileServer().getScriptName();
props.put("testPlanFile", testPlanFile);
Use this as ${__P(testPlanFile)} - Adding it as var would not work across all threads. From http://jmeter.apache.org/usermanual/functions.html -
Properties are not the same as variables. Variables are local to a
thread; properties are common to all threads, and need to be
referenced using the __P or __property function.

WSADMIN jacl Scripting - how get property value

in a WSADMIN jacl Script how i can get wsadmin.properties values ?
for example the "com.ibm.ws.scripting.traceFile" ?
i already try with
puts $com.ibm.ws.scripting.traceFile
buts return
can't read "com.ibm.ws.scripting.traceFile": no such variable
while executing
"puts $com.ibm.ws.scripting.traceFile"
The values stored in wsadmin.properties are loaded into the JVM, and are stored as System Properties. You can obtain the values of these properties by working with Java's java.lang.System object, and then retrieving the specific property you want:
Here's the JACL code:
package require java
set sysprops [java::call System getProperties]
set traceFile [[$sysprops get com.ibm.ws.scripting.traceFile] toString]
puts "trace file: $traceFile"
For anyone interested, here's the Jython equivalent:
from java.lang import System as javasystem
sysprops = javasystem.getProperties()
traceFile = sysprops.get('com.ibm.ws.scripting.traceFile')
print "traceFile: " + traceFile