• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cmp 2.x jndi local lookup fails

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I seem to of been on this problem for weeks.

Trying to find a Stock CMP Entity beans local interface from a session bean.

Using Rational Application Developer 7, from the Universal Test Client I can find the StockCMPLocalHome interface. However with the following jndi code variations from the session bean I cannot find it.

-BEGIN CODE----------------------------
try {
jndiname = "java:comp/env/ejb/Stock";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("ONE FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejb/StockCMPLocal";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("TWO FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/Stock";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("THREE FAILED "+jndiname+" Err="+ne1.getMessage());
}


try {
jndiname = "java:comp/env/ejb/StockCMP";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("FOUR FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejbs.StockCMPLocalHome";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("FIVE FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejbs.StockCMP";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("SIX FAILED "+jndiname+" Err="+ne1.getMessage());
}
-END CODE----------------------------

I have provided the output below, note it cannot even find the ejb namespace in some.

-BEGIN ERR----------------------------
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O ONE FAILED java:comp/env/ejb/Stock Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O TWO FAILED java:comp/env/ejb/StockCMPLocal Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O THREE FAILED java:comp/env/Stock Err=Name "comp/env/Stock" not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O FOUR FAILED java:comp/env/ejb/StockCMP Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O FIVE FAILED java:comp/env/ejbs.StockCMPLocalHome Err=Name "comp/env/ejbs.StockCMPLocalHome" not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O SIX FAILED java:comp/env/ejbs.StockCMP Err=Name "comp/env/ejbs.StockCMP" not found in context "java:".
-END ERR----------------------------

I have also included the ejb-jar.xml file below.

-BEGIN ejb-jar.xml------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>
StockEJB</display-name>
<enterprise-beans>
<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>
<session id="StockList">
<ejb-name>StockList</ejb-name>
<home>ejbs.StockListHome</home>
<remote>ejbs.StockList</remote>
<ejb-class>ejbs.StockListBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

-END ejb-jar.xml--------------------

Thanks Phil
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JNDI name is specified in the <ejb-local-ref> element in the entity bean EJB deployment descriptor. It should look like this:


You should now be able to do a JNDI look up using "java:comp/env/ejb/StockCMPBean".
 
Philip Rowley
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I tried to implement your xml but still cannot find namespace ejb. I also noticed you referenced the StockList session bean instead of the Stock entity bean in <local-home> and <local>.

I tried with your xml which referenced the entity and session bean. This failed with java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

-BEGIN--------

JNDI Call Used = "java:comp/env/ejb/StockCMPBean";
Error Msg = java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/StockCMPBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>ejbs.StockListHome</local-home>
<local>ejbs.StockList</local>
</ejb-local-ref>
</entity>
-END------------

I then tried with it modified to only reference the Stock entity bean, which also failed with the same error msg.

-BEGIN----------

JNDI Call Used = "java:comp/env/ejb/StockCMPBean";
Error Msg = java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/StockCMPBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
</ejb-local-ref>
</entity>
-END--------

Looking at the error msg, it seems to me that it cannot get past the EJB namespace see msg again below

java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".


Thanks

Phil
 
Philip Rowley
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When calling a local lookup from a Session or Entity bean, and it's looking for its self it works.

But when calling a local lookup from Session or Entity bean, and it's looking for a different Entity or Session bean it fails.

However, when I create a refence from an entity bean to a sessoin bean etc.. it works (thanks Roger).

ie using <ejb-local-ref> tag.

Why does this exist? It seems like an overhead with no real use? Can anyone suggest some reading, I have not come across this in my books, or understood it when I have read it.

Any reply welcome.

Thanks Phil
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic