Hi!

I tried out everything, but it wont work as I always get an Exception. All 
Information is provided below!

I'm working with Netbeans 5Beta. As EJB support is new, you have to do lots of 
the work by hand. I already had an application running as I mentioned that the 
automatic bean generation tool used some fioelds with index as primary keys! 
Therefore I changed it, but do not ged rid of the Exception while deploying.


Database Table (datasource works perfectly!):

  | CREATE TABLE `device_part` (
  |   `id` int(10) unsigned NOT NULL auto_increment,
  |   `device_id` int(10) unsigned NOT NULL default '0',
  |   `part_id` int(10) unsigned NOT NULL default '0',
  |   `type` varchar(6) default NULL,
  |   PRIMARY KEY  (`id`),
  |   UNIQUE KEY `device_id__part_id__type` (`device_id`,`part_id`,`type`),
  |   KEY `device_id` (`device_id`),
  |   KEY `part_id` (`part_id`)
  | ) TYPE=MyISAM COMMENT='NEW'
  | 


My ejb-jar.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";>
  |   <display-name>TestCmp-EJBModule</display-name>
  |   <enterprise-beans>
  |     <entity>
  |       <description>jdbc:mysql://localhost/ios [root on Default 
schema]</description>
  |       <display-name>DevicePartEB</display-name>
  |       <ejb-name>DevicePartBean</ejb-name>
  |       <local-home>testing.DevicePartLocalHome</local-home>
  |       <local>testing.DevicePartLocal</local>
  |       <ejb-class>testing.DevicePartBean</ejb-class>
  |       <persistence-type>Container</persistence-type>
  |       <prim-key-class>java.lang.Integer</prim-key-class>
  |       <reentrant>false</reentrant>
  |       <abstract-schema-name>DevicePart</abstract-schema-name>
  |       <cmp-field>
  |         <field-name>id</field-name>
  |       </cmp-field>
  |       <cmp-field>
  |         <field-name>deviceId</field-name>
  |       </cmp-field>
  |       <cmp-field>
  |         <field-name>partId</field-name>
  |       </cmp-field>
  |       <cmp-field>
  |         <field-name>type</field-name>
  |       </cmp-field>
  |       <!--
  |       <primkey-field>deviceId</primkey-field>
  |       -->
  |       <query>
  |         <description>auto generated method</description>
  |         <query-method>
  |           <method-name>findById</method-name>
  |           <method-params>
  |             <method-param>java.lang.Integer</method-param>
  |           </method-params>
  |         </query-method>
  |         <ejb-ql>SELECT OBJECT(d) FROM DevicePart AS d WHERE d.id = 
?1</ejb-ql>
  |       </query>
  |       <query>
  |         <description>auto generated method</description>
  |         <query-method>
  |           <method-name>findByDeviceId</method-name>
  |           <method-params>
  |             <method-param>java.lang.Integer</method-param>
  |           </method-params>
  |         </query-method>
  |         <ejb-ql>SELECT OBJECT(d) FROM DevicePart AS d WHERE d.deviceId = 
?1</ejb-ql>
  |       </query>
  |       <query>
  |         <description>auto generated method</description>
  |         <query-method>
  |           <method-name>findByPartId</method-name>
  |           <method-params>
  |             <method-param>java.lang.Integer</method-param>
  |           </method-params>
  |         </query-method>
  |         <ejb-ql>SELECT OBJECT(d) FROM DevicePart AS d WHERE d.partId = 
?1</ejb-ql>
  |       </query>
  |       <query>
  |         <description>auto generated method</description>
  |         <query-method>
  |           <method-name>findByType</method-name>
  |           <method-params>
  |             <method-param>java.lang.String</method-param>
  |           </method-params>
  |         </query-method>
  |         <ejb-ql>SELECT OBJECT(d) FROM DevicePart AS d WHERE d.type = 
