Как изменить порядок загрузчика классов на родительский последний в ManageModules, используя IBM JAVA API? - PullRequest
0 голосов
/ 06 июня 2018

Я хочу изменить порядок загрузчика классов веб-приложения на PARENT_LAST с помощью WebSphere Java Administration API.

Корпоративные приложения> 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)); 

Спасибо, Кусума

1 Ответ

0 голосов
/ 08 июня 2018

Ниже приведено решение

  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());
  }
}

}

...