Wednesday, May 23, 2012

Weblogic 10.3.5: WLST in Embedded Mode

Weblogic 10.3.5: WLST in Embedded Mode

In embedded mode, you instantiate the WLST interpreter in your Java code and use it to run WLST commands and scripts. All WLST commands and variables that you use in interactive and script mode can be run in embedded mode.

This example illustrates how to instantiate the WLST interpreter and use it to connect to a running server, create two servers, and assign them to clusters.

package wlst;
import java.util.*;
import org.python.util.InteractiveInterpreter;

 * Simple embedded WLST example that will connect WLST to a running server,
 * create two servers, and assign them to a newly created cluster and exit.
 * <p>Title:</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: BEA Systems</p>

public class EmbeddedWLST 
  static InteractiveInterpreter interpreter = null;

  EmbeddedWLST() {
    interpreter = new WLSTInterpreter();

private static void connect() {
  String user="user1";
  String pass="pw12ab";
  String url ="t3://localhost:7001";
  Environment env = new Environment();
  Context ctx = env.getInitialContext();

private static void createServers() {
    StringBuffer buf = new StringBuffer();
    buf.append("print ‘Script ran successfully ...’ \n");

private static String startTransaction() {
    StringBuffer buf = new StringBuffer();
    return buf.toString();

private static String endTransaction() {
    StringBuffer buf = new StringBuffer();
    return buf.toString();

  public static void main(String[] args) {
    new EmbeddedWLST();



  1. I get an error saying the CompatabilityMBeanServer is not initialized properly when I try to connect. I am running a JDeveloper Integrated weblogic server. The wlst.cmd script works fine just can connect when running through Java from within an Eclipse project. Any ideas ?

  2. Can you help for a script to export a customization files wiht wlst embedded like your example but for a Customization File.



ForgeRock: Open AM. Install Open AM 5.5 with Tomcat 8.0 - Part 1- Install Tomcat

This BLOG thread discusses on steps to install and configure Open AM 5.5 with Tomcat 8.0. Install Tomcat. You can always find the l...