Jacek Laskowski wrote:
On Tue, Jul 1, 2008 at 1:40 PM, dsthode
<[EMAIL PROTECTED]> wrote:
I've followed your advice and changed the default namespace to openejb
version 2.2 and added a <pattern> element for the <gbean-ref> resolution,
but Geronimo keeps failing on deployment with the message that <ref-name> is
not in geronimo-namespace-1.2 schema but in
http://openejb.apache.org/xml/ns/openejb-jar-2.2, even though you can open
geronimo-naming-1.2 and find <ref-name> defined in this schema.
Did you happen to sort it out? What was the solution?
Jacek
Hi,
I think I've traced the problem to a bug in OpenEJB:
OpenEJB forces the namespace of the tags <ref-name> and <ref-type> to
"http://geronimo.apache.org/xml/ns/naming-1.2" in
container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/NamespaceFilter.java
regardless of the namespace specified in the openejb-jar.xml deployment
descriptor. On the other hand the "namespace" attributes in the
@XmlElement annotations in
container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GbeanRefType.java
are missing for these variables and therefore during the parsing of the
deployment descriptor the wrong default namespace of
"http://openejb.apache.org/xml/ns/openejb-jar-2.2" is expected. The
patch attached to this mail fixes this by adding the missing attributes.
I used my patched version of OpenEJB with Geronimo to access a GBean
from a stateless EJB:
openejb-jar.xml:
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.2">
<enterprise-beans>
<session>
<ejb-name>DummyEJB</ejb-name>
<gbean-ref>
<ref-name>LocalGBeanName</ref-name>
<pattern>
<name>GlobalGBeanName</name>
</pattern>
</gbean-ref>
</session>
</enterprise-beans>
</openejb-jar>
geronimo-application.xml:
[...]
<sys:gbean name="GlobalGBeanName"
class="com.heilgeist.tests.tst_geronimo_gbean.gbean.TheGBeanClass"/>
[...]
Inside a @PostConstruct of the EJB class:
[...]
InitialContext ic = new InitialContext();
this.theGBean = (TheGBeanClass)
ic.lookup("java:comp/geronimo/env/LocalGBeanName");
[...]
Everything deploys without any errors and the EJB can correctly access
the GBean and call methods of the GBean. There doesn't seem to be a way
to actually inject the GBean with something like a @Resource annotation.
Is this supposed to work or can GBeans only be injected into an EJBs
JNDI environment and have to be looked up manually?
Anyway, this should fix most of Damians original problems.
Janko
Index: container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GbeanRefType.java
===================================================================
--- container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GbeanRefType.java (revision 674851)
+++ container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/GbeanRefType.java (working copy)
@@ -58,10 +58,11 @@
extends AbstractNamingEntryType
{
- @XmlElement(name = "ref-name", required = true)
+ @XmlElement(name = "ref-name", namespace="http://geronimo.apache.org/xml/ns/naming-1.2", required = true)
protected String refName;
- @XmlElement(name = "ref-type")
+ @XmlElement(name = "ref-type", namespace="http://geronimo.apache.org/xml/ns/naming-1.2")
protected List<String> refType;
+ @XmlElement(name = "pattern", namespace = "http://geronimo.apache.org/xml/ns/naming-1.2")
protected List<PatternType> pattern;
/**