On Jan 23, 2009, at 1:47 AM, Juergen Weber wrote:


Hi,

right now I access a GBean from a servlet using (is that the correct way?)

Kernel kernel = KernelRegistry.getSingleKernel();
URI uri = new URI(myuri);
AbstractName gBeanAN = new AbstractName(uri);
retVal = kernel.invoke(gBeanAN,"myMethod",args,paramTypes);

with myuri from the abstractName field of the GBean in JMX Viewer in
Console, which is quite a long uri.
Also you need Geronimo-specific code in a JEE application.

So I tried to bind the GBean into JNDI as suggested in
http://www.nabble.com/How-to-get-hold-of-a-WorkManager-in-a-web-app--td21400861s134.html

<gbean name="...BeanBinding"
class="org.apache.geronimo.gjndi.binding.GBeanBinding">
       <attribute name="name">...</attribute>
<attribute name="abstractNameQuery">?name=MyJNIGBean#</ attribute>
       <reference name="Context">
           <name>JavaContext</name>
       </reference>
   </gbean>

but then I get Classnotfound for GBeanBinding. How do you specify a
dependency for this class?

If this gbean is declared in a javaee app the GBeanBinding class should be available already. Otherwise...

<groupId>org.apache.geronimo.framework</groupId>
<artifactId>rmi-naming</artifactId>
<type>car</type>


and what is the abstractNameQuery for the GBean? the full AbstractName ?

The full name will definitely work but is usually overkill. Enough to uniquely identify the gbean is sufficient; this will usually be the name component of the map part of the abstract name, as in the example above. You can also use an interface implemented by your gbean after the #.

There's another approach, which gets your gbean in the java:comp/env namespace... I'll try to find time to document it better but you include a gbean-ref element in your geronimo javaee app plan with the other naming stuff...

see the geronimo-naming-1.2.xsd which ought to be in the /schemas directory and the org.apache.geronimo.naming.deployment.GBeanRefBuilder class.

In either case its a really good idea if not essential to make sure the plugin or module that contains the gbean you are looking up is the same as or an ancestor of the app that is looking it up so you are certain it has started before you try to use it.

thanks
david jencks


Thanks,
Juergen
--
View this message in context: 
http://www.nabble.com/How-do-you-access-a-GBean-via-JNDI--tp21621410s134p21621410.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Reply via email to