Hi there,
I'm trying to get an external JMX client to connect to a SAP Web AS ABAP+Java 640 (Unicode, SP 9).
My first problem was that I couldn't find the file client.jar as written in "Compile and Run your Client" of the JMX Service Interface documentation. I could solve the "class not found" problems by using sapj2eeclient.jar, so I thing the file has just been renamed.
I then tried to run the following code, which has been taken more or less from the "Connecting to an MBeanServer" example.
import java.util.Properties; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.naming.Context; import com.sap.jmx.ObjectNameFactory; import com.sap.jmx.remote.JmxConnectionFactory; public class Client { public Client( ) { } private void run( ) { try { Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl"); props.setProperty(Context.SECURITY_PRINCIPAL, "J2EE_ADMIN"); props.setProperty(Context.SECURITY_CREDENTIALS, "password"); props.setProperty(Context.PROVIDER_URL, "my-server:50004"); MBeanServerConnection mbsc = null; mbsc = JmxConnectionFactory.getMBeanServerConnection( JmxConnectionFactory.PROTOCOL_ENGINE_P4, props); String path = "Root/Services/Memory/AllocatedMemory"; ObjectName name = null; name = ObjectNameFactory.getNameForMonitorPerNode( ObjectName.quote(path), null, null); System.out.println("ObjectName: " + name.getCanonicalName()); Integer value = (Integer)mbsc.invoke(name, "getValue", null, null); System.out.println("Value: " + value); } catch(Exception ex) { ex.printStackTrace(); } } public static void main( String[] args ) { new Client().run(); } }
Unfortunately, I get the following error:
com.sap.engine.services.jmx.exception.JmxConnectorException: Unable to connect to connector server. at com.sap.engine.services.jmx.connector.p4.P4ConnectorClient.<init>(P4ConnectorClient.java:96) at com.sap.engine.services.jmx.connector.p4.ConnectorFactory.getJmxConnector(ConnectorFactory.java:31) at com.sap.jmx.remote.JmxConnectionFactory.getConnector(JmxConnectionFactory.java:191) at com.sap.jmx.remote.JmxConnectionFactory.getMBeanServerConnection(JmxConnectionFactory.java:92) at Client.run(Client.java:29) at Client.main(Client.java:51) Caused by: com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception while trying to get InitialContext. [Root exception is com.sap.engine.services.security.exceptions.BaseLoginException: Cannot create new RemoteLoginContext instance.] at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:538) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.init(InitialContext.java:219) at javax.naming.InitialContext.<init>(InitialContext.java:195) at com.sap.engine.services.jmx.connector.p4.P4ConnectorClient.<init>(P4ConnectorClient.java:69) ... 5 more Caused by: com.sap.engine.services.security.exceptions.BaseLoginException: Cannot create new RemoteLoginContext instance. at com.sap.engine.services.security.remote.login.RemoteLoginContext.<init>(RemoteLoginContext.java:98) at com.sap.engine.services.jndi.implclient.LoginHelper.clientSideLogin(LoginHelper.java:78) at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:402) ... 10 more Caused by: java.lang.NullPointerException at com.sap.engine.services.security.remote.RemoteSecurity_Stub.getRemoteLoginContext(RemoteSecurity_Stub.java:678) at com.sap.engine.services.security.remote.login.RemoteLoginContext.<init>(RemoteLoginContext.java:93) ... 12 more
Am I doing something wrong? Any help or hint would be greatly appreciated.
Regards, Bernd