Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Refresh OSGi bundles programmatically
Refresh OSGi bundles programmatically [message #782303] Mon, 23 January 2012 13:48 Go to next message
JP S is currently offline JP SFriend
Messages: 3
Registered: January 2012
Junior Member
My question is related to how to refresh bundles programmatically. I got some ideas from Virgo FAQ and Virgo Tooling section of the wiki.

I have a PLAN which deploys/installs 4 bundles when virgo starts. Now to automate my deployment i can push my one of updated artifact(included in the PLAN) into /repository/usr.

My problem is that if I try to refresh this bundle programmatically using the following code

            MBeanServerConnection connection = jmxHandle.getConnection();
            ObjectName name = new ObjectName(BaseMojo.MBEAN_DEPLOYER);
            //Object[] params  = { "file:///" + artifactPath, "1.0.0.SNAPSHOT"};
            Object[] params = { "com.company.my-api", "1.0.0.SNAPSHOT"};
            String[] signature = { "java.lang.String", "java.lang.String" };
            
            connection.invoke(name, "refreshBundle", params, signature);

It is throwing an exception Refresh not possible as no bundle with name com.company.my-api and version 1.0.0.SNAPSHOT is deployed.

I can confirm that this bundle is 100% deployed by using JConsole & my symbolic name and version name is correct(again verified from JConsole)

Can someone advise what's going wrong in my approach.

Thanks
JP
Re: Refresh OSGi bundles programmatically [message #782325 is a reply to message #782303] Mon, 23 January 2012 14:37 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Please could you post the exception stack trace? Also, presumably the plan is unscoped, but please confirm this.
Re: Refresh OSGi bundles programmatically [message #782541 is a reply to message #782325] Mon, 23 January 2012 23:03 Go to previous messageGo to next message
JP S is currently offline JP SFriend
Messages: 3
Registered: January 2012
Junior Member
Thanks Glyn for looking into it. Yes, the plan is unscoped.
Please find the stack trace below -


javax.management.RuntimeMBeanException: java.lang.RuntimeException: org.eclipse.virgo.kernel.deployer.core.DeploymentException: Refresh not possible as no bundle with name com.company.my-api and version 1.0.0.SNAPSHOT is deployed
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.rethrow(DefaultMBeanServerInterceptor.java:856)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.rethrowMaybeMBeanException(DefaultMBeanServerInterceptor.java:869)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:838)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:447)
	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 java.security.AccessController.doPrivileged(Native Method)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1367)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
	at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
	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:303)
	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:680)
	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
	at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
	at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
	at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
	at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:993)
	at net.flybyte.virgo.maven.deployer.JPRefresh.refreshBundle(JPRefresh.java:62)
	at com.mit.virgo.VirgoServerConnectionTest.refreshBundle(VirgoServerConnectionTest.java:32)
	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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: org.eclipse.virgo.kernel.deployer.core.DeploymentException: Refresh not possible as no bundle with name com.company.my-api and version 1.0.0.SNAPSHOT is deployed
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.refreshBundle(PipelinedApplicationDeployer.java:436)
	at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.refreshBundle(StandardDeployer.java:74)
	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.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:167)
	at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:96)
	at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:33)
	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 com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:447)
	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 java.security.AccessController.doPrivileged(Native Method)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1367)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
	at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
	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:303)
	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:680)


FYI - I did some further investigation using the queryNames method, just to confirm what MBeans are retrieved.

ObjectName searchObjectName = new ObjectName("org.eclipse.virgo.kernel:type=Model,artifact-type=bundle,name=com.company.my-api,version=1.0.0.SNAPSHOT");
			MBeanServerConnection connection = jmxHandle.getConnection();
			Set<ObjectName> objectNames = connection.queryNames(searchObjectName, null);
			
			for (Iterator<ObjectName> iterator = objectNames.iterator(); iterator.hasNext(); ) {
				ObjectName objectName = iterator.next();
				
				//System.out.println("bundleSymbolicName [" + objectName.getKeyProperty("bundleSymbolicName") + "]");
				System.out.println("objectName [" + objectName.toString() + "]");
			}

Output is objectName [org.eclipse.virgo.kernel:type=Model,artifact-type=bundle,name=com.company.my-api,version=1.0.0.SNAPSHOT]

Thanks
JP
Re: Refresh OSGi bundles programmatically [message #782748 is a reply to message #782541] Tue, 24 January 2012 10:57 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Right. The ApplicationDeployer.refreshBundle method should be better documented. It's only designed to cope with bundles which have been deployed on their own - not as part of a PAR or plan. The ApplicationDeployer.refresh(URI uri, String symbolicName) method is what the Virgo IDE tooling uses to refresh a single bundle which is part of a PAR. Unfortunately, there's nothing provided to cope with a bundle which is deployed as part of a plan. If you would like to raise an enhancement bugzilla for this please do. (In case you're tempted, driving the OSGi API directly won't help as you need to get Virgo to copy the updated bundle into its work directory.)
Re: Refresh OSGi bundles programmatically [message #782787 is a reply to message #782748] Tue, 24 January 2012 13:05 Go to previous messageGo to next message
JP S is currently offline JP SFriend
Messages: 3
Registered: January 2012
Junior Member
Thanks for the clarification Glyn. It really was helpful.

JP
Re: Refresh OSGi bundles programmatically [message #783183 is a reply to message #782787] Wed, 25 January 2012 08:47 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
You're welcome. I opened an enhancement bug 369631.
Previous Topic:HOW-TO: Logging with the logback Consoleappender and/or custom appenders?
Next Topic:FIRST GWT WAB
Goto Forum:
  


Current Time: Fri Apr 19 11:20:54 GMT 2024

Powered by FUDForum. Page generated in 0.01992 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top