4 Replies Latest reply on Dec 6, 2002 7:25 PM by patrik99

    Entity Bean not bound when using local interface

    patrik99

      Hello there,

      I'm using jboss-3.0.4_tomcat-4.1.12 and are trying to deploy an Entity bean with a local interface but I can't seem to get the local-jndi-name to bound.
      I have no problem using the Entity bean with it's remote interface so the problems starts when it's time to deploy it's local interface.

      Below are the deployment info I get and the xml-files I use:

      13:57:50,109 INFO [MainDeployer] Starting deployment of package: file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/testCMP.jar
      13:57:50,171 INFO [EjbModule] Creating
      13:57:50,171 INFO [EjbModule] Deploying TestCMPBean
      13:57:50,203 INFO [EjbModule] Created
      13:57:50,203 INFO [EjbModule] Starting
      13:57:50,312 INFO [TestCMPBean] Created table 'TestCMPBean' successfully.
      13:57:50,312 INFO [EjbModule] Started
      13:57:50,312 INFO [MainDeployer] Deployed package: file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/testCMP.jar
      13:57:55,328 INFO [MainDeployer] Undeploying file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/cmpTest.war
      13:57:55,328 INFO [MainDeployer] could not delete directory file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/tmp/deploy/server/default/dep
      loy/cmpTest.war/98.cmpTest.war restart will delete it
      13:57:55,328 INFO [MainDeployer] Undeployed file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/cmpTest.war
      13:57:55,328 INFO [MainDeployer] Starting deployment of package: file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/cmpTest.war
      13:57:55,359 WARN [NestedThrowable] Duplicate throwable nesting of same base type: class org.jboss.deployment.DeploymentException is assign
      able from: class org.jboss.deployment.DeploymentException
      13:57:55,359 INFO [EmbeddedCatalinaService41] deploy, ctxPath=/cmpTest, warUrl=file:/D:/jboss-3.0.4_tomcat-4.1.12/server/default/tmp/deploy
      /server/default/deploy/cmpTest.war/100.cmpTest.war
      13:57:55,359 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@ccfccd8d{ url=file
      :/D:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/cmpTest.war, deployedLastModified=1039179294031 }
      org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: ejb-local-ref: ejb/TestCMP
      LocalHome, target not found, add valid ejb-link)
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:309)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:807)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:621)

      ****************
      <web-app>

      <servlet-name>TestCMPServlet</servlet-name>
      <servlet-class>cmp.servlet.TestCMPServlet</servlet-class>
      <load-on-startup>1</load-on-startup>

      <servlet-mapping>
      <servlet-name>TestCMPServlet</servlet-name>
      <url-pattern>/TestServlet</url-pattern>
      </servlet-mapping>
      <ejb-local-ref>
      <ejb-ref-name>ejb/TestCMPLocalHome</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>cmp.slaskcmp.TestCMPLocalHome</local-home>
      cmp.slaskcmp.TestCMPLocal
      <ejb-link>testCMP.jar#TestCMPBean</ejb-link>
      </ejb-local-ref>
      <!--
      <ejb-ref>
      <ejb-ref-name>ejb/TestCMPHome</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      cmp.slaskcmp.TestCMPHome
      cmp.slaskcmp.TestCMP
      </ejb-ref>
      -->
      </web-app>
      ***************
      <jboss-web>
      <ejb-ref>
      <ejb-ref-name>ejb/TestCMPLocalHome</ejb-ref-name>
      <jndi-name>ejb/TestCMPLocalHome</jndi-name>
      </ejb-ref>
      </jboss-web>
      ***************
      <ejb-jar>
      TestCMP
      <display-name>Testing CMP</display-name>
      <enterprise-beans>

      <display-name>TestCMPBean</display-name>
      <ejb-name>TestCMPBean</ejb-name>
      cmp.slaskcmp.TestCMPHome
      cmp.slaskcmp.TestCMP
      <local-home>cmp.slaskcmp.TestCMPLocalHome</local-home>
      cmp.slaskcmp.TestCMPLocal
      <ejb-class>cmp.slaskcmp.TestCMPBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>testcmpEJB</abstract-schema-name>
      <cmp-field>
      no description
      <field-name>testCMPId</field-name>
      </cmp-field>
      <cmp-field>
      no description
      <field-name>number</field-name>
      </cmp-field>
      <cmp-field>
      no description
      <field-name>name</field-name>
      </cmp-field>
      <primkey-field>testCMPId</primkey-field>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>

      </enterprise-beans>
      </ejb-jar>
      *****************

      <enterprise-beans>

      <ejb-name>TestCMPBean</ejb-name>
      <local-jndi-name>ejb/TestCMPLocalHome</local-jndi-name>

      </enterprise-beans>

      *****************

      Does anybody know why what I do wrong?

      Best Regards
      Patrik

        • 1. Re: Entity Bean not bound when using local interface
          erik777

          The only place you define the JNDI name for a local reference is inside the definition in your ejb-jar.xml for the bean that is accessing it.

          Here is an example of a session bean that needs to use JNDI to obtain a local reference to a Sequence bean:

          <ejb-jar>
          ...

          ...
          <ejb-local-ref>
          <ejb-ref-name>OSnet/LocalSequence</ejb-ref-name>
          <ejb-ref-type>Entity</ejb-ref-type>
          net.openstandards.ejb.entity.SequenceLocal
          <local-home>net.openstandards.ejb.entity.SequenceLocalHome</local-home>
          <ejb-link>OSnet/SequenceBean</ejb-link>
          </ejb-local-ref>


          </ejb-jar>

          You need to include this reference in each bean that will use JNDI to obtain the local reference.

          You do not need the JNDI name anywhere else, so you can remove some of the definitions you defined in your previous attempts.

          • 2. Re: Entity Bean not bound when using local interface
            patrik99

            Thanks for your response Erik!

            OK, I think I've got a hold of that part, i.e. how to obtain a local bean reference from another bean.

            But I'm trying to obtain the local bean reference from a servlet. According to the web_app_2_3.dtd there is an ejb-local-ref element that should be used for this purpose. But I can't get it to work. Each time I try to use it in the web.xml, JBoss complains about target not found.
            To me it seems like the local bean interface is not available outside the ejb-jar it is defined in. But in such a case why is the above ejb-local-ref element defined in the dtd?

            Do you know how to make this work or if it is possible at all?

            Best regards
            Patrik

            • 3. Re: Entity Bean not bound when using local interface
              stevek

              I do not see your code, do you have "java:comp/env" in your lookup?

              • 4. Re: Entity Bean not bound when using local interface
                patrik99

                Yes!

                Sorry, I'm at home so I don't have the code right here but the lookup is very similar to the lookup code in the jndi part of the jboss documentation.
                So I do have "java:comp/env" in my lookup. And after that I have "ejb/'name_of_the_bean'".