In previous blogs, I already talked about how to fix issues with the D2 Privileged Client utility (for 16.4.0, 16.5.0 and 16.5.1) as well as how to execute/use this utility for automatic/silent registration & approval of DFC Client IDs. I’m now back to this topic because I had the opportunity recently to work with D2-REST 16.7.1 so I took some time to compare the 16.7.0, 16.7.1 and the newly released 20.2 versions as well of this utility. As you can expect by reading this blog, it’s not error free, otherwise I wouldn’t be writing something.

In the previous blog, I mentioned five different issues with the utility: no shebang, incorrect first line, log4j configuration using a hardcoded Windows path, DOS format for the shell script and finally the unavailability of secure communication support. The first bad news is that despite my SR opened with the OpenText Support a year ago, and their bugs opened internally, the first four issues haven’t been fixed until the 20.2 version (here I’m only talking about D2-REST which usually doesn’t receive a lot of update/patch, if any at all). All the versions of the D2-REST war files available on the OpenText site except 20.2 do not include an updated version of the shell script. It would be so easy to fix all these 4 issues but nobody is taking the time to, apparently. On the other hand, the non-support of the secure communication has fortunately been fixed on the 16.7.1 version. So starting with this one, you can now use the D2 Privileged Client utility without having to first switch your client dfc.properties to use native communication, you can just run it even with secure channels. That’s the status about the issues I discussed in my previous blog already but there is more and that’s the main goal of this blog!

Starting with 16.7.0, OpenText apparently added a second jar file in the same folder with the Java source of the D2 Privileged Client utility. Which is fine, right? Well in principle yes, that’s good because we can actually see what is done and how it’s done using the source code… But this second jar file actually cause a new issue! After fixing the first issues discussed earlier and trying to run the utility:

[weblogic@wsd2rest-0 ~]$ cd $APPLICATIONS
[weblogic@wsd2rest-0 applications]$ 
[weblogic@wsd2rest-0 applications]$ ls -l
total 4
drwxr-x---. 8 weblogic weblogic 4096 Mar 22 08:38 D2-REST
[weblogic@wsd2rest-0 applications]$ 
[weblogic@wsd2rest-0 applications]$ cd D2-REST/utils/d2privilegedclient/
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ls -l
total 44
-rw-r-----. 1 weblogic weblogic 18469 Mar 22 08:39 D2PrivilegedClientUtil-16.7.1.jar
-rw-r-----. 1 weblogic weblogic  9431 Mar 22 08:39 D2PrivilegedClientUtil-16.7.1-sources.jar
-rw-r-----. 1 weblogic weblogic  1214 Mar 22 08:39 D2PrivilegedClientUtil.cmd
-rwx------. 1 weblogic weblogic  1119 Mar 22 09:11 D2PrivilegedClientUtil.sh
-rw-r-----. 1 weblogic weblogic  1141 Mar 22 09:11 D2PrivilegedClientUtil.sh.orig
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ./D2PrivilegedClientUtil.sh -d ${gr} -u ${user} -p ${pw}
Running D2PrivilegedClientUtil
Error: Could not find or load main class com.opentext.d2.util.D2PrivilegedClientUtil
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ cat D2PrivilegedClientUtil.sh
#!/bin/bash

# Run this script with no arguments to get command line usage

# Specify location of WEB-INF folder
webinfdir=../../WEB-INF

echo "Running D2PrivilegedClientUtil"

# The following will suppress DFC warnings about non-existing log4j configuration
# if the specified log4j.properties file actually exists ... adjust as desired.
log4j_configuration=${webinfdir}/classes/log4j.properties

# Note: In order to run this utility on a Developer system, the following jar files must
# be copied from the corresponding DocumentumCoreProject/dfs*/dfs-sdk*/lib/java/utils
# folder to WEB-INF/lib:
#
#   aspectjrt.jar
#   log4j.jar

