users@glassfish.java.net

AMX: Programmatically add server-instance to a Cluster

From: <glassfish_at_javadesktop.org>
Date: Thu, 20 May 2010 02:36:00 PDT

Hi,

I'm trying to add a server-instance in a cluster using the AMX API. Here is my code:

[...]
 conf.createClusteredServerConfig("instance-3", "cluster1", "cluster1-nodeagent", options);
[...]

options is an HashMap<String,String> used to setup the server's ports

When I try to run the code this is what i get:

java.io.NotSerializableException: javaapplication3.Main
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
        at java.rmi.MarshalledObject.<init>(MarshalledObject.java:101)
        at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:990)
        at com.sun.appserv.management.client.handler.AMXProxyHandler.invokeTarget(AMXProxyHandler.java:464)
        at com.sun.appserv.management.client.handler.AMXProxyHandler.invokeProxyCreator(AMXProxyHandler.java:584)
        at com.sun.appserv.management.client.handler.AMXProxyHandler._invoke(AMXProxyHandler.java:1109)
        at com.sun.appserv.management.client.handler.AMXProxyHandler.invoke(AMXProxyHandler.java:1024)
        at $Proxy1.createClusteredServerConfig(Unknown Source)
        at javaapplication3.Main.<init>(Main.java:86)
        at javaapplication3.Main.main(Main.java:334)


When I execute the code with optinons=null (is an optional parameter) happen the following:

java.lang.Exception: Using 38.082 for HTTP_LISTENER_PORT.
Using 38.183 for HTTP_SSL_LISTENER_PORT.
Using 33.822 for IIOP_SSL_LISTENER_PORT.
Using 37.680 for JMS_PROVIDER_PORT.
Using 33.702 for IIOP_LISTENER_PORT.
Using 38.688 for JMX_SYSTEM_CONNECTOR_PORT.
Using 33.922 for IIOP_SSL_MUTUALAUTH_PORT.
        at com.sun.enterprise.ee.admin.configbeans.ServersConfigBean.createServerInstance(ServersConfigBean.java:894)
        at com.sun.enterprise.ee.admin.mbeans.ServersConfigMBean.createServerInstance(ServersConfigMBean.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:390)
        at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:373)
        at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:477)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
        at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
        at $Proxy1.invoke(Unknown Source)
        at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)
        at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:170)
        at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
        at $Proxy14.createServerInstance(Unknown Source)
        at com.sun.enterprise.management.config.StandaloneServerConfigFactory.create(StandaloneServerConfigFactory.java:104)
        at com.sun.enterprise.management.config.ClusteredServerConfigFactory.create(ClusteredServerConfigFactory.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.enterprise.management.config.AMXConfigImplBase.createConfig(AMXConfigImplBase.java:769)
        at com.sun.enterprise.management.config.AMXConfigImplBase.invokeManually(AMXConfigImplBase.java:987)
        at com.sun.enterprise.management.support.AMXImplBase.invoke(AMXImplBase.java:1788)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
        at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:174)
        at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1427)
        at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
        at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265)
        at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360)
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
        at sun.rmi.transport.Transport$1.run(Transport.java:159)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

Do someone know how to resolve this prolem or know how to add instance of glassfish in a cluster?

Thanks and sorry for my English
[Message sent by forum member 'emanuele84']

http://forums.java.net/jive/thread.jspa?messageID=470644