-
1. Re: Using local references from session bean to entity bean?
andreas Apr 10, 2002 6:09 AM (in response to razvjedtjik)Local references are defined in ejb-jar.xml and not in a jboss descriptor.
Example:
<ejb-jar>
<enterprise-beans>
<ejb-local-ref>
<local-home>eacm.ejb.RolesHome</local-home>
eacm.ejb.Roles
<ejb-ref-type>Entity</ejb-ref-type>
<ejb-ref-name>RolesEntity</ejb-ref-name>
<ejb-link>RolesEJB</ejb-link>
</ejb-local-ref>
....
ejb-link is mandatory in jBoss 2.4.4 while it isn't in the ejb spec.
hth
Andreas -
2. Re: Using local references from session bean to entity bean?
razvjedtjik Apr 10, 2002 8:27 AM (in response to razvjedtjik)Thanks for your reply, Andreas! I gather you have gotten it to work.
I know I have to define the local reference in the ejb-jar.xml file and I have done so. But when I try to look up the local bean jboss tells me that its name is not bound. It works well if the reference is not local:
::From ejb-jar.xml (remote ref)
...
<ejb-name>CaseManagerBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/CaseBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
acompany.CaseHome
acompany.Case
<ejb-link>CaseBean</ejb-link>
</ejb-ref>
...
::From jboss.xml (remote ref)
...
<ejb-name>CaseManagerBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/CaseBean</ejb-ref-name>
<jndi-name>ejb/cases/Case</jndi-name>
</ejb-ref>
...
This lookup works good for the remote ejb-ref above:
ctx.lookup("java:comp/env/ejb/CaseBean");
-----------------
::Same but with LOCAL ref, ejb-jar.xml:
(same as above, but:)
<ejb-local-ref>
<ejb-ref-name>ejb/CaseBeanLocal</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>acompany.CaseLocalHome</local-home>
acompany.CaseLocal
<ejb-link>CaseBean</ejb-link>
</ejb-local-ref>
Am I now to put an ejb-LOCAL-ref tag in the jboss.xml? The jboss DTD does not seem to support this tag (at least not according to their manual)...
What does your jboss.xml look like for the bean you describe in your reply?
Regards,
Jonas -
3. Re: Using local references from session bean to entity bean?
jbossid Apr 10, 2002 9:13 AM (in response to razvjedtjik)hi andreas,
i am not able to look an entity bean from a session bean.iam getting the following error.
Exception:java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Transaction rolled back; nested exception is:
java.lang.NullPointerException
if u have any example code of one bean looking another with local-ref ,please post it here with code and ejb-jar.xml.
it would be helpful .
Thanks -
4. Re: Using local references from session bean to entity bean?
andreas Apr 10, 2002 10:08 AM (in response to razvjedtjik)Hi,
you can get a list of all bound jndi names.
open http://yourserver:8082
and chose the link:
service=JNDIView
You'll see a botton 'list' and get somethig like this:
java:comp namespace of the DataInterface bean:
+- env (class: org.jnp.interfaces.NamingContext)
| +- RiskCurveEntity (class: eacm.ejb.RiskCurveHome)
| +- PersonEntity (class: eacm.ejb.PersonHome)
| +- RolesEntity (class: eacm.ejb.RolesHome)
.....
| +- CodedValueListStringEntry (class: eacm.ejb.CodedValueListEntryHome)
| +- ejb (class: org.jnp.interfaces.NamingContext)
| | +- CodedValueListEJBMVCLocal (class: eacm.rule.CodedValueListHome)
| | +- VolaEJBMVCLocal (class: eacm.ejb.VolaHome)
| | +- MarketDataInputEJBMVCLocal (class:
....
In my first example I defined the
<ejb-ref-name>RolesEntity</ejb-ref-name>
From the context of session bean 'DataInterface' now I can lookup:
Context initial = getContext();
RoleHome= (RoleHome) initial.lookup("java:comp/env/RoleEntity");
You should be able to lookup
java:comp/env/ejb/CaseBean
Andreas -
5. Re: Using local references from session bean to entity bean?
razvjedtjik Apr 10, 2002 10:12 AM (in response to razvjedtjik)As always I seem to solve problems just after having asked a question about them... well, well.
The only thing I had to do was NOT to have an ejb-ref in the jboss.xml if I just had an ejb-LOCAL-ref in ejb-jar.xml. This seems a bit weird but there is probably some good reason for it I guess. What got me going in the wrong direction is that you HAVE to specify an ejb-ref in the jboss.xml if you have a REMOTE ejb-ref in your ejb-jar.xml. Well, now everything is working nice and smooth.
So you did answer my question Andreas. Thanks!
.jonas -
6. Re: Using local references from session bean to entity bean?
jbossid Apr 10, 2002 12:16 PM (in response to razvjedtjik)hi jonas and andreas,
i have a session bean and entity bean.i ma looking entitybean from session bean.when iam deploying i am not able to see them in the server:8082 and the place where u mentioned.
java:comp namespace of the CustomerBean bean:
+- env (class: org.jnp.interfaces.NamingContext)
java:comp namespace of the UserManagerBean bean:
+- UserTransaction (class: javax.transaction.UserTransaction)
+- env (class: org.jnp.interfaces.NamingContext)
| +- CustomerBean (class: com.xxx.ejb.CustomerLocalHome)
iam using same jar file for both beans. could u please tell me why it is showing me like that.shall i need to deploy each bean in a single jar??
plz respond asap iam struck there.
thanx.