我使用此代码使用Java和JMX关闭WebLogic:
<body ng-app="myApp" ng-controller="myCtrl">
<form>
<input type="text" ng-model="<?php echo $product->id ?>" name="prid" />
<input type="submit" value="Add to Cart" ng-click="yea()"/>
</form>
</body>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.yea = function() {
$scope.$watch('xxx', function(){
var test = angular.copy($scope.xxx);
alert(test);
})
};
});
</script>
但是当我执行代码时,我得到了这个例外:
MBeanServerConnection connection;
JMXConnector connector;
ObjectName service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");
String hostname = "21.231.70.123";
int port = 7001;
String username = "test";
String password = "4r3";
String protocol = "t3";
String jndiroot = "/jndi/";
String mserver = "weblogic.management.mbeanservers.domainruntime";
JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiroot + mserver);
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, username);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
connector = JMXConnectorFactory.connect(serviceURL, h);
connection = connector.getMBeanServerConnection();
ObjectName[] serverRT = (ObjectName[]) connection.getAttribute(service, "ServerRuntimes");
for (int i = 0; i < serverRT.length; i++)
{
String name = (String) connection.getAttribute(serverRT[i], "Name");
// if (!name.equals("AdminServer"))
// {
System.out.println("Server Name : " + name + " shutting down");
Object obj = connection.invoke(serverRT[i], "forceShutdown", null, null);
System.out.println("Server Name : " + name + " down now.");
// }
}
connector.close();
你能给我一些建议我能解决这个问题吗?
这个问题有替代解决方案吗?