Index: admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/CreateDomainCommand.java =================================================================== --- admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/CreateDomainCommand.java (revision 52667) +++ admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/CreateDomainCommand.java (working copy) @@ -72,6 +72,11 @@ import com.sun.appserv.management.client.prefs.LoginInfoStoreFactory; import com.sun.logging.*; import static com.sun.enterprise.config.util.PortConstants.*; +import java.beans.PropertyVetoException; +import org.jvnet.hk2.config.ConfigBeanProxy; +import org.jvnet.hk2.config.ConfigCode; +import org.jvnet.hk2.config.ConfigSupport; +import org.jvnet.hk2.config.TransactionFailure; /** * This is a local command that creates a domain. @@ -787,6 +792,8 @@ Properties properties = new Properties(); properties.setProperty(StartupContext.STARTUP_MODULESTARTUP_NAME, "DomainCreation"); + properties.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY, + domainDir.getAbsolutePath()); properties.setProperty("-domain", domainConfig.getDomainName()); Server server = builder.build(properties); @@ -821,7 +828,19 @@ logger.info(strings.get("InvokeInitializer", inhabitant.getClass())); Container newContainerConfig = inhabitant.getInitialConfig(ctx); - config.getContainers().add(newContainerConfig); + try { + ConfigSupport.apply((new ConfigCode() { + @Override + @SuppressWarnings("unchecked") + public Object run(ConfigBeanProxy... objects) throws PropertyVetoException, TransactionFailure { + ((Config)objects[0]).getContainers().add((Container)objects[1]); + return Boolean.TRUE; + } + }), new ConfigBeanProxy[] { config, newContainerConfig }); + } catch(TransactionFailure e) { + logger.severe(strings.get("InitializerTransactionFailure", + inhabitant.getClass())); + } } server.stop(); }