8 Replies Latest reply on May 12, 2008 12:50 PM by I need a real name

    enitiy manager

    I need a real name Newbie


      public class CompanyManager implements IFCompanyManager {
           public Company m_Company;
           public UserManager m_UserManager;
           EntityManager em;
           public CompanyManager(){
           Company company;
            * @param CompanyDetails
            * @param SuperUserName
            * @param SuperUserEmail
            * @param Login
           public Status RegisterCompany(IFCompany CompanyDetails, String SuperUserName, String SuperUserEmail, String Login){
                try {
                     System.out.println("inside reg button in manager");
                     List existing = em.createQuery("select u.companyId from Company u").getResultList();
                } catch (Exception e) {
                     System.out.println("inside catch");
                return Status.SUCCESS;

      in the above code, i am getting a nullpointer exception, where i write the query. Plz tell me where i went worn. when i execute this query in the msql query browser, its returning a result.
      plz help me with this???

        • 1. Re: enitiy manager
          Geoffrey De Smet Newbie

          EntityManager em is probably null? The createQuery method shouldn't return null.
          So that means that the em doesn't get injected during deployment, which it should if it's an EJB3 jar deployment with a META-INF/ejb-jar.xml file.

          Btw, it's very unconventional that you use a capital to start your method and parameter names: it makes your code harder to read, but it shouldn't cause any errors.

          • 2. Re: enitiy manager
            I need a real name Newbie

            Thank you a lot for the tip.

            im entirely new to this.
            here is my ejb-jar.xml.
            plz go through this and tell me if i need to change anything, inorder to make the entitymanager ready.

            <?xml version="1.0" encoding="UTF-8"?>
            <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" 
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"

            • 3. Re: enitiy manager
              Ananthan Rudran Newbie

              how is your EntityManager named in components.xml?

              • 4. Re: enitiy manager
                I need a real name Newbie

                here is my components.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <components xmlns="http://jboss.com/products/seam/components"
                                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.2.xsd 
                                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-1.2.xsd
                                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.2.xsd
                                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-1.2.xsd
                                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.2.xsd">
                   <core:init debug="true" jndi-pattern="@jndiPattern@"/>
                   <core:manager concurrent-request-timeout="500" 
                   <core:managed-persistence-context name="entityManager"
                   <core:ejb installed="@embeddedEjb@"/>
                   <drools:rule-base name="securityRules">
                   <security:identity authenticate-method="#{authenticator.authenticate}"
                   <event type="org.jboss.seam.notLoggedIn">
                       <action expression="#{redirect.captureCurrentView}"/>
                   <event type="org.jboss.seam.postAuthenticate">
                       <action expression="#{redirect.returnToCapturedView}"/>
                   <mail:mail-session host="localhost" port="2525" username="test" password="test" />
                   <!-- For use with jBPM pageflow or process management -->

                Any idea why the EntityManager is null????
                plz help .......

                • 5. Re: enitiy manager
                  fanto black Newbie

                  Sounds strange?
                  are you sure you have place the bean in ejb package?

                  • 6. Re: enitiy manager
                    I need a real name Newbie

                    Yes the bean is in ejb package itself.....

                    • 7. Re: enitiy manager
                      fanto black Newbie

                      then have you place the datasouce file in deploy directory?

                      • 8. Re: enitiy manager
                        I need a real name Newbie

                        the datasource file given below is in the deploy folder

                        <?xml version="1.0" encoding="UTF-8"?>