?1</ejb-ql>
  |       </query>
  |     </entity>
  |   </enterprise-beans>
  |   <assembly-descriptor>
  |     <container-transaction>
  |       <method>
  |         <ejb-name>DevicePartBean</ejb-name>
  |         <method-name>*</method-name>
  |       </method>
  |       <trans-attribute>Required</trans-attribute>
  |     </container-transaction>
  |   </assembly-descriptor>
  | </ejb-jar>
  | 
  | 

The jboss.xml


  | <?xml version="1.0" encoding="UTF-8"?>
  | <jboss/>
  | 

The jbosscmp-jdbc.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN" 
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd";>
  | 
  | <jbosscmp-jdbc>
  |    <defaults>
  |      <datasource>java:/oldios</datasource>
  |      <datasource-mapping>mySQL</datasource-mapping>
  |      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
  |    </defaults>
  | 
  |    <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 <entity></entity> markup for those beans.
  |      -->
  | 
  |       <entity>
  |          <ejb-name>DevicePartBean</ejb-name>
  |          <table-name>device_part</table-name>
  |          <cmp-field>
  |             <field-name>id</field-name>
  |             <column-name>id</column-name>
  |          <auto-increment/> 
  |         </cmp-field>
  |          <cmp-field>
  |             <field-name>deviceId</field-name>
  |             <column-name>device_id</column-name>
  |         </cmp-field>
  |          <cmp-field>
  |             <field-name>partId</field-name>
  |             <column-name>part_id</column-name>
  |         </cmp-field>
  |          <cmp-field>
  |             <field-name>type</field-name>
  |             <column-name>type</column-name>
  |         </cmp-field>
  |     <!--
  |     <unknown-pk> 
  |          <unknown-pk-class>java.lang.Integer</unknown-pk-class> 
  |          <field-name>id</field-name> 
  |          <column-name>id</column-name> 
  |          <jdbc-type>INTEGER</jdbc-type> 
  |          <sql-type>INTEGER</sql-type> 
  |          <auto-increment/> 
  |     </unknown-pk>   
  |     -->
  |     
  |     <!--
  |     <unknown-pk>
  |          <unknown-pk-class>java.lang.Integer</unknown-pk-class> 
  |          <field-name>id</field-name> 
  |          <column-name>id</column-name> 
  |          <jdbc-type>INTEGER</jdbc-type> 
  |          <sql-type>INTEGER</sql-type> 
  |     <auto-increment/>
  |     </unknown-pk>
  |     -->
  |     <entity-command name="mysql-get-generated-keys">
  |     </entity-command>
  |       </entity>
  |    </enterprise-beans>
  | </jbosscmp-jdbc>
  | 
  | 


THE BEANS:
DevicePartBean

  | package testing;
  | 
  | import javax.ejb.*;
  | 
  | /**
  |  * This is the bean class for the DevicePartBean enterprise bean.
  |  * Created 10.10.2005 13:34:11
  |  * @author adminmeyer
  |  */
  | public abstract class DevicePartBean implements javax.ejb.EntityBean, 
