Error parsing ejb-ql
prafullan Oct 14, 2003 5:09 AMHello all ,
I am new to JBoss . I am trying to build a CMP entity Bean .I am using Mastering Enterprise JavaBeans book of Ed Roman ,example for it ProductBean enitity Bean with CMP . When deploying , i am getting parser error for ejb-ql syntax
<ejb-ql>
<! [CDATA[ SELECT OBJECT(a) FROM ProductBean AS a WHERE productId IS NOT NULL ]] >
</ejb-ql>
error :
--------
org.xml.sax.SaxParseException : "<!"
at org.apache.crimson.parser.Parser2.fatal() etc ...
I am using jboss-3.0.0RC1_tomcat-4.0.3 .
Can any one help me solve this problem .
Thanks
prafullan
My remote interface is :
------------------------------
public interface Product extends EJBObject
{
public void setName(String name) throws RemoteException ;
public String getName() throws RemoteException ;
public void setDescription(String desc) throws RemoteException ;
public String getDescription() throws RemoteException ;
public void setBasePrice(double price) throws RemoteException ;
public double getBasePrice() throws RemoteException ;
public String getProductId() throws RemoteException ;
}
My entity Bean issome what like shown below:
----------------------------------------------------------
public abstract class ProductBean implements EntityBean
{
private EntityContext ctxt = null ;
/* Abstract Methods */
public abstract void setProductId(String productId);
public abstract void setName(String name);
public abstract void setDescription(String desc);
public abstract void setBasePrice(double price);
public abstract String getProductId();
public abstract String getName();
public abstract String getDescription();
public abstract double getBasePrice();
public void setEntityContext(EntityContext ctxt)
{
this.ctxt = ctxt;
}
public void unsetEntityContext()
{
this.ctxt = null;
}
public ProductPK ejbCreate(String productId ,String name,String desc,double price)
throws CreateException
{
System.out.println(" CMP EntityBean ejbCreate");
setProductId(productId);
setName(name);
setDescription(desc);
setBasePrice(price);
return new ProductPK(productId);
}
// other ejb methods here .
}
ejb-jar file given below :
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/j2ee/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
My sample HelloWorld EJBforJBOSS
<display-name>Hello World EJB </display-name>
<enterprise-beans>
<ejb-name>Product</ejb-name>
com.myEjb.sample.ProductHome
com.myEjb.sample.Product
<local-home>com.myEjb.sample.ProductLocalHome</local-home>
com.myEjb.sample.ProductLocal
<ejb-class>com.myEjb.sample.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.myEjb.sample.ProductPK</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ProductBean</abstract-schema-name>
<cmp-field>
<field-name>productId</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>
<query-method>
<method-name>findAllProducts</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql>
<! [CDATA[ SELECT OBJECT(a) FROM ProductBean AS a WHERE productId IS NOT NULL ]] >
</ejb-ql>
</enterprise-beans>
</ejb-jar>
jbosscmp-jdbc.xml file is :
--------------------------------
<?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>
<enterprise-beans>
<ejb-name>Product</ejb-name>
<remove-table>product</remove-table>
<table-name>product</table-name>
<cmp-field>
<field-name>productId</field-name>
<column-name>id</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>name</column-name>
<not-null/>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>description</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(64)</sql-type>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<column-name>price</column-name>
<jdbc-type>DOUBLE</jdbc-type>
<sql-type>FLOAT</sql-type>
</cmp-field>
</enterprise-beans>
</jbosscmp-jdbc>