8 Replies Latest reply on Nov 22, 2006 10:14 PM by pintovc

    JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Exception

    pintovc

      I have created an EJB with CMP in JBoss 3.2.5. It deploys fine. When I try to find a record in the database table it gives me a FinderException error.
      However, I am able to see the record in the table. Here is the code in the EJB.

      try{
      home.create("test","password");
      Collection col = home.findByUserName("test");
      }catch(FinderException fe){
      throw new EJBException("Cannot find user");
      }

      The database table has 3 columns: id, userName and password of type integer, varchar and varchar respectively. There is only one record in the database with field values of (1,"test", "junk")

      Here is the error trace.

      14:25:18,236 ERROR [LogInterceptor] EJBException:
      javax.ejb.EJBException: Cannot find user
      at wonomi.identityManagement.ejb.FiboBean.compute(FiboBean.java:126)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)

        • 1. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
          pintovc

          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 >

          <![CDATA[No Description.]]>
          <display-name>Generated by XDoclet</display-name>

          <enterprise-beans>

          <!-- Session Beans -->

          <![CDATA[EJB that computes Fibonacci Suite]]>
          <display-name>Fibo EJB</display-name>

          <ejb-name>Fibo</ejb-name>

          wonomi.identityManagement.interfaces.FiboHome
          wonomi.identityManagement.interfaces.Fibo
          <ejb-class>wonomi.identityManagement.ejb.FiboBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>



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

          <!-- Entity Beans -->

          <![CDATA[]]>

          <ejb-name>UserProfile</ejb-name>

          <local-home>wonomi.identityManagement.interfaces.UserProfileLocalHome</local-home>
          wonomi.identityManagement.interfaces.UserProfileLocal

          <ejb-class>wonomi.identityManagement.ejb.UserProfileBean</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          true
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>UserProfile</abstract-schema-name>
          <cmp-field >
          <![CDATA[]]>
          <field-name>id</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>userName</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>password</field-name>
          </cmp-field>
          <primkey-field>id</primkey-field>


          <query-method>
          <method-name>findAll</method-name>
          <method-params>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o]]></ejb-ql>


          <query-method>
          <method-name>findByID</method-name>
          <method-params>
          <method-param>java.lang.Integer</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o where o.id = (?1)]]></ejb-ql>


          <query-method>
          <method-name>findByUserName</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o where o.userName = (?1)]]></ejb-ql>


          <query-method>
          <method-name>findAll</method-name>
          <method-params>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[select object(o) from UserProfile o]]></ejb-ql>

          <!-- Write a file named ejb-finders-UserProfileBean.xml if you want to define extra finders. -->


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

          <!-- Message Driven Beans -->
          <!--
          To add message driven beans that you have deployment descriptor info for, add
          a file to your XDoclet merge directory called message-driven-beans.xml that contains
          the <message-driven></message-driven> markup for those beans.
          -->

          </enterprise-beans>

          <!-- Relationships -->

          <!-- Assembly Descriptor -->
          <assembly-descriptor >
          <!--
          To add additional assembly descriptor info here, add a file to your
          XDoclet merge directory called assembly-descriptor.xml that contains
          the <assembly-descriptor></assembly-descriptor> markup.
          -->

          <!-- finder permissions -->

          <!-- finder permissions -->

          <!-- transactions -->

          <!-- finder transactions -->
          </assembly-descriptor>

          </ejb-jar>

          • 2. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
            pintovc

            I performed a "Select * from userprofile" from the MySQL query browser and it worked fine. The mysql check shows that the database is running fine. The JBoss log indicates that it is able to locate and connect to mySQL datasource.

            • 3. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
              pintovc

              So to finally help myself I downloaded the source for JBoss 3.2.5 and am tracing through it. It appears that the exception is thrown on the invocation of the findByUserName method in the TxManager class.

              I have not been able to trace further, but it bring to my attention how there can never be a dearth of documentation. And open source is just a poor step above closed source in the absence of good documentation.

              :-) Enough said lest I induce myself to start documenting the JBoss code :-)

              • 4. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
                pintovc

                Any help? :-)

                • 5. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
                  pintovc

                  Some help guys. Many thanks in advance

                  • 6. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
                    pintovc

                    An update:
                    So I figured I would try the new JBoss IDE and see if it would resolve my issues. Unfortunately I get the same error.

                    Hss anyone got the JBoss CMP to work on MySQL? IF kindly provide any help you believe may be useful

                    • 7. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
                      pintovc

                      So I finally turned on the DEBUG and here is what I got in the detailed stack trace

                      20:55:31,324 DEBUG [UserProfile#findAll] Executing SQL: SELECT t0_o.id FROM UserProfile t0_o
                      20:55:31,324 DEBUG [LocalManagedConnectionFactory] Using properties: {user=root, password=--hidden--}
                      20:55:31,809 DEBUG [UserProfile#findAll] Find failed
                      java.sql.SQLException: null, message from server: "Unknown column 't0_o.id' in 'field list'"
                      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1977)
                      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
                      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
                      at com.mysql.jdbc.Connection.execSQL(Connection.java:2236)
                      at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1555)
                      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:296)
                      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:197)
                      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:116)
                      at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.execute(JDBCFindEntitiesCommand.java:41)
                      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntities(JDBCStoreManager.java:590)
                      at org.jboss.ejb.plugins.CMPPersistenceManager.findEntities(CMPPersistenceManager.java:332)
                      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.java:322)
                      at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:626)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                      • 8. Re: JBoss 3.2.5 MySQL 4.0 finder Method gives a Finder Excep
                        pintovc

                        Well I finally figured it out. A small piece of advice for those of you trying it out, JBoss is even more picky than hibernate. Check the capitalization of your database table column names, class attribute names and the mapping between them.
                        If oyu need help you can contact me at pintovc at hotmail dot com