You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Stefan Schulze Frielinghaus <st...@sf-net.com> on 2007/08/23 14:48:24 UTC

deploy and undeploy a gbean

Hello,

I'm trying to write a GBean which dynamically deploys and undeploys  
other GBeans. My first thought about this task was to get a list of  
all running modules from which I could decide which to undeploy.

String uri = "deployer:geronimo:inVM";
String username = "system";
String password = "manager";
		
dManager = dFactoryMgr.getDeploymentManager(uri, username, password);

System.out.println("Targets:");
Target[] targets = dManager.getTargets();		
for(Target t : targets) {
	System.out.println(t);
}

System.out.println("Modules:");
TargetModuleID[] moduleIDs = dManager.getRunningModules(null, targets);
			
for(TargetModuleID m : moduleIDs) {
	System.out.println(m);
}


With the code above I tried to accomplish my goal. But if I run this  
one I get the following exception:


14:38:55,100 ERROR [BaseDeploymentFactory]  
org.apache.geronimo.web.deployment.WARConfigurer
java.lang.ClassCastException:  
org.apache.geronimo.web.deployment.WARConfigurer
         at  
org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager.loadMod 
uleConfigurers(LocalDeploymentManager.java:51)
         at  
org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager.<init>( 
LocalDeploymentManager.java:41)
         at  
org.apache.geronimo.deployment.plugin.factories.BaseDeploymentFactory.ge 
tDeploymentManager(BaseDeploymentFactory.java:133)
         at  
javax.enterprise.deploy.shared.factories.DeploymentFactoryManager.getDep 
loymentManager(DeploymentFactoryManager.java:109)
         at  
de.furtwangen.hs.informatik.geronimo.ac.MigrationService.test 
(MigrationService.java:37)
         at  
de.furtwangen.hs.informatik.geronimo.ac.AutonomicGeronimoGBean.testMigra 
tion(AutonomicGeronimoGBean.java:202)
         at  
de.furtwangen.hs.informatik.geronimo.ac.AutonomicGeronimoGBean$ 
$FastClassByCGLIB$$78735f6f.invoke(<generated>)
         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
         at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke 
(FastMethodInvoker.java:38)
         at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke 
(GBeanOperation.java:127)
         at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke 
(GBeanInstance.java:863)
         at org.apache.geronimo.kernel.basic.BasicKernel.invoke 
(BasicKernel.java:239)
         at org.apache.geronimo.system.jmx.MBeanGBeanBridge.invoke 
(MBeanGBeanBridge.java:168)
         at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke 
(DynamicMetaDataImpl.java:213)
         at com.sun.jmx.mbeanserver.MetaDataImpl.invoke 
(MetaDataImpl.java:220)
         at  
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke 
(DefaultMBeanServerInterceptor.java:815)
         at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke 
(JmxMBeanServer.java:784)
         at javax.management.remote.rmi.RMIConnectionImpl.doOperation 
(RMIConnectionImpl.java:1408)
         at javax.management.remote.rmi.RMIConnectionImpl.access$100 
(RMIConnectionImpl.java:81)
         at javax.management.remote.rmi.RMIConnectionImpl 
$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
         at  
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation 
(RMIConnectionImpl.java:1341)
         at javax.management.remote.rmi.RMIConnectionImpl.invoke 
