Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing entity bean from session bean

 
chuck keuper
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an entity bean with a method getMember. My session bean has this code - for which I am receiveing a javax.naming.NameNotFoundException: Missing Node - Member. How do I write this lookup???
public java.lang.String getMember(Integer memberid)
{
String strMemberName = null;
try {
Context ctx = new InitialContext();
// Object obj = ctx.lookup("java:comp/env/ejb/member");
Object obj = ctx.lookup("java:comp/env/Member");
MemberHome aMemberHome = (MemberHome)PortableRemoteObject.narrow(obj,MemberHome.class);
Member aMember = aMemberHome.findByPrimaryKey(memberid);
strMemberName = aMember.getFname();
return strMemberName;
} catch (ClassCastException cce) {
cce.printStackTrace();
return "ClassCastException " + cce.getMessage();
} catch (NamingException ne) {
ne.printStackTrace();
return "NamingException " + ne.getMessage();
} catch (FinderException fe) {
fe.printStackTrace();
return "FinderException " + fe.getMessage();
}
}

C:\BES\jdk\jdk1.4.1\bin\javaw -classpath "C:\TMP\whitepaper\classes;C:\BES\lib\asrt.jar;C:\BES\lib\lm.jar;C:\BES\lib\xmlrt.jar;C:\BES\lib\vbjorb.jar;C:\BES\lib\vbejb.jar;C:\BES\lib\vbsec.jar;C:\BES\lib\beandt.jar;C:\BES\lib\dx.jar;C:\BES\lib\axis\axis-bes.jar;C:\BES\lib\axis\axis-ant.jar;C:\BES\SonicMQ\lib\sonic_Client.jar;C:\OracleDriver\lib\ojdbc14.jar;C:\BES\jdk\jdk1.4.1\demo\jfc\Java2D\Java2Demo.jar;C:\BES\jdk\jdk1.4.1\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\BES\jdk\jdk1.4.1\jre\lib\charsets.jar;C:\BES\jdk\jdk1.4.1\jre\lib\ext\dnsn s.jar;C:\BES\jdk\jdk1.4.1\jre\lib\ext\ldapsec.jar;C:\BES\jdk\jdk1.4.1\jre\lib\ext\localedata.jar;C:\BES\jdk\jdk1.4.1\jre\lib\ext\sunjce_provider.jar;C:\BES\jdk\jdk1.4.1\jre\lib\im\indicim.jar;C:\BES\jdk\jdk1.4.1\jre\lib\jaws.jar;C:\BES\jdk\jdk1.4.1\jre\lib\jce.jar;C:\BES\jdk\jdk1.4.1\jre\lib\jsse.jar;C:\BES\jdk\jdk1.4.1\jre\lib\rt.jar;C:\BES\jdk\jdk1.4.1\jre\lib\sunrsasign.jar;C:\BES\jdk\jdk1.4.1\lib\dt.jar;C:\BES\jdk\jdk1.4.1\lib\htmlconverter.jar;C:\BES\jdk\jdk1.4.1\lib\tools.jar" -Dvbroker.agent.enableLocator=false -DORBInitRef=NameService=iioploc://11.112.1.135:9999/NameService whitepaper.ProfileSessionTestClient1
-- Initializing bean access.
-- Succeeded initializing bean access through Home interface.
-- Execution time: 1547 ms.
-- Calling create()
-- Succeeded: create()
-- Execution time: 31 ms.
-- Return value from create(): Stub[repository_id=RMI:whitepaper.ProfileSession:0000000000000000,key=Se ...
-- Calling getMember(1)
-- Succeeded: getMember(1)
-- Execution time: 250 ms.
-- Return value from getMember(1): NamingException Missing Node - Member.
This is a copy of the error from the printstacktrace �

javax.naming.NameNotFoundException: Missing Node - Member
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:522)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:532)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:532)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:532)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:991)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:996)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at whitepaper.ProfileSessionBean.getMember(ProfileSessionBean.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:166)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1301)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1023)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:816)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:595)
at com.inprise.ejb.EJBHome.dispatcherInvokeBeanMethod(EJBHome.java:55)
at com.inprise.ejb.EJBHome$ComponentInterfaceMethodCache.invokeDispatcherMethod(EJBHome.java:1502)
at com.inprise.ejb.EJBHome.invokeDispatcherMethod(EJBHome.java:34)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:416)
at whitepaper.ProfileSessionPOAInvokeHandler.getMember(ProfileSessionPOAInvokeHandler.java:35)
at whitepaper.ProfileSessionPOAInvokeHandler.getMember(ProfileSessionPOAInvokeHandler.java:69)
at whitepaper.ProfileSessionPOA._invoke(ProfileSessionPOA.java:62)
at whitepaper.ProfileSessionPOA._invoke(ProfileSessionPOA.java:43)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2693)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:109)
at com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:110)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:824)
at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1106)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:106)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)
ejbcontainer: EJB Container Statistics
ejbcontainer: ========================
ejbcontainer: TimeWed May 05 18:13:21 MDT 2004
ejbcontainer: Memory (used)5572 Kb(max 5572 Kb)
ejbcontainer: Memory (total)65152 Kb(max 65152 Kb)
ejbcontainer: Memory (free)91.0%
ejbcontainer: ------------------------
ejbcontainer: Home (remote)ProfileSession
ejbcontainer: READY1
ejbcontainer: Total in memory1
ejbcontainer: Total in use1
ejbcontainer: ------------------------
ejbcontainer: Home (local)Member
ejbcontainer: Total in memory0
ejbcontainer: Total in use0
ejbcontainer: ========================
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your code is ok.
Do you get any exceptions at deploy time?
Have you specified a reference to the entity ejb in ejb-jar.xml (for the session ejb)?
 
