How to Prevent Starting a WebLogic Domain as ROOT

In a UNIX/Linux environment, if an Admin logged in as Root ever starts your WebLogic domain forgetting to change to the application user first, it can cause serious problems. Ownership of key files is automatically updated to the Root user which makes starting WebLogic as the application user impossible. And to make matters worse, the log shows a cryptic error that could cause you to throw up your hands after wasting hours trying to run down the issue.

java.lang.ClassCastException: com.octetstring.vde.backend.BackendRoot cannot be cast to com.octetstring.vde.backend.standard.BackendStandard

To correct the damage, the Admin as Root has to find and update the permissions of all files that were altered during the mishap.

But, there is a quick solution you can implement to prevent this from happening to your domain in the first place. Take the code snippet displayed below and add it to the beginning of your “startWebLogic.sh” script changing the user ID name and number to match your environment. Once in place only the application user will be able to start WebLogic preventing any future errors by your Admin.

 AUTH_USER=`id | awk '{print($1)}'`  
 if [[ ${AUTH_USER} != "uid=300(weblogic)" ]]; then  
   echo " "  
   echo "***  You are logged in as the wrong user trying to run this script.  ***"  
   echo " "  
   echo "Please login as weblogic. Exiting..."  
   echo " "  
   exit 1  
 fi