1 Reply Latest reply on Oct 8, 2003 6:46 PM by ranaaich

    EJB and STRUTS

    ranaaich

      Hi All,

      I have planned to develop a project on JBOSS with STRUTS. I'm using jboss-3.2.2RC4.

      While deploying the *.ear file into JBOSS default/deploy directory I'm getting error deployment error for Entity Bean.

      My JBOSS gives the following warning, and then fails to deploy the *.ear file:
      ---------------------------------------------------------------------------
      12:17:18,619 INFO [EARDeployer] Init J2EE application: file:/D:/JBOSS3.2/jboss-3.2.2RC4/server/default/deploy/po.ear
      12:17:19,440 WARN [verifier] EJB spec violation:
      Bean : EmployeeBean
      Section: 10.6.2
      Warning: The entity bean's class must implement, directly or indirectly, the javax.ejb.EntityBean interface.

      12:17:19,451 WARN [verifier] EJB spec violation:
      Bean : EmployeeBean
      Section: 10.6.2
      Warning: The entity bean class must define a public constructor that takes no arguments.

      12:17:19,461 ERROR [MainDeployer] could not create deployment: file:/D:/JBOSS3.2/jboss-3.2.2RC4/server/default/tmp/deploy/tmp4055po.ear-contents/po.jar
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:490)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:776)
      ----------------------------------------------------------------------

      The ear file contains the *.jar and *.war files.
      In the SAMS publication book STRUTS KICK START there is chapter on STRUTS + EJB. But it uses JBOSS 3.0 and thus deploys war files in TOMCAT directory and deploys the jar files in JBOSS directory.

      What we shall do in the context of JBOSS 3.2.

      I also figured out that this particular problem has nothing to do with STRUTS. I have written a client program that will run from the command line to access the EJB -- and in that case(i.e without using files that are related to STRUTS) also the *ear fails to deploy.

      Can any one point to me where I'm getting wrong?
      Thanks in advance.
      Sorry I'm unable to attach the related files ....so here are two of them:

      ejb-jar.xml
      -------------

      <?xml version="1.0"?>

      <!DOCTYPE ejb-jar PUBLIC
      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      <display-name>Purchase Order System</display-name>
      <enterprise-beans>


      <display-name>EmployeeBean</display-name>
      <ejb-name>EmployeeBean</ejb-name>

      <local-home>com.nri.po.ejb.LocalEmployeeHome</local-home>
      com.nri.po.ejb.LocalEmployee
      <ejb-class>com.nri.po.ejb.LocalEmployee</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>Employee</abstract-schema-name>

      <cmp-field>
      no description
      <field-name>firstname</field-name>
      </cmp-field>
      <cmp-field>
      no description
      <field-name>lastname</field-name>
      </cmp-field>
      <cmp-field>
      no description
      <field-name>identifier</field-name>
      </cmp-field>
      <cmp-field>
      no description
      <field-name>password</field-name>
      </cmp-field>
      <primkey-field>identifier</primkey-field>

      <security-identity>

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



      <display-name>POManagementBean</display-name>
      <ejb-name>POManagementBean</ejb-name>
      com.nri.po.ejb.POManagementHome
      com.nri.po.ejb.POManagement
      <ejb-class>com.nri.po.ejb.POManagementBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-local-ref>
      <ejb-ref-name>EmployeeHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.nri.po.ejb.LocalEmployeeHome</local-home>
      com.nri.po.ejb.LocalEmployee
      <!-- ejb-link is required by jboss for local-refs. -->
      <ejb-link>EmployeeBean</ejb-link>
      </ejb-local-ref>


      </enterprise-beans>
      .
      .
      .
      .
      EmployeeBean.java
      -----------------------------

      package com.nri.po.ejb;

      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.CreateException;


      /**
      * CMP bean for Employee record
      */
      public abstract class EmployeeBean implements EntityBean {

      /*
      * Unlike in 1.0 and 1.1, there is no need to define the context or CMP fields as attributes in 2.x
      *
      * However, we need to define the Accessor/Mutator methods for CMP fields -
      * a) These methods must be abstract, as the implementation will be provided by Container provider
      * b) Unlike the local interface, here we MUST have the setter methods also for the read-only fields.
      */

      public abstract String getFirstname();
      public abstract void setFirstname(String s);

      public abstract String getLastname();
      public abstract void setLastname(String s);

      public abstract String getIdentifier();
      public abstract void setIdentifier(String s);

      public abstract String getPassword();
      public abstract void setPassword(String s);


      //Lifecycle Methods for EJB Container

      /**
      * Associate this bean instance with a particular context.
      * Once done, we can quiery the Context for environment info via properties.
      * @param EntityContext
      */
      public void setEntityContext(EntityContext ctx) {}
      /**
      * Disassociate this bean instance with a particular context.
      */
      public void unsetEntityContext() {}

      /**
      * Called after activating this instance.
      * Placeholder - should acquire needed resource here.
      */
      public void ejbActivate() {}
      /**
      * Called before passivating this instance.
      * Placeholder - should release any acquired resources here.
      */
      public void ejbPassivate() {}

      /**
      * Save values to DB.
      * Placeholder - should do any needed pre-processing here.
      */
      public void ejbStore() {}
      /**
      * Load values from DB.
      * Placeholder - should do any needed post-processing here.
      */
      public void ejbLoad() {}

      /**
      * To create a new record.
      * We just take in the firstname, lastname, identifier and password.
      * @param String firstname
      * @param String lastname
      * @param String identifier
      * @param String password
      * @return String - must return 'null' primary key class
      * @throws CreateException
      */
      public String ejbCreate(String firstname, String lastname, String identifier, String password)
      throws CreateException {
      setFirstname(firstname);
      setLastname(lastname);
      setIdentifier(identifier);
      setPassword(password);
      return null;
      }
      /**
      * To associate the newly created record with its own EJBObject.
      * Placeholder - should do any needed post-processing here.
      * @param String firstname
      * @param String lastname
      * @param String identifier
      * @param String password
      * @throws CreateException
      */
      public void ejbPostCreate(String firstname, String lastname, String identifier, String password)
      throws CreateException {
      }
      /**
      * To delete record from DB.
      */
      public void ejbRemove() {}

      }

        • 1. Re: EJB and STRUTS
          ranaaich

          Hi All,

          Please ignore this problem statement. Infact I have solved it just now. It was nothing but a problem of wrong entry in ejb-jar.xml .

          Thanks.