Augg Stine
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I think that it is 99% due to EJB, which is not deployed on the server.
check it out once again
regards,
Augg
 
chuck keuper
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not get any exceptions at deploy time. Code listed below.
C:\BES\jdk\jdk1.4.1\bin\javaw -classpath ;;C:\JBuilder9\classes;C:\JBuilder9\lib\primetime.jar;C:\JBuilder9\lib\jbuilder.jar;C:\JBuilder9\lib\servers\bes-jbsp.jar;C:\JBuilder9\lib\help.jar;C:\JBuilder9\lib\dbswing.jar;C:\JBuilder9\lib\internetbeans.jar;C:\BES\jdk\jdk1.4.1\lib\tools.jar;C:\BES\lib\vbjorb.jar;C:\BES\lib\vbjdev.jar;C:\BES\lib\vbdev.jar;C:\BES\lib\vbejb.jar;C:\BES\lib\vbsec.jar;C:\BES\lib\xmlrt.jar;C:\BES\lib\asrt.jar;C:\BES\lib\agentclient.jar;C:\BES\lib\guicore.jar;C:\BES\lib\lm.jar;C:\BES\lib\navigator.jar;C:\BES\lib\js se.jar;C:\BES\lib\jaas.jar;C:\BES\lib\jcert.jar;C:\BES\lib\jnet.jar;C:\BES\lib\dx.jar; com.borland.jbuilder.server.bes.WaitProcess
Looking for standard partition...
Found standard partition.
Deploy -- C:/whitepaper/jndi-definitions.xml
Succeeded: Deploy -- C:/whitepaper/WhitepaperModule.jar
I looked at the ejb-jar.xml and there is no reference to the entity in the session. There is a reference to the entity in the enterprise-bean. What tags am I susposed to use for the session bean to represent the entity???
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<display-name>ProfileSession</display-name>
<ejb-name>ProfileSession</ejb-name>
<home>whitepaper.ProfileSessionHome</home>
<remote>whitepaper.ProfileSession</remote>
<ejb-class>whitepaper.ProfileSessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<entity>
<display-name>Member</display-name>
<ejb-name>Member</ejb-name>
<local-home>whitepaper.MemberHome</local-home>
<local>whitepaper.Member</local>
<ejb-class>whitepaper.MemberBean</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>Member</abstract-schema-name>
<cmp-field>
<field-name>memberid</field-name>
</cmp-field>
<cmp-field>
<field-name>docapprovalid</field-name>
</cmp-field>
<cmp-field>
<field-name>securitydetailid</field-name>
</cmp-field>
<cmp-field>
<field-name>membertypid</field-name>
</cmp-field>
<cmp-field>
<field-name>fname</field-name>
</cmp-field>
<cmp-field>
<field-name>lname</field-name>
</cmp-field>
<cmp-field>
<field-name>mname</field-name>
</cmp-field>
<cmp-field>
<field-name>uniqueid</field-name>
</cmp-field>
<cmp-field>
<field-name>gender</field-name>
</cmp-field>
<cmp-field>
<field-name>membertypname</field-name>
</cmp-field>
<primkey-field>memberid</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ProfileSession</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>Member</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a piece of ejb-jar.xml of a project i'm working on.
My session HousesInfo looks up for my PartyHouse bean, so i need a ref to it in:
-> ejb-jar.xml

-> jboss.xml (or your server file conf. file)

I'm refering the local interface of PartyHouseBean.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You need to define a ejb reference for your local bean in your ejb-jar.xml in order for you to use java:comp/env
e.g.

Cheers.


Han Ming
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic