我想使用WebSphere Java Administration API将Web Application的类加载器顺序更改为PARENT_LAST。
企业应用程序> MyAppEAR>管理模块> MyApp.war
如何使用ConfigService设置属性。
尝试下面抛出的代码
java.lang.ClassCastException:java.util.ArrayList无法强制转换为javax.management.AttributeList 在com.kony.admin.deployment.websphere.KonyWebsphereDeployer.updateArtifact(KonyWebsphereDeployer.java:1854)
AttributeList clList = (AttributeList) configService.getAttribute (session, appDeplID, "modules");
ConfigServiceHelper.setAttributeValue (clList, "classloaderMode", "PARENT_LAST");
attrList.add (new Attribute ("modules", clList));
谢谢, 库苏马
答案 0 :(得分:0)
以下是解决方案
private void updateArtifactConfig(String appName, DeploymentConfig dc)
throws DeploymentException {
Session session = new Session();
try {
ObjectName[] classLoadersId = configService.resolve(session,
"Deployment=" + appName + "\":ApplicationDeployment:WebModuleDeployment:");
AttributeList attrList = new AttributeList();
AttributeList clList = (AttributeList)configService.getAttribute(session, classLoadersId[0],
"classloader");
ConfigServiceHelper.setAttributeValue(clList, "mode",
"PARENT_LAST");
attrList.add(new Attribute("classloader", clList));
configService.setAttributes(session, classLoadersId[0], attrList);
configService.save(session, true);
} catch (Exception ex) {
LOGGER.error("Not able to update " + appName, ex);
} finally {
try {
configService.discard(session);
} catch (ConfigServiceException csEx) {
LOGGER.error("Not able to discard updateArtifact " + appName + " session", csEx);
} catch (ConnectorException cnEx) {
throw new DeploymentException("Unable to connect to IBM WebSphere Application Server @ "
+ dc.getHostname() + ":" + dc.getPort());
}
}
}