0 Replies Latest reply on Aug 9, 2005 3:09 PM by Chris Mc

    Useless error when deploying ejbSelect code... please help!

    Chris Mc Newbie

      I have:
      JBoss 4.0.2
      PostgreSQL 8.0
      RedHat Fedora Core 3

      I have a very straight-forward project which needs to use a couple of ejbSelect queries using EntityBeans as method-params... However doing this causes a NullPointerException. If I take out these two particular ejbSelect methods, the project deploys OK, so I know that it must be these issue. Please help, I don't know what to do about this! Thanks for looking!

      The ejbSelect statements are:

      <query>
       <query-method>
       <method-name>ejbSelectUnique</method-name>
       <method-params>
       <method-param>com.flytrading.trading.ejb.OptimizationLocal</method-param>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       SELECT OBJECT(odp) FROM OptimizationDynamicParameter AS odp
       WHERE odp.optimization = ?1 AND odp.parameterName = ?2
       </ejb-ql>
      </query>


      and

      <query>
       <query-method>
       <method-name>ejbSelectUnique</method-name>
       <method-params>
       <method-param>com.flytrading.trading.ejb.OptimizationLocal</method-param>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       SELECT OBJECT(osp) FROM OptimizationStaticParameter AS osp
       WHERE osp.optimization = ?1 AND osp.parameterName = ?2
       </ejb-ql>
      </query>



      The deployment error I get is:
      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT OBJECT(osp) FROM OptimizationStaticParameter AS osp
       WHERE osp.optimization = ?1 AND osp.parameterName = ?2'; - nested throwable: (java.lang.NullPointerException)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.<init>(JDBCEJBQLQuery.java:52)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:60)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:272)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDBCStoreManager.java:490)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:381)
       at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:157)
       at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:340)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
       at ...
       ...
       ... and so on
      
      





      and the ejb-jar for the EntityBeans are:

      <ejb-jar
       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/ejb-jar_2_1.xsd"
       version="2.1">
       <enterprise-beans>
       <entity>
       <ejb-name>OptimizationEJB</ejb-name>
       <home>com.flytrading.trading.ejb.OptimizationHomeRemote</home>
       <remote>com.flytrading.trading.ejb.OptimizationRemote</remote>
       <local-home>com.flytrading.trading.ejb.OptimizationHomeLocal</local-home>
       <local>com.flytrading.trading.ejb.OptimizationLocal</local>
       <ejb-class>com.flytrading.trading.ejb.OptimizationBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Object</prim-key-class>
       <reentrant>False</reentrant>
       <abstract-schema-name>Optimization</abstract-schema-name>
       <cmp-field><field-name>name</field-name></cmp-field>
       <cmp-field><field-name>timestamp</field-name></cmp-field>
       <cmp-field><field-name>basket</field-name></cmp-field>
       <cmp-field><field-name>parentConfiguration</field-name></cmp-field>
       <cmp-field><field-name>comment</field-name></cmp-field>
       <security-identity><use-caller-identity/></security-identity>
       <query>
       <query-method>
       <method-name>findByName</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       SELECT OBJECT(opt) FROM Optimization AS opt
       WHERE opt.name = ?1
       </ejb-ql>
       </query>
       </entity>
      
       <entity>
       <ejb-name>OptimizationDynamicParameterEJB</ejb-name>
       <local-home>com.flytrading.trading.ejb.OptimizationDynamicParameterHomeLocal</local-home>
       <local>com.flytrading.trading.ejb.OptimizationDynamicParameterLocal</local>
       <ejb-class>com.flytrading.trading.ejb.OptimizationDynamicParameterBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Object</prim-key-class>
       <reentrant>False</reentrant>
       <abstract-schema-name>OptimizationDynamicParameter</abstract-schema-name>
       <cmp-field><field-name>optimization</field-name></cmp-field>
       <cmp-field><field-name>parameterName</field-name></cmp-field>
       <cmp-field><field-name>startValue</field-name></cmp-field>
       <cmp-field><field-name>stopValue</field-name></cmp-field>
       <cmp-field><field-name>stepSize</field-name></cmp-field>
       <security-identity><use-caller-identity/></security-identity>
       <query>
       <query-method>
       <method-name>ejbSelectUnique</method-name>
       <method-params>
       <method-param>com.flytrading.trading.ejb.OptimizationLocal</method-param>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       SELECT OBJECT(odp) FROM OptimizationDynamicParameter AS odp
       WHERE odp.optimization = ?1 AND odp.parameterName = ?2
       </ejb-ql>
       </query>
       </entity>
       <entity>
       <ejb-name>OptimizationStaticParameterEJB</ejb-name>
       <local-home>com.flytrading.trading.ejb.OptimizationStaticParameterHomeLocal</local-home>
       <local>com.flytrading.trading.ejb.OptimizationStaticParameterLocal</local>
       <ejb-class>com.flytrading.trading.ejb.OptimizationStaticParameterBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Object</prim-key-class>
       <reentrant>False</reentrant>
       <abstract-schema-name>OptimizationStaticParameter</abstract-schema-name>
       <cmp-field><field-name>parameterName</field-name></cmp-field>
       <cmp-field><field-name>value</field-name></cmp-field>
       <cmp-field><field-name>optimization</field-name></cmp-field>
       <security-identity><use-caller-identity/></security-identity>
       <query>
       <query-method>
       <method-name>ejbSelectUnique</method-name>
       <method-params>
       <method-param>com.flytrading.trading.ejb.OptimizationLocal</method-param>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>
       SELECT OBJECT(osp) FROM OptimizationStaticParameter AS osp
       WHERE osp.optimization = ?1 AND osp.parameterName = ?2
       </ejb-ql>
       </query>
       </entity>
      
       <!-- ... -->
      
       </enterprise-beans>
      <!-- ... -->
      
      </ejb-jar>
      



      and, if it matters, here is the jbosscmp-jdbc.xml

      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:/PostgresDS</datasource>
       <create-table>true</create-table>
       <remove-table>false</remove-table>
       <pk-constraint>true</pk-constraint>
       <fk-constraint>false</fk-constraint>
       <unknown-pk>
       <unknown-pk-class>java.lang.Integer</unknown-pk-class>
       <jdbc-type>INTEGER</jdbc-type>
       <sql-type>SERIAL</sql-type>
       <auto-increment/>
       </unknown-pk>
       </defaults>
      
      
       <entity>
       <ejb-name>OptimizationEJB</ejb-name>
       <cmp-field>
       <auto-increment/>
       </cmp-field>
       <entity-command name="postgresql-fetch-seq"/>
       </entity>
       <entity>
       <ejb-name>OptimizationDynamicParameterEJB</ejb-name>
       <cmp-field>
       <auto-increment/>
       </cmp-field>
       <entity-command name="postgresql-fetch-seq"/>
       </entity>
       <entity>
       <ejb-name>OptimizationStaticParameterEJB</ejb-name>
       <cmp-field>
       <auto-increment/>
       </cmp-field>
       <entity-command name="postgresql-fetch-seq"/>
       </entity>
      
      <!-- ... -->
      
      </jbosscmp-jdbc>