I see 2 errors in the plan 1) In your openejb-jar.xml file you are setting the default namespace "http://www.openejb.org/xml/ns/openejb-jar-2.1" instead of 2.2 but anyway that should be taken care of by g
2) In the gbean-ref you are only giving the ref-name but u need to provide a mapping of that refname to the actual gbean by giving the pattern/ ref-type elements. If you give the pattern element then you need to specify the name of your gbean inside that element inside the name tag. However I guess both these should not cause the problem you are experiencing Another thing you can try is to call org.apache.geronimo.kernel.KernelRegistry.getSingleKernel(); from within the ejb. This will give you the kernel from which you can get the gbean by executing a gbean query. Using gbean refs is the better approach though. regards Manu On Wed, Jun 25, 2008 at 4:39 PM, dsthode <[EMAIL PROTECTED]> wrote: > > Hello all, > > I'm trying to deploy an enterprise application in Geronimo 2.1.1 wich makes > use of a GBean from inside a Message EJB. That GBean is a custom developed > GBean that creates a thread and uses the persistence unit defined in my > persistence.xml as well as a ConnectionFactory and a Topic for a JMS > destination, all of them injected with the <reference> tags in the <gbean> > definition. All that does not represent a problem as all the injections work > right and I've created the connection to the JMS destination from my GBean > with no major trouble. > > My problem comes when I try to reference that GBean from my Message EJB. > I've tried to add a <gbean-ref> to the <message-driven> definition of this > MDB but I get the following exception when deploying (see below for the > openejb-jar.xml): > > [severity=ERROR,message=unexpected element > (uri:"http://geronimo.apache.org/xml/ns/naming-1.2", local:"ref-name"). > Expected elements are <{http://openejb.apache.org/xml/n > s/openejb-jar-2.2}ref-type>,<{http://openejb.apache.org/xml/ns/openejb-jar-2.2}pattern>,<{http://openejb.apache.org/xml/ns/openejb-jar-2.2}ref-name>,locator=[node=null,ob > ject=null,url=null,line=38,col=15,offset=-1]] > > If anyone needs the details for the exception stack trace I can post them, > but I think the error message is explanatory enough and the stack trace is > quite too long. > > I've checked all the xsd files and <ref-name> is defined inside a > <gbean-ref> tag and it belongs to the geronimo-naming-1.2 schema , so I > don't get the meaning of this message. > > Also I've tried to change the namespace to the <ref-name> tag and set it to > <ref-name xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"> as the > error message suggests, but fails with the same error message. And i've > tried to prepend the "nam:" namespace to the <ref-name> tag also, but with > no success either. > > And another question is, when I set the reference in my openejb-jar.xml, how > do I use this GBean from my MDB? I've tried to set a @Reference annotation > but I guess this is not going to work as I think it's only for JDBC, JMS and > the like resources, not for GBeans. > > This is my openejb-jar.xml file: > > <?xml version="1.0" encoding="UTF-8"?> > <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1" > > xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2" > xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0" > > xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" > > xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"> > <sys:environment> > <sys:moduleId> > <sys:groupId>sampleGroup</sys:groupId> > <sys:artifactId>sample_EJB</sys:artifactId> > <sys:version>1.0</sys:version> > <sys:type>car</sys:type> > </sys:moduleId> > <sys:dependencies> > <sys:dependency> > <sys:groupId>console.dbpool</sys:groupId> > <sys:artifactId>sampleDS</sys:artifactId> > </sys:dependency> > <sys:dependency> > <sys:groupId>console.jms</sys:groupId> > <sys:artifactId>sampleMsgResources</sys:artifactId> > </sys:dependency> > </sys:dependencies> > </sys:environment> > <enterprise-beans> > <session> > <ejb-name>Bean1</ejb-name> > </session> > <session> > <ejb-name>Bean2</ejb-name> > </session> > <message-driven> > <ejb-name>MDBBean1</ejb-name> > <resource-adapter> > > <resource-link>sampleMsgResources</resource-link> > </resource-adapter> > <gbean-ref> > <!-- the next tag is causing trouble with an "unexpected element" exception > --> > <ref-name>UpdatesProcessorGBean</ref-name> > </gbean-ref> > </message-driven> > <message-driven> > <ejb-name>MDBBean2</ejb-name> > <resource-adapter> > > <resource-link>sampleMsgResources</resource-link> > </resource-adapter> > </message-driven> > </enterprise-beans> > <sys:gbean name="UpdatesProcessorGBean" > class="sample.gbean.GBeanUpdatesProcessor"> > <!-- this is the persistence unit defined in persistence.xml --> > <reference name="samplePU"> > <name>samplePU</name> > </reference> > <!-- this is a connection factory defined in sampleMsgResources --> > <reference name="UpdatesConnectionFactory"> > <name>UpdatesListasConnectionFactory</name> > </reference> > <!-- this is a Topic defined in sampleMsgResources --> > <reference name="sampleTopic"> > <name>sampleTopic</name> > </reference> > </sys:gbean> > </openejb-jar> > > If anyone has an idea, please help me, as I'm stuck and I don't know where > to go next. > > Thank you. > -- > View this message in context: > http://www.nabble.com/Use-of-a-GBean-from-a-Message-EJB-tp18109820s134p18109820.html > Sent from the Apache Geronimo - Users mailing list archive at Nabble.com. > >
