TreeCache instantiation
jarva55 Jan 28, 2005 4:38 AMHello.
Supposedly my TreeCacheMBean is still registrered by this xml:
<?xml version="1.0" encoding="UTF-8"?> <server> <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/> <!-- ==================================================================== --> <!-- Defines TreeCache configuration --> <!-- ==================================================================== --> <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache"> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> <attribute name="JndiName">qnecta/servicio/treecache/TreeCache</attribute> <!-- Configure the TransactionManager --> <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> ....... </server>
And to use this MBean, I've been using this source code and my program:
MBeanServer serverMBean = MBeanServerLocator.locate(); try { treeCache = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, nombreServicio, serverMBean); } catch (MalformedObjectNameException mne) { throw new RuntimeException(mne); }
And it goes ok. But my problems is at use of standard classes, like MBeanServerFactory and MBeanServerInvocationHandler, like that:
MBeanServer server = MBeanServerFactory.createMBeanServer(); ObjectName objName; try { objName = new ObjectName("jboss.cache:service=TreeCache"); Object proxy = MBeanServerInvocationHandler.newProxyInstance(server, objName, TreeCacheMBean.class, false); treeCache = (TreeCacheMBean)proxy; } catch (Exception e) { e.printStackTrace(); }
But when i try this code, it results on this exception:
10:35:43,600 INFO [STDOUT] javax.management.InstanceNotFoundException: jboss.cache:service=TreeCache is not registered. 10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:509) 10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:259) 10:35:43,600 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:245) 10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.mbean.DAOTreeCache.setCache(DAOTreeCache.java:201) 10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.mbean.DAOTreeCache.<init>(DAOTreeCache.java:52) 10:35:43,600 INFO [STDOUT] at com.acotelsa.qnecta.server.dao.treecache.ejb.DAOTreeCache.ejbCreate(DAOTreeCache.java:64) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.StatelessSessionEnterpriseContext.<init>(StatelessSessionEnterpriseContext.java:63) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.java:35) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:146) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:80) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624) 10:35:43,615 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:870) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324) 10:35:43,615 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144) 10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) 10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72) 10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) 10:35:43,615 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642) 10:35:43,615 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805) 10:35:43,615 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:35:43,615 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 10:35:43,615 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 10:35:43,615 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324) 10:35:43,615 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) 10:35:43,615 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.java:148) 10:35:43,615 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method) 10:35:43,615 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Transport.java:144) 10:35:43,615 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) 10:35:43,615 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) 10:35:43,615 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
I've seen the use of this source code on more than one example, what is the problem???
If I register a MBean by the ".xml", I can't use the second source code way???
Thanks.