2 Replies Latest reply on Apr 26, 2005 11:26 AM by Darko Krizic

    Own LoginModule access to Entity Bean via @Inject

    Darko Krizic Newbie

      Hi!

      I implemented my own LoginModule that works with hardcoded values. But now I want to access the EntityManager in order to access the database, but I don't know how.

      I tried "private @Inject EntityManager em", but em is always null.

      How can I achieve this?

        • 1. Re: Own LoginModule access to Entity Bean via @Inject
          Kabir Khan Master

          A bit hard to say without more details, but the only things in EJB3 that have injection performed on them are classes annotated with
          @Stateless
          @Stateful
          @MessageDriven
          (and the JBoss extensions @Service and @Consumer).

          If LoginModules can be created as EJB3 beans and hotdeployed I am not actually 100% sure, but a posibility could be for your LoginModule to delegate validation to a @Stateless bean which then accesses the entity manager.

          • 2. Re: Own LoginModule access to Entity Bean via @Inject
            Darko Krizic Newbie

            Hi Khan,

            I found a solution that is not very elegant but works!

            My CustomLoginModule is a @Management @Service and therefore
            @Inject-ion works and the create()-Method is executed upon startup. There i take the successfully injected EntityManager and put it in a static member where each instance of the Login Module is able to access it.

            As I said: Not beauty, but works.

            ...darko