testing.DevicePartLocalBusiness {
  |     private javax.ejb.EntityContext context;
  |     
  |     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure 
methods. Click on the + sign on the left to edit the code.">
  |     // TODO Consider creating Transfer Object to encapsulate data
  |     // TODO Review finder methods
  |     /**
  |      * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
  |      */
  |     public void setEntityContext(javax.ejb.EntityContext aContext) {
  |     context = aContext;
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#ejbActivate()
  |      */
  |     public void ejbActivate() {
  |     
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#ejbPassivate()
  |      */
  |     public void ejbPassivate() {
  |     
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#ejbRemove()
  |      */
  |     public void ejbRemove() {
  |     
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#unsetEntityContext()
  |      */
  |     public void unsetEntityContext() {
  |     context = null;
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#ejbLoad()
  |      */
  |     public void ejbLoad() {
  |     
  |     }
  |     
  |     /**
  |      * @see javax.ejb.EntityBean#ejbStore()
  |      */
  |     public void ejbStore() {
  |     
  |     }
  |     // </editor-fold>
  |     
  |     
  |     public abstract java.lang.Integer getId();
  |     public abstract void setId(java.lang.Integer id);
  |     
  |     public abstract java.lang.Integer getDeviceId();
  |     public abstract void setDeviceId(java.lang.Integer deviceId);
  |     
  |     public abstract java.lang.Integer getPartId();
  |     public abstract void setPartId(java.lang.Integer partId);
  |     
  |     public abstract java.lang.String getType();
  |     public abstract void setType(java.lang.String type);
  |     
  |     
  |     public java.lang.Object ejbCreate(java.lang.Integer id, 
java.lang.Integer deviceId, java.lang.Integer partId, java.lang.String type)  
throws javax.ejb.CreateException {
  |     //if (id == null) {
  |     //    throw new javax.ejb.CreateException("The field \"id\" must not be 
null");
  |     //}
  |     if (deviceId == null) {
  |         throw new javax.ejb.CreateException("The field \"deviceId\" must 
not be null");
  |     }
  |     if (partId == null) {
  |         throw new javax.ejb.CreateException("The field \"partId\" must not 
be null");
  |     }
  |     
  |     // TODO add additional validation code, throw CreateException if data 
is not valid
  |     setId(id);
  |     setDeviceId(deviceId);
  |     setPartId(partId);
  |     setType(type);
  |     
  |     return null;
  |     }
  |     
  |     public void ejbPostCreate(java.lang.Integer id, java.lang.Integer 
deviceId, java.lang.Integer partId, java.lang.String type) {
  |     // TODO populate relationships here if appropriate
  |     
  |     }
  | }
  | 
  | 

DevicePartLocal

  | 
  | package testing;
  | 
  | 
  | /**
  |  * This is the local interface for DevicePart enterprise bean.
  |  */
  | public interface DevicePartLocal extends javax.ejb.EJBLocalObject, 
testing.DevicePartLocalBusiness {
  |     
  |     
  | }
  | 
  | 

DevicePartLocalBusiness

  | 
  | package testing;
  | 
  | 
  | /**
  |  * This is the business interface for DevicePart enterprise bean.
  |  */
  | public interface DevicePartLocalBusiness {
  |     public abstract java.lang.Integer getId();
  | 
  |     public abstract void setId(java.lang.Integer id);
  | 
  |     public abstract java.lang.Integer getDeviceId();
  | 
  |     public abstract java.lang.Integer getPartId();
  | 
  |     public abstract void setPartId(java.lang.Integer partId);
  | 
  |     public abstract java.lang.String getType();
  | 
  |     public abstract void setType(java.lang.String type);
  |     
  | }
  | 
  | 

DevicePartLocalHome

  | 
  | package testing;
  | 
  | 
  | /**
  |  * This is the local-home interface for DevicePart enterprise bean.
  |  */
  | public interface DevicePartLocalHome extends javax.ejb.EJBLocalHome {
  |     
  |     
  |     
  |     /**
  |      *
  |      */
  |     testing.DevicePartLocal findByPrimaryKey(java.lang.Integer key)  throws 
javax.ejb.FinderException;
  | 
  |     public testing.DevicePartLocal create(java.lang.Integer id, 
java.lang.Integer deviceId, java.lang.Integer partId, java.lang.String type) 
throws javax.ejb.CreateException;
  | 
  |     java.util.Collection findById(java.lang.Integer id) throws 
javax.ejb.FinderException;
  | 
  |     java.util.Collection findByDeviceId(java.lang.Integer deviceId) throws 
javax.ejb.FinderException;
  | 
  |     java.util.Collection findByPartId(java.lang.Integer partId) throws 
javax.ejb.FinderException;
  | 
  |     java.util.Collection findByType(java.lang.String type) throws 
javax.ejb.FinderException;
  |     
  |     
  | }
  | 
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3900246#3900246

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3900246


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to