findAll fails with missing expression, but ejb-ql looks OK
larry054 Jan 2, 2003 2:41 PMI am a somewhat experienced EJB programmer trying CMP for the first time. I have an existing app running smoothly with some BMP beans, so I think my configuration is OK. I took an existing BMP entity bean, converted it to CMP, and it deployed without error. I ran a simple test client which I have used before and got the attached error. Since the error message implies a faulty SQL query, I tried setting the log4j priority to TRACE but I got no additional information. I tried this with my default Oracle db and also with hsqldb; same results. There must be some simple error somewhere, but I don't see it. Source code for the EJB, client, and ant-generated ejb-jar.xml follow. Does anyone know what the problem is? Thank you very much.
I am using JBoss-3.0.4_Tomcat-4.1.12, Oracle 8.1.7, Win2K, Ant 1.5.1, Xdoclet 1.2b2.
Larry
=======================================================
>java -classpath classes;f:\jboss-3.0.4_tomcat-4.1.12\client\jbossall-client.jar;f:\jboss-3.0.4_t
omcat-4.1.12\client\jboss-j2ee.jar;f:\jboss-3.0.4_tomcat-4.1.12\client\log4j.jar EPClient
Caught an exception.
javax.ejb.FinderException: Find failed: java.sql.SQLException: ORA-00936: missing expression
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:148)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.execute(JDBCFindEntitiesCommand.java:40)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntities(JDBCStoreManager.java:549)
at org.jboss.ejb.plugins.CMPPersistenceManager.findEntities(CMPPersistenceManager.java:348)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.jav
a:323)
at org.jboss.ejb.EntityContainer.find(EntityContainer.java:665)
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.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1119)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:206)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:
215)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:90)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:151)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:138)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
at $Proxy0.findAll(Unknown Source)
at EPClient.main(EPClient.java:35)
=======================================================
package com.entymology;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
/**
* @ejb.bean
* name="EportfolioBean"
* type="CMP"
* jndi-name="EportfolioBean"
* cmp-version="2.x"
* view-type="both"
* @ejb.transaction-type type="Container"
* @ejb.transaction type="Required"
* @ejb.pk class="java.lang.String" generate="false"
* @ejb:home remote-class="com.entymology.EportfolioHome"
* local-class="com.entymology.EportfolioLocalHome"
* @ejb:interface remote-class="com.entymology.Eportfolio"
* local-class="com.entymology.EportfolioLocal"
* @ejb.ejb-ref
* ejb-name="EportfolioBean"
* ref-name="EportfolioBean"
* @ejb.persistence
* table-name="jportfolio"
* @jboss.persistence
* datasource="java:/OracleDS"
* datasource-mapping="Oracle8"
* @jboss:container-configuration
* name="Standard CMP 2.x EntityBean"
* @ejb.finder
* signature="java.util.Collection findAll()"
* query="SELECT Object(o) FROM EportfolioBean AS o"
* transaction-type="NotSupported"
* unchecked="true"
*/
public abstract class JportfolioEJB implements EntityBean {
protected EntityContext entityContext = null;
/**
*
* @ejb.pk-field
* @ejb.persistent-field
* @ejb.persistence
* column-name="portfolioid"
*/
public abstract String getPortfolioid();
/**
*
* @ejb.interface-method
* @ejb.transaction
* type="Supports"
* @ejb.persistent-field
* @ejb.persistence
* column-name="name"
*/
public abstract String getName();
public abstract void setName(String name);
/**
*
* @ejb.interface-method
* @ejb.transaction
* type="Supports"
* @ejb.persistent-field
* @ejb.persistence
* column-name="password"
*/
public abstract String getPassword();
public abstract void setPassword(String password);
/**
*
* @ejb.interface-method
* @ejb.transaction
* type="Supports"
* @ejb.persistent-field
* @ejb.persistence
* column-name="description"
*/
public abstract String getDescription();
public abstract void setDescription(String description);
/**
*
* @ejb.interface-method
* @ejb.transaction
* type="Supports"
* @ejb.persistent-field
* @ejb.persistence
* column-name="stockschedule"
*/
public abstract String getStockschedule();
public abstract void setStockschedule(String stockschedule);
/**
*
* @ejb.interface-method
* @ejb.transaction
* type="Supports"
* @ejb.persistent-field
* @ejb.persistence
* column-name="optionschedule"
*/
public abstract String getOptionschedule();
public abstract void setOptionschedule(String optionschedule);
public void ejbPostCreate(String portfolioid, String name,
String stockschedule, String optionschedule, String password, String description) { }
protected EntityContext getEntityContext() {
return entityContext;
}
public void setEntityContext(EntityContext entityContext) throws EJBException {
this.entityContext = entityContext;
}
public void unsetEntityContext() throws EJBException {
entityContext = null;
}
public void ejbActivate() throws EJBException { }
public void ejbPassivate() throws EJBException { }
public void ejbLoad() throws EJBException { }
public void ejbStore() throws EJBException { }
public void ejbRemove() throws RemoveException, EJBException { }
}
=======================================================
import java.io.*;
import java.util.*;
import java.sql.*;
import com.entymology.*;
import javax.naming.*;
import javax.rmi.*;
import java.text.DateFormat;
import javax.rmi.PortableRemoteObject;
public class EPClient {
public static void main(String[] args) {
try {
Properties env = new Properties();
env.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url","localhost:1099");
env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming");
Context initial = new InitialContext(env);
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL, Locale.US);
Object objref = initial.lookup("EportfolioBean");
EportfolioHome phome = (EportfolioHome)PortableRemoteObject.narrow(objref,
EportfolioHome.class);
Collection c = phome.findAll();
System.out.println("EportfolioBean returned "+c.size()+" rows.");
Iterator i=c.iterator();
while (i.hasNext()) {
Eportfolio js = (Eportfolio)i.next();
String id = (String)js.getPrimaryKey();
String name = (String)js.getName();
String description = (String)js.getDescription();
String stockschedule = (String)js.getStockschedule();
String optionschedule = (String)js.getOptionschedule();
System.out.println(id + ": " + name + ": " + description + ": " + stockschedule );
}
} catch (Exception ex) {
System.err.println("Caught an exception." );
ex.printStackTrace();
}
}
}
=======================================================
<?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 -->
<!-- Entity Beans -->
<![CDATA[]]>
<ejb-name>EportfolioBean</ejb-name>
com.entymology.EportfolioHome
com.entymology.Eportfolio
<local-home>com.entymology.EportfolioLocalHome</local-home>
com.entymology.EportfolioLocal
<ejb-class>com.entymology.EportfolioBeanCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>EportfolioBean</abstract-schema-name>
<cmp-field >
<![CDATA[]]>
<field-name>portfolioid</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>name</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>password</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>description</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>stockschedule</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>optionschedule</field-name>
</cmp-field>
<ejb-ref >
<ejb-ref-name>ejb/EportfolioBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
com.entymology.EportfolioHome
com.entymology.Eportfolio
<ejb-link>EportfolioBean</ejb-link>
</ejb-ref>
<query-method>
<method-name>findAll</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT Object(o) FROM EportfolioBean AS o]]></ejb-ql>
<!-- Write a file named ejb-finders-JportfolioEJB.xml if you want to define extra finders. -->
</enterprise-beans>
<!-- finder permissions -->
<method-permission >
<![CDATA[description not supported yet by ejbdoclet]]>
<ejb-name>EportfolioBean</ejb-name>
<method-name>findAll</method-name>
<method-params>
</method-params>
</method-permission>
<!-- transactions -->
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getDescription</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getDescription</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getName</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getName</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getOptionschedule</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getOptionschedule</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getPassword</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getPassword</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getStockschedule</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getStockschedule</method-name>
<method-params>
</method-params>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EsquoteBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>EntymologyBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<!-- finder transactions -->
<container-transaction >
<ejb-name>EportfolioBean</ejb-name>
<method-name>findAll</method-name>
<method-params>
</method-params>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>