6 Replies Latest reply on Oct 4, 2011 5:06 PM by subversion

    JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome

    subversion

      Hi,

      When I lookup for 2.x Entity bean in .jsp, JBoss returns remote interface instead of local.

      initialContext.lookup("java:comp/env/ejb/Faculty")
      

      But it works properly on [6.0.0.CR1 - 6.0.0.M2] and doesn't on 6.0.0.Final and 6.1.0.Final. So, I migrate from JBoss 3.2 and I don't know: is this my mistake or JBoss bug?

       

      ejb-jar.xml

      <ejb-jar>
      <enterprise-beans>
      <entity>
              <display-name>FacultyBean</display-name>
              <ejb-name>FacultyBean</ejb-name>
              <home>faculty.FacultyHome</home>
              <remote>faculty.Faculty</remote>
              <local-home>faculty.FacultyLocalHome</local-home>
              <local>faculty.FacultyLocal</local>
              <ejb-class>faculty.FacultyBean</ejb-class>
      
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.Integer</prim-key-class>
              <reentrant>False</reentrant>
              <cmp-version>2.x</cmp-version>
              <abstract-schema-name>FacultyBean</abstract-schema-name>
              <cmp-field>...</cmp-field>
              <ejb-local-ref>...</ejb-local-ref>
      </entity>
      

       

      web.xml (other file, the same JBoss instance)

      <web-app>
      <ejb-local-ref>
      <ejb-ref-name>ejb/Faculty</ejb-ref-name>
       <ejb-ref-type>Entity</ejb-ref-type>
       <local-home>faculty.FacultyLocalHome</local-home>
       <local>faculty.FacultyLocal</local>
      <ejb-link>FacultyBean</ejb-link>
      </ejb-local-ref>
      

       

       

       

       

       

        • 1. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
          jaikiran

          Looks like a bug. Can you try removing that ejb-link element in the web.xml and instead using a jboss-web.xml to point the ejb-local-ref to the jndi-name of the local interface?

          1 of 1 people found this helpful
          • 2. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
            subversion

            Thank you for reply.

            Still works in the same way: properly in 6.0...CR1 and returns remote-home in 6.1.0.

            I moved references from web.xml to the

            app.ear/web.war/WEB-INF/jboss-web.xml

            <jboss-web>

                 <ejb-local-ref>

                      ...

            • 3. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
              jaikiran

              Please post the exact configuration in that jboss-web.xml. Did you point to the jndi-name?

              • 4. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
                subversion
                <?xml version="1.0" encoding="UTF-8"?>
                <jboss-web>
                          <resource-ref>
                                    <res-ref-name>jdbc/ServerSideDataSource</res-ref-name>
                                    <res-type>javax.sql.DataSource</res-type>
                                    <jndi-name>java:/app-DataSource</jndi-name>
                          </resource-ref>
                          <ejb-local-ref>
                                    <ejb-ref-name>ejb/Faculty</ejb-ref-name>
                                    <ejb-ref-type>Entity</ejb-ref-type>
                                    <local-home>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocalHome</local-home>
                                    <local>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocal</local>
                                    <ejb-link>FacultyBean</ejb-link>
                          </ejb-local-ref>
                          <ejb-local-ref>
                               ....
                          </ejb-local-ref>
                </jboss-web>
                
                • 5. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
                  jaikiran

                  I meant, change it to:

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <jboss-web>
                            <resource-ref>
                                      <res-ref-name>jdbc/ServerSideDataSource</res-ref-name>
                                      <res-type>javax.sql.DataSource</res-type>
                                      <jndi-name>java:/app-DataSource</jndi-name>
                            </resource-ref>
                            <ejb-local-ref>
                                      <ejb-ref-name>ejb/Faculty</ejb-ref-name>
                                      <ejb-ref-type>Entity</ejb-ref-type>
                                      <local-home>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocalHome</local-home>
                                      <local>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocal</local>
                  
                                                          <!-- Remove the ejb-link and point to the jndi name of the local interface of the bean -->
                                                          <local-jndi-name>the-jndi-name</local-jndi-name>
                  
                            </ejb-local-ref>
                  ...
                  


                  • 6. Re: JBoss 6.0.0.final lookup 2.1 Entity Bean from java:comp/env returns EJBHome instead of EJBLocalHome
                    subversion

                    Yes! It works. Thank you so much. Sorry for the late reply.

                     

                    <?xml version="1.0" encoding="UTF-8"?>
                    <jboss-web>
                              <resource-ref>
                                        <res-ref-name>jdbc/ServerSideDataSource</res-ref-name>
                                        <res-type>javax.sql.DataSource</res-type>
                                        <jndi-name>java:/app-DataSource</jndi-name>
                              </resource-ref>        
                            <ejb-local-ref>
                                        <ejb-ref-name>ejb/Faculty</ejb-ref-name>
                                        <ejb-ref-type>Entity</ejb-ref-type>
                                        <local-home>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocalHome</local-home>
                                        <local>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocal</local>
                                        <local-jndi-name>com.ecwo.project2002.server.domain.localeDictionary.faculty.FacultyLocalHome</local-jndi-name>
                            </ejb-local-ref>
                    ...