(RMIConnectionImpl.java:782)
         at sun.reflect.GeneratedMethodAccessor187.invoke(Unknown  
Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at sun.rmi.server.UnicastServerRef.dispatch 
(UnicastServerRef.java:294)
         at sun.rmi.transport.Transport$1.run(Transport.java:153)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages 
(TCPTransport.java:466)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run 
(TCPTransport.java:707)
         at java.lang.Thread.run(Thread.java:613)


Is there another way to deploy/undeploy GBeans via another GBean?

I even tried it with another URI (String uri =  
"deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";) but  
with that I still got a worse result.

javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationExceptio 
n: Failed to retrieve RMIServer stub:  
javax.naming.NoInitialContextException: Cannot instantiate class:  
org.apache.xbean.naming.global.GlobalContextManager [Root exception  
is java.lang.ClassNotFoundException:  
org.apache.xbean.naming.global.GlobalContextManager]
         at  
org.apache.geronimo.deployment.plugin.factories.BaseDeploymentFactory.ne 
wRemoteDeploymentManager(BaseDeploymentFactory.java:167)
         at  
org.apache.geronimo.deployment.plugin.factories.BaseDeploymentFactory.ge 
tDeploymentManager(BaseDeploymentFactory.java:131)
         at  
javax.enterprise.deploy.shared.factories.DeploymentFactoryManager.getDep 
loymentManager(DeploymentFactoryManager.java:109)
         at  
de.furtwangen.hs.informatik.geronimo.ac.MigrationService.test 
(MigrationService.java:37)
         at  
de.furtwangen.hs.informatik.geronimo.ac.AutonomicGeronimoGBean.testMigra 
tion(AutonomicGeronimoGBean.java:202)
         at  
de.furtwangen.hs.informatik.geronimo.ac.AutonomicGeronimoGBean$ 
$FastClassByCGLIB$$78735f6f.invoke(<generated>)
         at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
         at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke 
(FastMethodInvoker.java:38)
         at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke 
(GBeanOperation.java:127)
         at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke 
(GBeanInstance.java:863)
         at org.apache.geronimo.kernel.basic.BasicKernel.invoke 
(BasicKernel.java:239)
         at org.apache.geronimo.system.jmx.MBeanGBeanBridge.invoke 
(MBeanGBeanBridge.java:168)
         at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke 
(DynamicMetaDataImpl.java:213)
         at com.sun.jmx.mbeanserver.MetaDataImpl.invoke 
(MetaDataImpl.java:220)
         at  
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke 
(DefaultMBeanServerInterceptor.java:815)
         at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke 
(JmxMBeanServer.java:784)
         at javax.management.remote.rmi.RMIConnectionImpl.doOperation 
(RMIConnectionImpl.java:1408)
         at javax.management.remote.rmi.RMIConnectionImpl.access$100 
(RMIConnectionImpl.java:81)
         at javax.management.remote.rmi.RMIConnectionImpl 
$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
         at  
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation 
(RMIConnectionImpl.java:1341)
         at javax.management.remote.rmi.RMIConnectionImpl.invoke 
(RMIConnectionImpl.java:782)
         at sun.reflect.GeneratedMethodAccessor187.invoke(Unknown  
Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at sun.rmi.server.UnicastServerRef.dispatch 
(UnicastServerRef.java:294)
         at sun.rmi.transport.Transport$1.run(Transport.java:153)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages 
(TCPTransport.java:466)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run 
(TCPTransport.java:707)
         at java.lang.Thread.run(Thread.java:613)
Caused by: java.io.IOException: Failed to retrieve RMIServer stub:  
javax.naming.NoInitialContextException: Cannot instantiate class:  
org.apache.xbean.naming.global.GlobalContextManager [Root exception  
is java.lang.ClassNotFoundException:  
org.apache.xbean.naming.global.GlobalContextManager]
         at javax.management.remote.rmi.RMIConnector.connect 
(RMIConnector.java:317)
         at javax.management.remote.JMXConnectorFactory.connect 
(JMXConnectorFactory.java:248)
         at  
org.apache.geronimo.deployment.plugin.factories.BaseDeploymentFactory.ne 
wRemoteDeploymentManager(BaseDeploymentFactory.java:159)
         ... 30 more
Caused by: javax.naming.NoInitialContextException: Cannot instantiate  
class: org.apache.xbean.naming.global.GlobalContextManager [Root  
exception is java.lang.ClassNotFoundException:  
org.apache.xbean.naming.global.GlobalContextManager]
         at javax.naming.spi.NamingManager.getInitialContext 
(NamingManager.java:657)
         at javax.naming.InitialContext.getDefaultInitCtx 
(InitialContext.java:247)
         at javax.naming.InitialContext.init(InitialContext.java:223)
         at javax.naming.InitialContext.<init>(InitialContext.java:197)
         at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI 
(RMIConnector.java:1815)
         at javax.management.remote.rmi.RMIConnector.findRMIServer 
(RMIConnector.java:1787)
         at javax.management.remote.rmi.RMIConnector.connect 
(RMIConnector.java:259)
         ... 32 more
Caused by: java.lang.ClassNotFoundException:  
org.apache.xbean.naming.global.GlobalContextManager
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 
268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java: 
319)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:242)
         at com.sun.naming.internal.VersionHelper12.loadClass 
(VersionHelper12.java:42)
         at javax.naming.spi.NamingManager.getInitialContext 
(NamingManager.java:654)
         ... 38 more

Since I've the package org.apache.xbean.naming in my classpath I  
don't no why geronimo can't instantiate a class of them.

So has anyone an idea how to solve a deply/undeploy task?

Best regards,
Stefan

Re: deploy and undeploy a gbean

Posted by Stefan Schulze Frielinghaus <st...@sf-net.com>.
> BTW, It's a user question so you'd be better off sending it to the
> user mailing list - user@geronimo.apache.org (see
> http://geronimo.apache.org/mailing-lists.html).

Ops, I thought the dev-list is for developing stuff. I will close  
this thread an "reopen" it under the user list. Please ignore this  
one ;-)


Re: deploy and undeploy a gbean

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 8/23/07, Stefan Schulze Frielinghaus <st...@sf-net.com> wrote:

> I'm trying to write a GBean which dynamically deploys and undeploys
> other GBeans. My first thought about this task was to get a list of
> all running modules from which I could decide which to undeploy.
...
> 14:38:55,100 ERROR [BaseDeploymentFactory]
> org.apache.geronimo.web.deployment.WARConfigurer
> java.lang.ClassCastException:
> org.apache.geronimo.web.deployment.WARConfigurer
>          at
> org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager.loadMod
> uleConfigurers(LocalDeploymentManager.java:51)

Hi,

I won't help you with it, but perhaps point in the right direction.
CCE is when a class is in two classloaders. I think the proper way is
to declare a dependency on GBeanDeployer in your gbean descriptor. I
have never done it before so it's way the answer is wacky.

See var/config/config.xml for references how to wire gbeans (and await
others' responses to get the real answer ;-))

> I even tried it with another URI (String uri =
> "deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector";) but
> with that I still got a worse result.

Don't do that. There're simpler ways, I guess. I'd rather see gbean
wiring used not Java Deployment API.

BTW, It's a user question so you'd be better off sending it to the
user mailing list - user@geronimo.apache.org (see
http://geronimo.apache.org/mailing-lists.html).

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl