0 Replies Latest reply on Apr 7, 2007 9:08 AM by pxpwxj

    How to find a container managed entity manager through JNDI?

    pxpwxj

      How to find a container managed entity manager through JNDI?


      I deployed a EAR under jboss4.0.5.GA.I have a ejb3.0 jar named a.jar which consists of three entity bean,and a web app named b.war in this ear.
      I want use those entity bean in those servlets of b.war.In this case ,i do not want to use session bean.I hope can use entity bean in those servlets directory,not through session bean.Because i think those EntityBean and servlets are in the same jvm,even the same ear!To use session bean to bridge these ENTITYBEAN and servets ,is not gracefuly,and not efficiently,they are in the same ear!!
      To achieve that ,I try to get a container managed entity manager in these servlets,I have tried two way use annotation,they are below:
      1.@persistcontext(unit......)
      EntityManager em;
      this do not work,every time the variable em is null;
      2.@resource(mappedname.....

      in both case,i use the name of the persistent unit which defined in the persistent.xml of a.jar.

      I searched many topics on google,never find a post which tell me to find a jboss managed entitymanager under jboss.But many posts said affirmatively " ...can get a container managed entity manager through jndi...",so i wonder :
      a.jboss now do not surpport getting a container managed entity manager through jndi,or I used the wrong jndi name?
      b.in which case can i use @persistcontext(unit......) or @resource(mappedname ,those two annotation to get a container managed entity manager ?


      thank you very much for your help.I really do not want to use session bean for me,and do not want to create a app managed entitymanager under my jbossAS,it is absurd.