1 Reply Latest reply on Jan 24, 2006 11:03 PM by chaman kumar

    why MYSQL error come

    chaman kumar Newbie

      when I deploy cmp bean on jboss-3.2.2 it gives following error (I use lomboz plugins):-

      5:53:11,197 INFO [EjbModule] Deploying FirstStat
      15:53:11,728 WARN [EntityContainer] No resource manager found for jdbc/MySqlDs
      15:53:13,320 ERROR [EntityContainer] Starting failed
      org.jboss.deployment.DeploymentException: Error in jbosscmp-jdbc.xml : datasource-mapping MYSQL not found
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.(JDBCEntityMetaData.java:433)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.(JDBCApplicationMetaData.java:310)

      Note:- Stateless or stateful bean created with dao, accessing of database normally.
      ------------------------------------------
      FirstStatBean.class
      ------------------------------------------
      /*
      * Created on Jan 23, 2006
      *
      * TODO To change the template for this generated file go to
      * Window - Preferences - Java - Code Style - Code Templates
      */
      package chaman.com;

      import java.rmi.RemoteException;

      import javax.ejb.EJBException;
      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;

      /**
      *
      * <!-- begin-user-doc --> You can insert your documentation for 'FirstcmpBean'. <!-- end-user-doc --> *
      <!-- begin-lomboz-definition -->
      <?xml version="1.0" encoding="UTF-8"?>
      <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz">
      <lomboz:entity>
      <lomboz:entityEjb>
      <j2ee:display-name>Firstcmp</j2ee:display-name>
      <j2ee:ejb-name>Firstcmp</j2ee:ejb-name>
      <j2ee:ejb-class>chaman.com.FirstcmpBean</j2ee:ejb-class>
      <j2ee:persistence-type>Container</j2ee:persistence-type>
      <j2ee:prim-key-class>java.lang.Integer</j2ee:prim-key-class>
      <j2ee:cmp-version>2.x</j2ee:cmp-version>
      <j2ee:abstract-schema-name>ecr</j2ee:abstract-schema-name>
      <j2ee:primkey-field>id</j2ee:primkey-field>
      </lomboz:entityEjb>
      <lomboz:fieldMappings>
      <lomboz:fieldName>id</lomboz:fieldName>
      <lomboz:fieldType>java.lang.Integer</lomboz:fieldType>
      <lomboz:columnName>id</lomboz:columnName>
      <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
      <lomboz:sqlType>INT</lomboz:sqlType>
      <lomboz:readOnly>false</lomboz:readOnly>
      <lomboz:primaryKey>true</lomboz:primaryKey>
      </lomboz:fieldMappings>
      <lomboz:fieldMappings>
      <lomboz:fieldName>fname</lomboz:fieldName>
      <lomboz:fieldType>java.lang.String</lomboz:fieldType>
      <lomboz:columnName>fname</lomboz:columnName>
      <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
      <lomboz:sqlType>VARCHAR</lomboz:sqlType>
      <lomboz:readOnly>false</lomboz:readOnly>
      <lomboz:primaryKey>false</lomboz:primaryKey>
      </lomboz:fieldMappings>
      <lomboz:fieldMappings>
      <lomboz:fieldName>lname</lomboz:fieldName>
      <lomboz:fieldType>java.lang.String</lomboz:fieldType>
      <lomboz:columnName>lname</lomboz:columnName>
      <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
      <lomboz:sqlType>VARCHAR</lomboz:sqlType>
      <lomboz:readOnly>false</lomboz:readOnly>
      <lomboz:primaryKey>false</lomboz:primaryKey>
      </lomboz:fieldMappings>
      <lomboz:fieldMappings>
      <lomboz:fieldName>phone</lomboz:fieldName>
      <lomboz:fieldType>java.lang.String</lomboz:fieldType>
      <lomboz:columnName>phone</lomboz:columnName>
      <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
      <lomboz:sqlType>VARCHAR</lomboz:sqlType>
      <lomboz:readOnly>false</lomboz:readOnly>
      <lomboz:primaryKey>false</lomboz:primaryKey>
      </lomboz:fieldMappings>
      <lomboz:tableName>address</lomboz:tableName>
      <lomboz:dataSourceName></lomboz:dataSourceName>
      </lomboz:entity>
      </lomboz:EJB>
      <!-- end-lomboz-definition -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.bean name="Firstcmp"
      * jndi-name="Firstcmp"
      * type="CMP"
      * primkey-field="id"
      * schema="ecr"
      * cmp-version="2.x"
      * data-source=""
      *
      * @ejb.persistence
      * table-name="address"
      *
      * @ejb.finder
      * query="SELECT OBJECT(a) FROM ecr as a"
      * signature="java.util.Collection findAll()"
      *
      * @ejb.pk class="java.lang.Integer"
      * @ejb.resource-ref res-ref-name="jdbc/MySqlDs"
      * res-auth="Container"
      * @jbos.resource-ref res-ref-name="jdbc/MySqlDs"
      * jndi-name="java:/MySqlDS"
      * <!-- end-xdoclet-definition -->
      * @generated
      **/
      public abstract class FirstcmpBean implements javax.ejb.EntityBean {
      protected EntityContext eContext;

      /**
      *
      * <!-- begin-user-doc -->
      * The ejbCreate method.
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.create-method
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public java.lang.Integer ejbCreate(Integer id, String fname,String lname, String phone ) throws javax.ejb.CreateException {
      // EJB 2.0 spec says return null for CMP ejbCreate methods.
      // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
      // setMyField("Something");
      // begin-user-code
      setId(id);
      setFname(fname);
      setLname(lname);
      setPhone(phone);

      return null;
      // end-user-code
      }

      /**
      * <!-- begin-user-doc -->
      * The container invokes this method immediately after it calls ejbCreate.
      * <!-- end-user-doc -->
      *
      * @generated
      */
      public void ejbPostCreate(Integer id, String fname,String lname, String phone) throws javax.ejb.CreateException {
      // begin-user-code
      // end-user-code
      }

      /**
      *
      *
      * <!-- begin-user-doc -->
      * CMP Field id
      *
      * Returns the id
      * @return the id
      *
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="id"
      * jdbc-type="VARCHAR"
      * sql-type="INT"
      * read-only="false"
      * @ejb.pk-field
      *
      * @ejb.interface-method
      *
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract java.lang.Integer getId();

      /**
      * <!-- begin-user-doc -->
      * Sets the id
      *
      * @param java.lang.Integer the new id value
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.interface-method
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract void setId(java.lang.Integer id);

      /**
      *
      *
      * <!-- begin-user-doc -->
      * CMP Field fname
      *
      * Returns the fname
      * @return the fname
      *
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="fname"
      * jdbc-type="VARCHAR"
      * sql-type="VARCHAR"
      * read-only="false"
      *
      *
      * @ejb.interface-method
      *
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract java.lang.String getFname();

      /**
      * <!-- begin-user-doc -->
      * Sets the fname
      *
      * @param java.lang.String the new fname value
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.interface-method
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract void setFname(java.lang.String fname);

      /**
      *
      *
      * <!-- begin-user-doc -->
      * CMP Field lname
      *
      * Returns the lname
      * @return the lname
      *
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="lname"
      * jdbc-type="VARCHAR"
      * sql-type="VARCHAR"
      * read-only="false"
      *
      *
      * @ejb.interface-method
      *
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract java.lang.String getLname();

      /**
      * <!-- begin-user-doc -->
      * Sets the lname
      *
      * @param java.lang.String the new lname value
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.interface-method
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract void setLname(java.lang.String lname);

      /**
      *
      *
      * <!-- begin-user-doc -->
      * CMP Field phone
      *
      * Returns the phone
      * @return the phone
      *
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="phone"
      * jdbc-type="VARCHAR"
      * sql-type="VARCHAR"
      * read-only="false"
      *
      *
      * @ejb.interface-method
      *
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract java.lang.String getPhone();

      /**
      * <!-- begin-user-doc -->
      * Sets the phone
      *
      * @param java.lang.String the new phone value
      * <!-- end-user-doc -->
      *
      * <!-- begin-xdoclet-definition -->
      * @ejb.interface-method
      * <!-- end-xdoclet-definition -->
      * @generated
      */
      public abstract void setPhone(java.lang.String phone);

      /* (non-Javadoc)
      * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
      */
      public void setEntityContext(EntityContext arg0) throws EJBException,
      RemoteException {
      // TODO Auto-generated method stub
      this.eContext= arg0;
      }
      /* (non-Javadoc)
      * @see javax.ejb.EntityBean#unsetEntityContext()
      */
      public void unsetEntityContext() throws EJBException, RemoteException {
      // TODO Auto-generated method stub
      this.eContext=null;
      }
      }
      ---------------------------------------------------
      jbosscmp-jdbc.class
      --------------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

      <jbosscmp-jdbc>

      java:/MySqlDS
      <datasource-mapping>MYSQL</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>


      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml
      that contains the markup for those beans.
      -->


      <ejb-name>Firstcmp</ejb-name>

      <table-name>address</table-name>

      <cmp-field>
      <field-name>id</field-name>
      <column-name>id</column-name>

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>INT</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>fname</field-name>
      <column-name>fname</column-name>

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>lname</field-name>
      <column-name>lname</column-name>

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>phone</field-name>
      <column-name>phone</column-name>

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR</sql-type>

      </cmp-field>



      </enterprise-beans>

      </jbosscmp-jdbc>