users@glassfish.java.net

How to access local Entity inside a Session Bean?

From: <glassfish_at_javadesktop.org>
Date: Fri, 11 Jul 2008 14:48:30 PDT

Hi,
  I have entries in web.xml for accessing local session bean and local entity beans.

[u][b]web.xml[/b][/u]
<ejb-local-ref>
     <ejb-ref-name>ParticipantServicesEJB</ejb-ref-
     <ejb-ref-type>Session</ejb-ref-type>
     <local-home>ParticipantServicesLocalHome</local-home>
     <local>com.biperf.ejb.participant.ParticipantServicesLocal</local>
     <ejb-ink>participantEJB.jar#ParticipantServicesEJB</
</ejb-local-ref>

<ejb-local-ref>
     <ejb-ref-name>ChallengeQuestion</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>ChallengeQuestionLocalHome</local-home>
     <local>ChallengeQuestionLocal</local>
     <ejb-link>participantEJB.jar#ChallengeQuestion</ejb-link>
</ejb-local-ref>

[u][b]ejb-jar.xml[/b][/u]
<session>
     <ejb-name>com.biperf.ejb.participant.ParticipantServicesEJB</ejb-name>
     <local-home>com.biperf.ejb.participant.ParticipantServicesLocalHome</local-
     <local>com.biperf.ejb.participant.ParticipantServicesLocal</local>
     <ejb-class>com.biperf.ejb.participant.ParticipantServicesBean</ejb-class>
     <session-type>Stateless</session-type>
     <transaction-type>Container</transaction-type>
</session>

<entity>
     <ejb-name>ChallengeQuestion</ejb-name>
     <local-home>..ChallengeQuestionLocalHome</local-home>
     <local>..ChallengeQuestionLocal</local>
     <ejb-class>..ChallengeQuestionDataBean</ejb-class>
     <persistence-type>Container</persistence-type>
     <prim-key-class>..</prim-key-class>
     <reentrant>false</reentrant>
     <cmp-version>2.x</cmp-version>
     <abstract-schema-name>ChallengeQuestion</abstract-schema-name>
     <cmp-field>
          <field-name>.........</field-name>
     </cmp-field>
     <primkey-field>..</primkey-field>
     <query>
          <query-method>
               <method-name>findAll</method-name>
               <method-params/>
          </query-method>
          <ejb-ql>SELECT OBJECT(o) FROM ChallengeQuestion o</ejb-ql>
     </query>
</entity>

I try to look up my session bean and entity bean separately from the web tier say .jsp file and [u][b]successfully[/b][/u] I was able to fetch and update data.

[u][b]Inside .jsp File:[/b][/u]
Object o = ctx.lookup("java:comp/env/ParticipantServicesEJB"); //session
Object o1 = ctx.lookup("java:comp/env/ChallengeQuestion"); //entity

[u][b]Here comes the PROBLEM:[/b][/u]
When I try to lookup my entity bean inside a Session bean it Fails.

Can anyone answer why and the fix to it?

Thanks in advance!
[Message sent by forum member 'gjp' (gjp)]

http://forums.java.net/jive/thread.jspa?messageID=286095