You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by anair <as...@yahoo.com> on 2013/03/21 23:44:13 UTC

Start/Stop Karaf 2.3.x via JMX

Hello,

I have a requirement where we are required to control Karaf from outside the
container, like start/stop bundles, uninstall/install features or bundles. I
was able to do it via JMX using:
serverConn.invoke(new
ObjectName("org.apache.karaf:type=features,name=root"), installFeature, new
Object[] { <feature-name> }, new String[] { "java.lang.String" });

However, I could not find any command to start or stop the Karaf container
from outside via JMX. Is it possible to do this? 

Any pointers/link to example will be greatly appreciated.

thanks,

Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Start/Stop Karaf 2.3.x via JMX

Posted by Christian Schneider <ch...@die-schneider.net>.
Starting the container is of course not possible directly as the mbean 
server is only started when karaf is started.
What you can do though is start a master instannce of karaf and use the 
admin/instance mbean to start and stop
child instances.

Christian


Am 21.03.2013 23:44, schrieb anair:
> Hello,
>
> I have a requirement where we are required to control Karaf from outside the
> container, like start/stop bundles, uninstall/install features or bundles. I
> was able to do it via JMX using:
> serverConn.invoke(new
> ObjectName("org.apache.karaf:type=features,name=root"), installFeature, new
> Object[] { <feature-name> }, new String[] { "java.lang.String" });
>
> However, I could not find any command to start or stop the Karaf container
> from outside via JMX. Is it possible to do this?
>
> Any pointers/link to example will be greatly appreciated.
>
> thanks,
>
> Asha
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Start/Stop Karaf 2.3.x via JMX

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Asha,

no argument for the shutdown() operation, so you can directly invoke the 
operation.

Regards
JB

On 03/22/2013 12:27 AM, anair wrote:
> Thanks Jean-Baptiste for the quick response. Are you aware of any
> samples/test that use it via MBeanServerConnection. I tried a few things,
> but none worked. Does it need any arguments passed to shutdown the
> container?
>
> thanks again,
>
> Asha
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274p4028278.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Start/Stop Karaf 2.2.9 via JMX

Posted by anair <as...@yahoo.com>.
Never mind, thanks.



--
View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274p4028282.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Start/Stop Karaf 2.2.9 via JMX

Posted by anair <as...@yahoo.com>.
I tried to shutdown the container, but I got the following exception. Is
there some settings I need to modify to let JMX shutdown the container. I
used the shutdown command in "org.apache.karaf:type=system,name=root" to
shutdown Karaf 2.2.9.

Caused by: java.lang.SecurityException: Start/Stop of bundle not allowed
	at
com.ge.dsp.core.spi.impl.BundleLevelSecurity.checkAdminPermission(BundleLevelSecurity.java:87)
	at
com.ge.dsp.core.spi.impl.BundleLevelSecurity.checkPermission(BundleLevelSecurity.java:53)
	at org.apache.felix.framework.Felix.stop(Felix.java:871)
	at
org.apache.karaf.management.mbeans.system.internal.SystemMBeanImpl.shutdown(SystemMBeanImpl.java:37)
	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.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
	at
com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
	at
com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
	at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
	at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
	at javax.management.StandardMBean.invoke(StandardMBean.java:391)
	at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
	at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1454)
	at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:74)
	at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1295)
	at java.security.AccessController.doPrivileged(Native Method)
	at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1394)
	at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:818)



--
View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274p4028281.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Start/Stop Karaf 2.3.x via JMX

Posted by anair <as...@yahoo.com>.
Thanks, I found a test program at
http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/SystemShutdownTest.java?view=markup&pathrev=1397165
.

- Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274p4028280.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Start/Stop Karaf 2.3.x via JMX

Posted by anair <as...@yahoo.com>.
Thanks Jean-Baptiste for the quick response. Are you aware of any
samples/test that use it via MBeanServerConnection. I tried a few things,
but none worked. Does it need any arguments passed to shutdown the
container?

thanks again,

Asha



--
View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274p4028278.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Start/Stop Karaf 2.3.x via JMX

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Asha,

in org.apache.karaf:type=system,name=root, you can find the shutdown 
operation to stop Karaf.

For start/restart, it's not available in Karaf 2.2.x.

Since Karaf 2.3.x (so 2.3.0 ;)), in 
org.apache.karaf:type=system,name=root, you have the following operations:

halt() - to stop Karaf
halt(String time) - to stop Karaf at a given time
reboot() - to reboot Karaf
reboot(String time, boolean clean) - to reboot Karaf at a given time and 
eventually cleanup the data folder

Regards
JB

On 03/21/2013 11:44 PM, anair wrote:
> Hello,
>
> I have a requirement where we are required to control Karaf from outside the
> container, like start/stop bundles, uninstall/install features or bundles. I
> was able to do it via JMX using:
> serverConn.invoke(new
> ObjectName("org.apache.karaf:type=features,name=root"), installFeature, new
> Object[] { <feature-name> }, new String[] { "java.lang.String" });
>
> However, I could not find any command to start or stop the Karaf container
> from outside via JMX. Is it possible to do this?
>
> Any pointers/link to example will be greatly appreciated.
>
> thanks,
>
> Asha
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Start-Stop-Karaf-2-3-x-via-JMX-tp4028274.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com