CMP2.x table name ignored in jbosscmp-jdbc.xml
ksimeon2000 Dec 1, 2002 12:17 PMI am trying to get one of the JBoss examples (CDBean) to work with CMP2.x (by default they use CMP1.x). Specifically I want the bean to use a table name different from the name of the bean.
The jbosscmp-jdbc.xml file seems to be getting ignored (it doesn't use the table name specified). Both ejb-jar.xml and jbosscmp-jdbc.xml files are listed out at the end of this message.
When I deploy the bean, I get the following message on the jboss console :
[JBoss] 23:34:02,576 INFO [EJBDeployer]
[JBoss] Bean : CDBean
[JBoss] Method : public abstract Collection findByType(String) throws
RemoteException, FinderException
[JBoss] Section: 10.5.6
[JBoss] Warning: Every finder method except findByPrimaryKey(key) must be associated with a query element in the deployment descriptor.
[JBoss] 23:34:02,600 INFO [EjbModule] Creating
[JBoss] 23:34:02,635 INFO [EjbModule] Deploying CDBean
[JBoss] 23:34:02,901 INFO [EjbModule] Deploying CDCollectionBean
[JBoss] 23:34:04,358 INFO [JDBCInitCommand] Created table 'CDBean' successfully.
[JBoss] 23:34:04,371 INFO [EjbModule] Created
[JBoss] 23:34:04,372 INFO [EjbModule] Starting
[JBoss] 23:34:04,454 INFO [EjbModule] Started
The message is labeled as a *WARNNG*, not a fatal deployment error. I have defined query elements for all finder methods, except findByPrimaryKey (as stated in the warning message).
JBoss *appears* to ignore everything in jbosscmp-jdbc.xml and proceed. For example, it uses a different tablename (same name as the bean - CDBean). The deployment is successfull (I can talk to the bean) but it is using the wrong table name (should be CDBeanTable per my jbosscmp-jdbc.xml file, not CDBean).
Perhaps someone can help with my questions :
- Is the jbosscmp-jdbc.xml file required for CMP2.x? Every CMP 2.x example I have seen includes this file.
- Does the jbosscmp-jdbc.xml file go under META-INF dir of the bean jar? This is where I put it.
- Do the elements go in ejb-jar.xml, or jbosscmp-jdbc.xml? They are shown in both DTD's.
- Is there something wrong with the element structure & content in my jbosscmp-jdbc.xml file? I followed the DTD for this file as best as I could.
Thanks in advance,
Keith
Here is the jbosscmp-jdbc.xml file for this bean :
=== Start jbosscmp-jdbc.xml ===
<?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>
<create-table>true</create-table>
<remove-table>true</remove-table>
<enterprise-beans>
<ejb-name>CD</ejb-name>
<table-name>CDBeanTable</table-name>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
</cmp-field>
<cmp-field>
<field-name>title</field-name>
<column-name>title</column-name>
</cmp-field>
<cmp-field>
<field-name>artist</field-name>
<column-name>artist</column-name>
</cmp-field>
<cmp-field>
<field-name>type</field-name>
<column-name>type</column-name>
</cmp-field>
<cmp-field>
<field-name>notes</field-name>
<column-name>notes</column-name>
</cmp-field>
<query-method>
<method-name>findByType</method-name>
<method-params/>
</query-method>
<ejb-ql><![CDATA[ SELECT OBJECT(l) FROM cdbean l WHERE
l.type=?1 ]]>
</ejb-ql>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>
<![CDATA[ SELECT OBJECT(l) FROM cdbean l ]]>
</ejb-ql>
</enterprise-beans>
</jbosscmp-jdbc>
=== End jbosscmp-jdbc.xml ===
Here is my ejb-jar.xml file for this bean :
=== Start 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>MusicCDs</display-name>
<enterprise-beans>
Models a music CD
<ejb-name>CDBean</ejb-name>
org.jboss.docs.cmp.cd.interfaces.CDHome
org.jboss.docs.cmp.cd.interfaces.CD
<ejb-class>org.jboss.docs.cmp.cd.bean.CDBean</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>CDBean</abstract-schema-name>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>title</field-name></cmp-field>
<cmp-field><field-name>artist</field-name></cmp-field>
<cmp-field><field-name>type</field-name></cmp-field>
<cmp-field><field-name>notes</field-name></cmp-field>
<primkey-field>id</primkey-field>
<query-method>
<method-name>findByType</method-name>
<method-params/>
</query-method>
<ejb-ql>
<![CDATA[ SELECT OBJECT(l) FROM cdbean l WHERE l.type=?1 ]]>
</ejb-ql>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>
<![CDATA[ SELECT OBJECT(l) FROM cdbean l ]]>
</ejb-ql>
Models a music CD collection
<ejb-name>CDCollectionBean</ejb-name>
org.jboss.docs.cmp.cd.interfaces.CDCollectionHome
org.jboss.docs.cmp.cd.interfaces.CDCollection
<ejb-class>org.jboss.docs.cmp.cd.bean.CDCollectionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/CD</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
org.jboss.docs.cmp.cd.interfaces.CDHome
org.jboss.docs.cmp.cd.interfaces.CD
<ejb-link>CDBean</ejb-link>
</ejb-ref>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>CDBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
=== End ejb-jar.xml ===