4 Replies Latest reply on Sep 3, 2008 8:31 AM by joe Koch

    Inject a POJO

    joe Koch Newbie


      we are running a nice application with seam :-)

      no we like to inject a pojo. this class is in a jar that is in the classpath. we do not want this to be annotated as ejb or a seam component.

      i try use @In but it was always null.

      i guess i have to declare it in a config file. but i do not know where.

      thx :-)

        • 1. Re: Inject a POJO
          Mikael Andersson Master


          Is the pojo annotated with Seam annotations?
          If it is there a seam.properties file in there so that it is scanned by Seam at startup?

          If the pojo is discovered as a Seam component you should be able to see this in the log when the server starts up.

          If not you could define the pojo as a bean in components.xml or in Spring or perhaps via faces-config.xml.

          - micke

          • 2. Re: Inject a POJO
            Rene Felgenträger Newbie

            Seam can only inject/outject ejbs and pojos which are manageable and regocnized at startup of the web app.
            There are two (or even more ways) to inform seam about these manageable objects:

            • annotations

            • components.xml

            u have to use components.xml, if u cannot or do not want to recompile (using name-annotations) the target-class itself


            <component name="someName" class="FULL_QUALIFIED_NAME_OF_THE_CLASS_U_WANT_TO_MAKE_MANAGABLE" auto-create="true" scope="EVENT" >

            • 3. Re: Inject a POJO
              joe Koch Newbie

              thanks a lot that was what i looking for. i will test it and give you feedback. :-)

              • 4. Re: Inject a POJO
                joe Koch Newbie


                thanks this works well in a normal bean. thanks a lot for you help.

                now i like to use this bean the authenticator

                every thing work well except of the injection of the ldapServiceAuthenticate

                i did the following entry's in the components.xml:

                <security:identity authenticate-method="#{authenticator.authenticate}"/>
                <component name="ldapServiceAuthenticate" class="com.xxx.ldap.LdapServiceAuthenticate" auto-create="true" scope="application">

                in my beans i use the following:

                private LdapServiceAuthenticate ldapServiceAuthenticate; 

                - in a normal bean i get the ldapServiceAuthenticate injected :-)

                - in my authenticator i let inject the LDAPService (work well), that get the ldapServiceAuthenticate injectet that is always null.

                other things work well when we like that to be injected:

                public class Authenticator implements IAuthenticator {
                        Identity identity; 
                        @Out(required = false, scope = SESSION)
                        private User user;
                        private IConfigurationDAO configDAO;
                        private IUserDAO userDAO;
                        private ILDAPService ldapService;
                        private FacesMessages facesMessages;

                public class LDAPService implements ILDAPService {
                        private LdapServiceAuthenticate ldapServiceAuthenticate; 

                that works well:

                public class ProductCreationController implements IProductCreationController {
                        private FacesMessages facesMessages;
                        private LdapServiceAuthenticate ldapServiceAuthenticate; 

                may someone has a clue why i can't inject something in the Authenticator or better in the LDAPService

                best regards