weblogicサーバにアプリケーション(EAR/WAR/JAR)をデプロイするオプションを探しています。このスクリプトはJavaメインクラスで実行されます。weblogicサーバスクリプトを使用してアプリケーションをプログラマティックにデプロイする
private static final String wlUsername = "'weblogic'";
private static final String wlPassword = "'welcome1'";
private static void connect() {
StringBuffer buffer = new StringBuffer();
buffer.append("connect(");
buffer.append(wlUsername);
buffer.append(",");
buffer.append(wlPassword);
buffer.append(")");
log.debug("connect: "+buffer.toString());
interpreter.exec(buffer.toString());
}
private static void createServers() {
StringBuffer buf = new StringBuffer();
buf.append(startTransaction());
buf.append("man1=create('msEmbedded1','Server')\n");
buf.append("man2=create('msEmbedded2','Server')\n");
buf.append("clus=create('clusterEmbedded','Cluster')\n");
buf.append("man1.setListenPort(8001)\n");
buf.append("man2.setListenPort(9001)\n");
buf.append("man1.setCluster(clus)\n");
buf.append("man2.setCluster(clus)\n");
buf.append(endTransaction());
buf.append("print ‘Script ran successfully ...’ \n");
interpreter.exec(buf.toString());
}
private static String startTransaction() {
StringBuffer buf = new StringBuffer();
buf.append("edit()\n");
buf.append("startEdit()\n");
return buf.toString();
}
private static String endTransaction() {
StringBuffer buf = new StringBuffer();
buf.append("save()\n");
buf.append("activate(block='true')\n");
//buf.append("dumpStack()");
return buf.toString();
}
public static void main(String[] args) {
connect();
enableMbeanServer();
createServers();
}
private static void enableMbeanServer(){
StringBuffer buf = new StringBuffer();
buf.append(startTransaction());
buf.append("set('CompatibilityMBeanServerEnabled', 'true')");
buf.append(endTransaction());
buf.append("shutdown()");
connect();
buf.append("print ‘CompatabilityMBeanServer enabled successfully ...’ \n");
interpreter.exec(buf.toString());
}
しかし、以下の例外を除いて終わる:
20:41:59.927 DEBUG [main][com.fedex.interfaces.wls.WLSTRunner] connect: connect('weblogic','welcome1')
Connecting to t3://localhost:7001 with userid weblogic ...
The CompatabilityMBeanServer is not initialized properly.
This might happen if the CompatabilityMBeanServer is
disabled via the JMXMBean.
To view the root cause exception use dumpStack()
WLST detected that the RuntimeMBeanServer is not enabled. This
might happen if the RuntimeMBeanServer is disabled via the JMXMBean.
Please ensure that this MBeanServer is enabled. Online WLST cannot
function without this MBeanServer.
Exception in thread "main" Traceback (innermost last):
File "<string>", line 1, in ?
File "<iostream>", line 22, in connect
File "<iostream>", line 648, in raiseWLSTException
WLSTException: Error occured while performing connect : "Cannot connect to WLST."
Use dumpStack() to view the full stacktrace
任意の提案やデプロイ/アンデプロイタスクを起動する方法任意のアイデア
私は次のようにJavaのを通じて同じことを達成しようとしていますJavaから?
**タスクを実行するには、** wldeploy **タスクを使用します。そして、* java *を使ってantタスクを実行することもできます。 – Sanjeev
@Sanjeev ANTを使用して、条件に基づいてサーバーを起動および停止し、展開する例 – Rembo
別のアプローチは、WLSTスクリプトを使用することです。 – devwebcl