facebook

SQL Cmnd Files in the Project and EJB->MySQL hookup

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #253328 Reply

    Lance Drake
    Member

    Hi MyEclipse Folks,

    Truly I have attempted to perform due-diligence and find the answers to these questions in MANY different places. However, the incantations, thus far, still elude me.

    FIRST QUESTION: Is it the general practice to cook up your own EJB-JAR.XML file and not rely on the XDoclet facility to generate the EJB-JAR.XML file? I have the ejb/jboss/web tag docs from the XDoclet site. It appears there many situations where my javadoc is simply ignored.

    (Note: I pay special attention to putting everything in the same order listed in the XDoclet tag specs, caps, punctuation, etc)

    SECOND QUESTION: Getting my EJB bean to hook up with mySQL is (in part) thwarted because the javadoc section does not end up generating a query entry in the ejb-jar.xml file. I can’t believe this is not a functional feature – so I am wondering WHAT am I doing wrong or missing?

    From the bean file – we have:

    
    /** @ejb.select
     * description="Get A Collection of all tables"
     * query="SELECT OBJECT(a) FROM TableList"
     */
    public abstract String ejbSelectFindByPrimaryKey(java.lang.String seq) throws FinderException;
     
    /** @ejb.select
     * description="Look for a table with a particular unique ID"
     * query="SELECT a.table_seq FROM TableList AS a WHERE a.table_seq = ?1"
     */
    public abstract Collection ejbSelectTableByPrimaryKey(java.lang.String seq) throws FinderException;
    
    

    In the javadoc section there is:

    /**
     * @ejb.bean name="TridentBean"
     *           description="Trident Table Entity Bean"
     *           display-name="TridentBean"
     *           jndi-name="ejb/TridentBean"
     *           type="CMP"
     *           cmp-version="2.x"
     *           view-type="local"
     *           local-jndi-name="ejb/TridentLocalHome" 
     *           abstract-schema-name="TridentList"
     *           primkey-field="table_seq" 
     *           cmp-field="table_name"
     *           cmp-field="table_type"
     *           cmp-field="table_id" 
     *           cmp-field="table_ipaddr"
     *           cmp-field="table_pit"
     *           cmp-field="table_status"
     *           cmp-field="table_serial"
     *           cmp-field="table_features"
     *           cmp-field="table_installed"
     *           cmp-field="table_txtime"
     *           cmp-field="table_heartbeat"
     *           
     * @ejb:util generate="physical"
     *
     * @ejb.pk    class="com.jcm.table.trident.interfaces.TridentPK"
     *             generate="false"
     *           
     * @ejb.persistence table-name="TridentList"
     * 
     * @jboss.persistence 
     *            datasource="java:/DefaultDS"
     *            datasource-mapping="mySQL"
     *            create-table="false"
     *            table-name="tridentList"
     *
     * @ejb.finder  
     *            description="Get ALL table items"
     *             signature="java.util.Collection Collection ejbSelectGetAllTables()"
     *            query="SELECT OBJECT(o) FROM TridentList AS o"
     *
     */
    

    (BTW – the jboss.persistence items are completely ignored. I’ve had to set them via the jboss xdoclet definitions.

    The resulting ejb-jar file then contains: (notice the empty CDATA entries)

            
           <query>
                <description><![CDATA[]]></description>
                <query-method>
                   <method-name>ejbSelectGetAllTables</method-name>
                   <method-params>
                   </method-params>
                </query-method>
               <ejb-ql><![CDATA[]]></ejb-ql>
             </query>
             <query>
                <description><![CDATA[]]></description>
                <query-method>
                   <method-name>ejbSelectFindByPrimaryKey</method-name>
                   <method-params>
                      <method-param>java.lang.String</method-param>
                   </method-params>
                </query-method>
                <ejb-ql><![CDATA[SELECT OBJECT(a) FROM TableList]]></ejb-ql>
             </query>
             <query>
                <description><![CDATA[]]></description>
                <query-method>
                   <method-name>ejbSelectTableByPrimaryKey</method-name>
                   <method-params>
                      <method-param>java.lang.String</method-param>
                   </method-params>
                </query-method>
                <ejb-ql><![CDATA[SELECT a.table_seq FROM TableList AS a WHERE a.table_seq = ?1]]></ejb-ql>
             </query>
    
    

    Then the especially exciting part comes when the EJB delpoys and JBoss reports:

    
    
    ObjectName: jboss.j2ee:service=EjbModule,module=TridentEJB.jar
      State: FAILED
      Reason: org.jboss.deployment.DeploymentException: Error while creating table trident; - nested throwable: (java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1)
    
    

    The only problem is, there IS no ‘line 1’ with “))” anywhere that I can find. The error is cryptic and I believe not a true indication of what is happening.

    So, I am wondering if I am supposed to include an SQL file as a description that gets handed to JBoss? And, if so, where do I put it and how do I identify it within the project?

    I have the connector/j package and jdbc driver installed. The mysql-ds.xml file is in there. The disconnect appears to be with the materials created and included in the EJB.jar file by way of MyEclipse.

    Any response or suggestions to this situation would be greatly appreciated.

    JBoss 4.0.4
    Java SDK 1.4.2
    Eclipse 3.1.x
    MyEclipse 4.1.x
    XDoclet 1.2.3
    MySQL 5.0.21

    #253358

    Lance Drake
    Member

    FWIW dept:
    There is some EXCELLENT documentation related to many matters of interest to J2EE developers using MyEclipse located at http://www.coredevelopers.net/library/index.jsp

    Several problems – all easily attributed to ’empty-brainitis’ with regards JBoss and EJB particulars were the cause of my woe(s).

    There were really two things that were in ill-repair. One being the syntax of the queries, the other being the references to JNDI locations for some of the objects, as well as including the javadoc references in the correct locations in the source.

    specifying details in the jboss xdoclet – that allowed for creation of:

    <jbosscmp-jdbc>
       <defaults>
         <datasource>java:/DefaultDS</datasource>
         <datasource-mapping>mySQL</datasource-mapping>
       </defaults>
       ...
    

    and details in the query strings where missing an object reference after the table name – such that…

    /** @ejb.select
     * description="Get A Collection of all tables"
     * query="SELECT OBJECT(a) FROM TableList"
     */ 

    …got revised to become…

    /** @ejb.select
     * description="Get A Collection of all tables"
     * query="SELECT OBJECT(a) FROM TableList a"
     */ 

    …as well as re-defining a target JNDI path from

    CtlHome jcmCtlHome = (CtlHome) initCtx.lookup("java:com/jcm/table/interfaces/Ctl");

    to

    CtlHome jcmCtlHome = (CtlHome) initCtx.lookup("com/jcm/table/interfaces/Ctl");

    In the words of Linda Ellerbee, “And so it goes…” I’m sure there are more chalenges that will stump me for impossibly long periods of time – but, eventually, I’ll come up to speed with the rest of you.

    Thanks!

    #253391

    Lance Drake
    Member

    If you’re creating EJB-QL:

    First: When creating a signature for an ejb.finder ref – fully define EVERYTHING such that: signature=”java.util.Collection findAllTables(com.jcm.table.trident.interfaces.TridentLocal arg0)”

    Second: Use the schema name from your ejb javadoc as the name of the table to which your are referring. This is not exactly well-spelled-out anywhere that **I** came across – as in query=”SELECT OBJECT[arg0] FROM your-abstract-schema-name arg0″ – and so on.

    Third: Do NOT do be tempted (as I was, only later to get it fixed, working and RIGHT) to render your ejb.finder queries as ejb.select references and do not create any public abstract <ejb.finder signature> references in any files – XDoclet takes care of that for you.

    Thanks to all that is good… and the authors of ‘Head First EJB’, I can now move on to actually DOING something.

    ..YEAA!.. In the words of comedian Norm Crosby, “A word to the wise should be deficient”

    #253402

    Lance Drake
    Member

    Somewhat related – regarding XDoclet BUG (key = XJD-71): Do not insert any ONE-LINE-COMMENTS inbetween JAVADOC and the subsequent item to which it refers. The two are effectively de-coupled. See “Primary Key Hassles” in this forum.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: SQL Cmnd Files in the Project and EJB->MySQL hookup

You must be logged in to post in the forum log in