EMCLI is not certified or supported on Mac OS X, but I wondered if it is possible to run on my new macbook. I searched metalink, googled and couldn’t found any useful information. I thought it should be easy because EMCLI is a java application certified to run almost all enterprise operating systems including HP-UX, AIX, Linux, Windows, Solaris, and we all remember “write once, run everywhere” slogan of Java. Unfortunately it wasn’t as easy as I expected
I have downloaded emclikit.jar from my Enterprise Manager web console, and tried to install it. Here’s the output:
gokhanatil$ java -jar emclikit.jar -installdir=emcli Oracle Enterprise Manager 12c Release 4. Copyright (c) 2012, 2014 Oracle Corporation. All rights reserved. Exception in thread "main" java.lang.UnsupportedOperationException at oracle.sysman.emSDK.emCLI.Utility.getFiles(Utility.java:640) at oracle.sysman.emCLI.CLICSInstaller.installClientSide(CLICSInstaller.java:35) at oracle.sysman.emCLI.CLICSInstaller.installClientSide(CLICSInstaller.java:28) at oracle.sysman.emCLI.CLICSInstaller.main(CLICSInstaller.java:21) Problem while installing.
UnsupportedOperationException? What kind of unsupported operation could it be? For a Java application which its primary duty is to communicate with a web service, this error was surprising for me.
As you can see from the error stack, the exception was thrown in getFiles method. So I though there could be something about permissions of the files, or maybe something about how java access to folders. After some hours of debugging, I found that this exception was thrown intentionally when the emcli installer detects an unsupported operating system. So we hit an artificial barrier which is put there by the developer.
Is it possible to tell emcli installer that we use a supported OS (ie Solaris)? Not always, but most Java developers uses system property called “os.name” to detect the operating system, and our emcli developer also uses this method. We can add “-Dos.name=Solaris” parameter to fake the installer:
gokhanatil$ java -Dos.name=Solaris -jar emclikit.jar -install_dir=emcli2 Oracle Enterprise Manager 12c Release 4. Copyright (c) 2012, 2014 Oracle Corporation. All rights reserved. Exception in thread "main" java.lang.UnsupportedOperationException at oracle.sysman.emSDK.emCLI.Utility.getFiles(Utility.java:640) at oracle.sysman.emCLI.CLICSInstaller.installClientSide(CLICSInstaller.java:35) at oracle.sysman.emCLI.CLICSInstaller.installClientSide(CLICSInstaller.java:28) at oracle.sysman.emCLI.CLICSInstaller.main(CLICSInstaller.java:21) Problem while installing.
I like these kind of challenges It didn’t work because the jar file, calls another jaf file so our parameter doesn’t affect to the method. We need to change os.name permanently for our terminal session. The JAVA_TOOL_OPTIONS environment variable helps us to do it:
gokhanatil$ export JAVA_TOOL_OPTIONS=-Dos.name=Solaris gokhanatil$ java -jar emclikit.jar -install_dir=emcli Picked up JAVA_TOOL_OPTIONS: -Dos.name=Solaris Oracle Enterprise Manager 12c Release 4. Copyright (c) 2012, 2014 Oracle Corporation. All rights reserved. Picked up JAVA_TOOL_OPTIONS: -Dos.name=Solaris EM CLI client-side install completed successfully. Execute "emcli help setup" from the EM CLI home (the directory where you have installed EM CLI) for further instructions.
Hurray! We beat the detection. Have you noticed that two “Picked up JAVA_TOOLS_OPTIONS”? This is why the parameter “-Dos.name=Solaris” didn’t work. Anyway, because we have successfully installed the emcli, let’s run it:
gokhanatil$ ./emcli Cannot find a java program of version "1.6" or greater. Set the JAVA_HOME environment variable to a java "1.6" or greater home.
I use Java 1.8.x, so why does it say that it requires version 1.6 or greater? After examining the emcli script, I see that the developer finds the java version by running “java -version” and parsing the output. Unfortunately our output has an extra line:
gokhanatil$ java -version Picked up JAVA_TOOL_OPTIONS: -Dos.name=Solaris java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
The JAVA_TOOL_OPTIONS variable already served us well. We have installed the emcli, so I unset that variable, and include “-Dos.name=Solaris” into emcli script itself. Search for exec “$JAVA_PROGRAM” line in the file. You’ll find two. One for windows, one for Unix. You can easily understand it by reading the comment lines. Then add “-Dos.name=Solaris” after -DoracleHome=”$OracleHome”:
else # on unix # overriding the System property "user.name" is not needed on unix though # this would work for all unix-like platforms: # EMCLI_USER=`id -un 2>/dev/null` # (for now, exact legacy behavior is maintained by not specifying user.name) # exec "$JAVA_PROGRAM" -Demcli.dir="$EMCLI_DIR" -DoracleHome="$OracleHome" \ -Dos.name=Solaris -Djava.class.path="$EMCLI_CLASSPATH" \ -Demcli.state.dir="$EMCLI_STATE_DIR" -Xmx512m $EMCLI_OPTS -jar "$EMCLI_JAR" "$@" fi
After this change, I have successfully issued the following commands:
gokhanatil$ ./emcli setup -url="https://...:7802/em" -username=GOKHAN -trustall Oracle Enterprise Manager 12c Release 4. Copyright (c) 1996, 2014 Oracle Corporation and/or its affiliates. All rights reserved. Enter password Emcli setup successful gokhanatil$ ./emcli sync Synchronized successfully
Everything looks OK! I haven’t tested all EMCLI verbs but for now it seems it works successfully. I also installed emcliadvancedkit (the one supporting Jpython scripting) with same method. Let me know if you encounter any problems. Of course, this is an unsupported and non-certified installation and you shouldn’t rely on it, and use it on production systems. You may wonder why we set the operating system variable to Solaris. There’s no reason. First I tried to install as setting os.name=Linux, spend some hours without success until I discovered JAVA_TOOL_OPTIONS variable, then I did set “os.name=Solaris”, and kept it as it is.