Incorrect:
credentials.put(AttributeNameConstants.WSCREDENTIAL_GROUPS, (List)java.util.Arrays.asList(new String[] {"group1","group2"}));
Correct way to create the group list is:
List list = new ArrayList<>(List.of("a", "b", "c"));"
Thanks to Benjamin Xue (Benjamin.Xue@ibm.com) for finding and testing this.