users@glassfish.java.net

JMX with GF 3 leads to iiop.login_exception

From: <forums_at_java.net>
Date: Tue, 13 Dec 2011 02:31:29 -0600 (CST)

In our integration test suite we have one test which works perfectly well
with Glassfish 2, but "kills" Glassfish 3.1.1. After this test is executed
every remote call to the server facade leads to this strange exception:

[#|2011-12-12T14:31:24.941+0100|SEVERE|glassfish3.1.1|javax.enterprise.system.core.security.com.sun.enterprise.iiop.security|_ThreadID=24;_ThreadName=Thread-2;|iiop.login_exception|#]

If we restart Glassfish everything is fine again.

The following itself is executed sucessfully, but afterwards nothing is
working... Any ideas how that comes? Should I open a bug?

package de.xyz.testapp.integrationtest.monitoring;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
public class MonitoringTest {
  /** The MBeanServerConnection */
  private static MBeanServerConnection mbsc;
  /** Name with which the BusinessApplicationManagerMBean is registered at
the MBeanServer */
  private static final String BAM_NAME =
"ASEP-System:type=BusinessApplicationManager";
  /** Name of the MBean's attribute that contains informations about the
applications */
  private static final String APP_INFO = "ApplicationInformations";
  /** One-time setup: connect to the MBeanServer */
  @BeforeClass
  public static void connect() {
    Map<String, String[]> environment = new HashMap<String, String[]>();
    environment.put(JMXConnector.CREDENTIALS, new String[] { "admin",
"adminadmin" });
    try {
      JMXServiceURL url = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi");
      JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);
      mbsc = jmxc.getMBeanServerConnection();
    } catch (IOException e) {
      fail("Exception occurred during conntection to the MBeanServer: "
+ e.getMessage());
    }
  }
  /**
   * Check if the method
BusinessApplicationManagerMBean.getApplicationInformations at least
   * contains the application Testapp (must be deployed correctly when
running tests).
   */
  @Test
  public void checkGetApplicationInfos() {
    Object attr = null;
    try {
      ObjectName object = new ObjectName(BAM_NAME);
      attr = mbsc.getAttribute(object, APP_INFO);
    } catch (Exception e) {
      fail("An exception occurred while receiving the informations from
the MBeanServer: "
          + e.getMessage());
    }
    if (attr instanceof String[]) {
      List<String> applicationInfos = Arrays.asList((String[]) attr);
      List<String> applicationNames = new ArrayList<String>();
      for (String appInfo : applicationInfos) {
        appInfo = appInfo.substring(0, appInfo.indexOf(","));
        applicationNames.add(appInfo);
      }
      assertTrue(
          "The application Testapp should be returned as registered
at the BusinessApplicationManager by the MBean.",
          applicationNames.contains("Testapp"));
    } else {
      fail("The Object returned by the MBean is not of type String[]: "
+ attr.getClass());
    }
  }
}
 


--
[Message sent by forum member 'ztangm']
View Post: http://forums.java.net/node/873583