12 Replies Latest reply on Jun 26, 2003 2:51 AM by Pranav Kapil

    JBoss 3.2, CMP Entity Bean problem

    Pranav Kapil Newbie

      I have written two beans, packed them in a .jar file. But when I try to deploy that file following error is coming...
      12:38:21,237 ERROR [XmlFileLoader] XmlFileLoader: File file:/F:/jboss-3.2.0_tomc
      at-4.1.24/server/pranav/tmp/deploy/server/pranav/deploy/shoejar.jar/44.shoejar.j
      ar!/META-INF/jbosscmp-jdbc.xml process error. Line: 38. Error message: The conte
      nt of element type "entity" must match "(ejb-name,(datasource,datasource-mapping
      )?,create-table?,remove-table?,read-only?,read-time-out?,row-locking?,pk-constra
      int?,read-ahead?,list-cache-max?,fetch-size?,table-name?,cmp-field*,load-groups?
      ,eager-load-group?,lazy-load-groups?,query*,unknown-pk?,entity-command?,optimist
      ic-locking?,audit?)".
      >>>>>>>>>>>>>>>>>>>>>>
      In the META-INF I have ejb-jar.xml, jboss.xml, jws.xml and jbosscmp-jdbc.xml files...

        • 1. Re: JBoss 3.2, CMP Entity Bean problem
          Adrian Brock Master

          You haven't posted your xml.

          Most likely the order of the tags is wrong, it
          must match the dtd.

          Regards,
          Adrian

          • 2. Re: JBoss 3.2, CMP Entity Bean problem
            Pranav Kapil Newbie

            here is the content of jbosscmp-jdbc.xml file
            <?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:/DefaultDS
            <datasource-mapping>Hypersonic SQL</datasource-mapping>


            <enterprise-beans>

            <ejb-name>Shoe</ejb-name>
            <table-name>SHOE_TBL</table-name>
            <create-table>true</create-table>
            <remove-table>false</remove-table>
            <read-only>false</read-only>

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

            <cmp-field>
            <field-name>name</field-name>
            <column-name>name</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>brand</field-name>
            <column-name>brand</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>branch</field-name>
            <column-name>branch</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>quantity</field-name>
            <column-name>quantity</column-name>
            </cmp-field>

            </enterprise-beans>
            </jbosscmp-jdbc>

            Cheers

            • 3. Re: JBoss 3.2, CMP Entity Bean problem
              Adrian Brock Master

              According to the dtd <table-name> should be
              defined after <read-only> and before <cmp-field>

              Regards,
              Adrian

              • 4. Re: JBoss 3.2, CMP Entity Bean problem
                Pranav Kapil Newbie

                Now following error is coming
                org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELE
                CT Object(O) FROM SHOE_TBL O WHERE O.branch LIKE '%?1%''; - nested throwable: (o
                rg.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "SHOE_TBL" at line 1,
                column 23.
                Was expecting one of:
                "IN" ...
                <ABSTRACT_SCHEMA> ...
                )

                here is the ejb-jar.xml file
                <?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>
                <enterprise-beans>

                <!-- Session Beans -->

                <display-name>ShoeCollection</display-name>
                <ejb-name>ShoeCollection</ejb-name>
                shoecollection.ShoeCollectionHome
                shoecollection.ShoeCollection
                <ejb-class>shoecollection.ShoeCollectionBean</ejb-class>
                <session-type>Stateful</session-type>
                <transaction-type>Container</transaction-type>


                <!-- Entity Beans -->

                <display-name>Shoe</display-name>
                <ejb-name>Shoe</ejb-name>
                shoe.ShoeHome
                shoe.Shoe
                <ejb-class>shoe.ShoeBean</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>Shoe</abstract-schema-name>
                <cmp-field>
                <field-name>id</field-name>
                </cmp-field>
                <cmp-field>
                <field-name>name</field-name>
                </cmp-field>
                <cmp-field>
                <field-name>brand</field-name>
                </cmp-field>
                <cmp-field>
                <field-name>branch</field-name>
                </cmp-field>
                <cmp-field>
                <field-name>quantity</field-name>
                </cmp-field>

                <primkey-field>id</primkey-field>


                <query-method>
                <method-name>findAll</method-name>
                <method-params/>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O</ejb-ql>


                <query-method>
                <method-name>findById</method-name>
                <method-params>
                <method-param>java.lang.String</method-param>
                </method-params>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O WHERE O.id LIKE '%?1%'</ejb-ql>


                <query-method>
                <method-name>findByName</method-name>
                <method-params>
                <method-param>java.lang.String</method-param>
                </method-params>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O WHERE O.name LIKE '%?1%'</ejb-ql>


                <query-method>
                <method-name>findByBrand</method-name>
                <method-params>
                <method-param>java.lang.String</method-param>
                </method-params>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O WHERE O.brand LIKE '%?1%'</ejb-ql>


                <query-method>
                <method-name>findByBranch</method-name>
                <method-params>
                <method-param>java.lang.String</method-param>
                </method-params>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O WHERE O.branch LIKE '%?1%'</ejb-ql>


                <query-method>
                <method-name>findByQuantity</method-name>
                <method-params>
                <method-param>java.lang.String</method-param>
                </method-params>
                </query-method>
                <ejb-ql>SELECT Object(O) FROM SHOE_TBL O WHERE O.quantity LIKE '%?1%'</ejb-ql>



                </enterprise-beans>
                </ejb-jar>

                • 5. Re: JBoss 3.2, CMP Entity Bean problem
                  Dmitry Mozheyko Novice

                  in jbosscmp-jdbc.xml

                  <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

                  replace with

                  <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">

                  Good luck !!!

                  • 6. Re: JBoss 3.2, CMP Entity Bean problem
                    Pranav Kapil Newbie

                    > in jbosscmp-jdbc.xml
                    >
                    > <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD
                    > JBOSSCMP-JDBC 3.0//EN"
                    > "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
                    >
                    >
                    > replace with
                    >
                    > <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD
                    > JBOSSCMP-JDBC 3.2//EN"
                    > "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
                    >
                    >
                    > Good luck !!!

                    Actually the first problem with the element sequence, which, as Adrian pointed out, was wrong... Now I have chnaged the element sequence in the xml file and that part is OK now...
                    Please refer to my last post, I have problem in that...

                    Cheers

                    • 7. Re: JBoss 3.2, CMP Entity Bean problem
                      Adrian Brock Master

                      You cannot use like %?1% in EJBQL2.0 only
                      like %SomeConstant%

                      You can use %?1% with JBossQL

                      Regards,
                      Adrian

                      • 8. Re: JBoss 3.2, CMP Entity Bean problem
                        Pranav Kapil Newbie

                        Adrian,

                        As you suggest...I am putting it here only...

                        Actually in the ejb-jar.xml file itself, there was one error in defining the <abstract-schema-name> also, which I have changed now to SHOE_TBL.

                        Now I am using <jboss-ql> tag in the jbosscmp-jdbc.xml file to use the LIKE operator as well.

                        I just need to know what shud I do with the tags in the ejb-jar.xml file which is having the queries. I don;t want to modify the quesries in this xml file, also I can not keep them with <jboss-ql> tag, as its against the dtd.

                        Please suggest something...

                        Cheers...

                        • 9. Re: JBoss 3.2, CMP Entity Bean problem
                          Adrian Brock Master

                          JBoss ignores the query in ejb-jar.xml if there
                          is a query in jbosscmp-jdbc.xml

                          Regards,
                          Adrian

                          • 10. Re: JBoss 3.2, CMP Entity Bean problem
                            Pranav Kapil Newbie

                            Thanks a lot Adrain, now I have my queries implemented using <jboss-ql> in the jbosscmp-jdbc.xml file... In the ejb-jar.xml file I'v kept some fake queries, because the EJB loader was expecting them there as well...

                            here is a sample query

                            <query-method>
                            <method-name>findById</method-name>
                            <method-params>
                            <method-param>java.lang.String</method-param>
                            </method-params>
                            </query-method>
                            <jboss-ql>SELECT Object(O) FROM SHOE_TBL O WHERE CONCAT(O.id) = ?1</jboss-ql>


                            I am using CONCAT function to convert a numeric value into string...
                            This is giving following error message...
                            ***************88
                            org.jboss.deployment.DeploymentException: Error compiling JBossQL statement 'SEL
                            ECT Object(O) FROM SHOE_TBL O WHERE CONCAT(O.id) = ?1'; - nested throwable: (org
                            .jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.id" at line 1, colum
                            n 49.
                            Was expecting one of:
                            "CONCAT" ...
                            "SUBSTRING" ...
                            "LCASE" ...
                            "UCASE" ...
                            "(" ...
                            <STRING_LITERAL> ...
                            <STRING_VALUED_PARAMETER> ...
                            <STRING_VALUED_PATH> ...
                            )
                            **********************

                            Please have a look...

                            Cheers...

                            • 11. Re: JBoss 3.2, CMP Entity Bean problem
                              Adrian Brock Master

                              Concat takes two parameters.

                              Please do *some* investigation before posting.

                              Regards,
                              Adrian

                              • 12. Re: JBoss 3.2, CMP Entity Bean problem
                                Pranav Kapil Newbie

                                Dear Adrian thanks for your support. Finally I have dployed the ejbs successfully. Regarding the CONCAT() function, I have used it with one argument in MySql, and thats why I used it here, thinking I may work.

                                As soon as my application finishes I'll send you one copy with designs etc.

                                Cheers...