0 Replies Latest reply on Apr 10, 2003 4:41 AM by freiburg

    CMP problem - Error in the deployment fase

    freiburg Newbie

      I have this problem. When I make the deploy I have an error message as

      "java.lang.StringIndexOutOfBoundsException: String index out of range: 0"

      I think that the mistake is in the descriptor when I use the tag <method param> and put inside that java.lang.String.
      But I don't know why. What do you think about?
      Thank you very much for helping me!
      Andrea

      This is the local interface:

      package com.sdb.stage.ejb;

      import java.rmi.RemoteException;
      import javax.ejb.EJBLocalObject;


      public interface Cliente extends EJBLocalObject {

      public Integer getCodice();

      public void setCodice(Integer codice);

      public String getNome();

      public void setNome(String nome);

      public String getPiva();

      public void setPiva(String piva);

      }


      This is the LocalHome Interface

      package com.sdb.stage.ejb;


      import javax.ejb.EJBLocalHome;
      import javax.ejb.CreateException;
      import javax.ejb.FinderException;
      import java.util.Collection;


      public interface ClienteHome extends EJBLocalHome {

      public Cliente create(Integer codice, String nome, String piva) throws CreateException;

      public Cliente findByPrimaryKey(Integer codice)
      throws FinderException;

      public Collection findByName(String nome)
      throws FinderException;

      public Collection findByPiva(String piva)
      throws FinderException;

      public Collection findAll()
      throws FinderException;

      }


      This is the Bean:

      package com.sdb.stage.ejb;

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

      public abstract class ClienteBean implements EntityBean {

      private EntityContext context;

      // Metodi di accesso per la persistenza

      public abstract Integer getCodice();
      public abstract void setCodice(Integer codice);

      public abstract String getNome();
      public abstract void setNome(String nome);

      public abstract String getPiva();
      public abstract void setPiva(String piva);


      // Metodi specifici dell'entity bean

      public Integer ejbCreate (Integer codice, String nome, String piva)
      throws CreateException {

      setCodice(codice);
      setNome(nome);
      setPiva(piva);
      return null;
      }

      public void ejbPostCreate (Integer codice, String nome, String piva)
      throws CreateException {}

      // EJB callbacks
      public void setEntityContext(EntityContext ctx) {
      context = ctx;
      }


      public void unsetEntityContext() {
      context = null;
      }

      public void ejbActivate() { }
      public void ejbPassivate() { }
      public void ejbLoad() { }
      public void ejbStore() { }
      public void ejbRemove() { }


      }

      This is the Deployment Descriptor

      <?xml version="1.0" encoding="UTF-8"?>
      <!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 >

      Cliente
      <display-name>Generated by Freiburg</display-name>


      <enterprise-beans>

      <!-- Entity Beans -->



      <display-name>Cliente entity bean</display-name>

      <ejb-name>ClienteEJB</ejb-name>

      <local-home>com.sdb.stage.ejb.ClienteHome</local-home>
      com.sdb.stage.ejb.Cliente
      <ejb-class>com.sdb.stage.ejb.ClienteBean</ejb-class>

      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>cli</abstract-schema-name>
      <cmp-field >
      <field-name>codice</field-name>
      </cmp-field>
      <cmp-field >
      <field-name>nome</field-name>
      </cmp-field>
      <cmp-field >
      <field-name>piva</field-name>
      </cmp-field>

      <primkey-field>codice</primkey-field>


      <query-method>
      <method-name>findByName</method-name>
      <method-params><method-param>java.lang.String</method-param></method-params>
      </query-method>
      <ejb-ql><![CDATA[
      SELECT OBJECT(g)
      FROM cli AS g
      WHERE g.nome = ?1
      ]]></ejb-ql>



      <query-method>
      <method-name>findByPiva</method-name>
      <method-params><method-param>java.lang.String</method-param></method-params>
      </query-method>
      <ejb-ql><![CDATA[
      SELECT DISTINCT OBJECT(g)
      FROM cli AS g
      WHERE g.piva = ?1
      ]]></ejb-ql>



      <query-method>
      <method-name>findAll</method-name>
      <method-params><method-param></method-param></method-params>
      </query-method>
      <ejb-ql><![CDATA[
      SELECT OBJECT(g)
      FROM ClienteEJB g
      ]]></ejb-ql>



      </enterprise-beans>

      <assembly-descriptor></assembly-descriptor>
      </ejb-jar>