osname=`uname`
key=`expr substr $osname 1 6`
if [ `expr match "$key" "CYGWIN"` != "6" ]
then
   # Linux
    utiljar=`find D2PrivilegedClientUtil*.jar`
    classpath="${utiljar}:${webinfdir}/classes/:${webinfdir}/lib/*"
else
   # Cygwin
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar`
    classpath="${utiljar};${webinfdir}/classes/;${webinfdir}/lib/*"
fi

java -Dlog4j.configuration="${log4j_configuration}" -cp "${classpath}" com.opentext.d2.util.D2PrivilegedClientUtil $*
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ sed -i 's,^java ,echo "------"necho "The Classpath is set to >>>>${classpath}<<<<"necho "------"nn&,' D2PrivilegedClientUtil.sh
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ cat D2PrivilegedClientUtil.sh
#!/bin/bash

# Run this script with no arguments to get command line usage

# Specify location of WEB-INF folder
webinfdir=../../WEB-INF

echo "Running D2PrivilegedClientUtil"

# The following will suppress DFC warnings about non-existing log4j configuration
# if the specified log4j.properties file actually exists ... adjust as desired.
log4j_configuration=${webinfdir}/classes/log4j.properties

# Note: In order to run this utility on a Developer system, the following jar files must
# be copied from the corresponding DocumentumCoreProject/dfs*/dfs-sdk*/lib/java/utils
# folder to WEB-INF/lib:
#
#   aspectjrt.jar
#   log4j.jar

osname=`uname`
key=`expr substr $osname 1 6`
if [ `expr match "$key" "CYGWIN"` != "6" ]
then
   # Linux
    utiljar=`find D2PrivilegedClientUtil*.jar`
    classpath="${utiljar}:${webinfdir}/classes/:${webinfdir}/lib/*"
else
   # Cygwin
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar`
    classpath="${utiljar};${webinfdir}/classes/;${webinfdir}/lib/*"
fi

echo "------"
echo "The Classpath is set to >>>>${classpath}<<<<"
echo "------"

