On a virtual machine that I installed Oracle Identity Federation I found that I could not remember what I had set the Weblogic Server (WLS) password to. I needed a way to recover this password so that I would not have to reinstall WLS. This isn’t the first time I have forgotten the password to start and login to WLS … I needed to find a reusable solution that would give me the password quickly. I found Kenneth Xu’s blog (“Program It”) where he defined a solution, in great detail. Kenneth’s solution was geared towards Windows … I needed a solution for Linux (fortunately there were very minor changes required). In other words … I borrowed heavily from: http://kennethxu.blogspot.com/2006/04/how-to-recover-weblogic-admin-password.html
Update (12/15/12): It’s important to note that this recovery process is dependent on the instance having the username and password in a boot.properties file. For those of you that are entering the username and password on the command line at startup time … this probably won’t help you. Also, if you get a Java NPE when running this code … come back to the java that you wrote and check the value of the BPF variable. Make sure that points to an actual boot.properties file that has the weblogic username and password.
Step 1: On the Linux server (I am logged in as Oracle) create a development directory
I created one called: /home/oracle/deve
Step 2: Create a file called: RecoverPassword.java and then copy in the following code
[sourcecode language=”java”]
import weblogic.security.internal.BootProperties;
public class RecoverPassword {
public static void main(String[] args) {
String BPF =
"/opt2/oracle/Middleware/user_projects/domains/IDMDomain/servers/wls_oif1/data/
nodemanager/boot.properties";
BootProperties.load(BPF, false);
BootProperties bootp = BootProperties.getBootProperties();
System.out.println(
"##############################[" + bootp.getOneClient() +
"/" + bootp.getTwoClient() + "]#############################"); } }
[/sourcecode]
Step 3: Compile:
[sourcecode language=”bash”]
javac -classpath /opt2/oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar RecoverPassword.java
[/sourcecode]
Step 4: Copy WLS Startup File to development directory
[sourcecode language=”bash”]
cp /opt2/oracle/Middleware/user_projects/domains/IDMDomain/bin/startWebLogic.sh .
[/sourcecode]
** make sure to include the period at the end of the line. This means copy “here”. The current directory that you are in.
Step 5: Rename to: recoverPassword.sh
Step 6: Edit recoverPassword.sh
[sourcecode language=”java”]
${JAVA_HOME}/bin/java ${JAVA_VM} -version // this is an existing line
### Custom Code inserted to Recover Password ###
CLASSPATH=/home/oracle/deve/:$CLASSPATH; export CLASSPATH
echo $CLASSPATH
SERVER_CLASS=RecoverPassword; export SERVER_CLASS
doExitFlag=false; export doExitFlag
if [ "${WLS_REDIRECT_LOG}" = "" ] ; then // this is en existing line
[/sourcecode]
Step 7: Change to the domain home directory
[sourcecode language=”bash”]
cd /opt2/oracle/Middleware/user_projects/domains/IDMDomain/
[/sourcecode]
Step 8: Run the recoverPassword.sh script
[sourcecode language=”bash”]
/home/oracle/deve/recoverPassword.sh
[/sourcecode]
Output will look like:
[sourcecode language=”bash”]
ware/Oracle_IDM1 -Xms512m -Xmx1024m -Xss512K -Djava.net.preferIPv6Addresses=true -DuseIPv6Address=true -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.management.discover=false -Djava.net.preferIPv6Addresses=true -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/opt2/oracle/Middleware/patch_wls1032/profiles/default/sysext_manifest_classpath
RecoverPassword
##############################[weblogic/Passw0rd1]#############################
[/sourcecode]
The password is displayed on the line with the hashmarks.