java -Dlog4j.configuration="${log4j_configuration}" -cp "${classpath}" com.opentext.d2.util.D2PrivilegedClientUtil $*
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ./D2PrivilegedClientUtil.sh -d ${gr} -u ${user} -p ${pw}
Running D2PrivilegedClientUtil
------
The Classpath is set to >>>>D2PrivilegedClientUtil-16.7.1.jar
D2PrivilegedClientUtil-16.7.1-sources.jar:../../WEB-INF/classes/:../../WEB-INF/lib/*<<<<
------
Error: Could not find or load main class com.opentext.d2.util.D2PrivilegedClientUtil
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$

 

As you can see above, the environment variable “${classpath}” is actually over 2 lines… This breaks the java command that is supposed to execute the utility since it cannot find the correct class file in the classpath. I opened another SR with the OpenText Support (SR#4480014) for this new issue and to explain them what is the issue and how to solve it. While writing this blog, the ticket is still under investigation on OpenText side and I have no estimate on when it will be fixed exactly but don’t expect it before at least 20.3 or maybe even 20.4 for D2-REST since 20.3 is approaching fast… For D2, it might be introduced in a patch for the 20.2 already, let’s see.

Anyway, until then and to fix the utility, it’s really simple: either you just rename the source jar file so it doesn’t get included in the classpath (simplest) or you update the command that fetch the jar files to automatically set the classpath:

[weblogic@wsd2rest-0 d2privilegedclient]$ ### First solution: rename the source jar file:
[weblogic@wsd2rest-0 d2privilegedclient]$ mv D2PrivilegedClientUtil-16.7.1-sources.jar bck_D2PrivilegedClientUtil-16.7.1-sources.jar
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ./D2PrivilegedClientUtil.sh -d ${gr} -u ${user} -p ${pw}
Running D2PrivilegedClientUtil
------
The Classpath is set to >>>>D2PrivilegedClientUtil-16.7.1.jar:../../WEB-INF/classes/:../../WEB-INF/lib/*<<<<
------
2020-03-22 09:25:52,701 UTC [INFO ] (main) - c.e.x.r.c.d.dao.impl.PrivilegeClientDaoImpl   : Checking dm_client_rights for dfc: dfc_Il39fcV3grqLj46AqOXV6ChBaEWk
D2-REST_wsd2rest-0_hBaEWk
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ mv bck_D2PrivilegedClientUtil-16.7.1-sources.jar D2PrivilegedClientUtil-16.7.1-sources.jar
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ### Second solution: change the classpath (1st possibility)
[weblogic@wsd2rest-0 d2privilegedclient]$ grep "utiljar=" D2PrivilegedClientUtil.sh
    utiljar=`find D2PrivilegedClientUtil*.jar`
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar`
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ sed -i 's,(utiljar=.*D2PrivilegedClientUtil.*jar),1 | grep -v sources,' D2PrivilegedClientUtil.sh
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ grep "utiljar=" D2PrivilegedClientUtil.sh
    utiljar=`find D2PrivilegedClientUtil*.jar | grep -v sources`
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar | grep -v sources`
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ./D2PrivilegedClientUtil.sh -d ${gr} -u ${user} -p ${pw}
Running D2PrivilegedClientUtil
------
The Classpath is set to >>>>D2PrivilegedClientUtil-16.7.1.jar:../../WEB-INF/classes/:../../WEB-INF/lib/*<<<<
------
2020-03-22 09:28:12,043 UTC [INFO ] (main) - c.e.x.r.c.d.dao.impl.PrivilegeClientDaoImpl   : Checking dm_client_rights for dfc: dfc_Il39fcV3grqLj46AqOXV6ChBaEWk
D2-REST_wsd2rest-0_hBaEWk
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ sed -i 's,(utiljar=.*D2PrivilegedClientUtil.*jar).*sources,1,' D2PrivilegedClientUtil.sh
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ### Second solution: change the classpath (2nd possibility)
[weblogic@wsd2rest-0 d2privilegedclient]$ grep "utiljar=" D2PrivilegedClientUtil.sh
    utiljar=`find D2PrivilegedClientUtil*.jar`
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar`
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ sed -i 's,(utiljar=.*D2PrivilegedClientUtil.*jar),1 | xargs | sed "s@ @:@",' D2PrivilegedClientUtil.sh
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ grep "utiljar=" D2PrivilegedClientUtil.sh
    utiljar=`find D2PrivilegedClientUtil*.jar | xargs | sed "s@ @:@"`
    utiljar=`/usr/bin/find.exe D2PrivilegedClientUtil*.jar | xargs | sed "s@ @:@"`
[weblogic@wsd2rest-0 d2privilegedclient]$ 
[weblogic@wsd2rest-0 d2privilegedclient]$ ./D2PrivilegedClientUtil.sh -d ${gr} -u ${user} -p ${pw}
Running D2PrivilegedClientUtil
------
The Classpath is set to >>>>D2PrivilegedClientUtil-16.7.1.jar:D2PrivilegedClientUtil-16.7.1-sources.jar:../../WEB-INF/classes/:../../WEB-INF/lib/*<<<<
------
2020-03-22 09:30:08,477 UTC [INFO ] (main) - c.e.x.r.c.d.dao.impl.PrivilegeClientDaoImpl   : Checking dm_client_rights for dfc: dfc_Il39fcV3grqLj46AqOXV6ChBaEWk
D2-REST_wsd2rest-0_hBaEWk
[weblogic@wsd2rest-0 d2privilegedclient]$

 

There are plenty of ways to have this fixed depending on the distribution you are running on. I haven’t tested on cygwin because, honestly, who in 2020 is using cygwin? The simplest and most portable way to avoid the issue is obviously the first one (renaming the source jar file) because it doesn’t change the content of the shell script. Therefore, I would personally go with this one until OpenText fix the product.