I use eclipse+lomboz,When I deploy the created by jar file to jboss,there is no error,but when I run the Test class,  jboss throws an exception:

  javax.ejb.FinderException: Find failed: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'FROM product WHERE ' at line 1

But I didnot define the findByPrimaryKey() method and it is created by jboss, and the exception is really throws by that method,does some created error by xdoclet?I use xdoclet 1.1.2

 

package hust;

import javax.ejb.EntityBean;

/**
 * @ejb:bean name="Product"
 * jndi-name="jndi/ProductBean"
 * type="CMP"
 * cmp-version="2.x"
 * @jboss:table-name table-name="product"
 * @ejb:pk
 *    class="java.lang.Integer"
 *    generate="false"
 **/
public abstract class ProductBean implements EntityBean {

/**
 * @ejb:interface-method
 * tview-type="remote"
 *  @ejb:persistent-field
**/
public abstract String getName();
public abstract void setName(String pname);
/**
 * @ejb:interface-method
 * tview-type="remote"
 [EMAIL PROTECTED]:persistent-field
 [EMAIL PROTECTED]:pk-field
**/
public abstract int getId();
public abstract void setId();
}

and the test class is :public class Test {

 private hust.ProductHome getHome() throws NamingException {
  return (hust.ProductHome) getContext().lookup(
   hust.ProductHome.JNDI_NAME);
 }
 private InitialContext getContext() throws NamingException {
  Hashtable props = new Hashtable();

    props.put(
   InitialContext.INITIAL_CONTEXT_FACTORY,
   "org.jnp.interfaces.NamingContextFactory");
  props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
  InitialContext initialContext = new InitialContext(props);
  return initialContext;
 }
 public void testBean() {

  try {
   hust.Product myBean = getHome().findByPrimaryKey(new Integer(1));
            System.out.println(myBean.getName());
    } catch (RemoteException e) {
   e.printStackTrace();
  }  catch (NamingException e) {
   e.printStackTrace();
  }
  catch(Exception e){
   e.printStackTrace();
  }
 }

 public static void main(String[] args) {
  Test test = new Test();
  test.testBean();

 }
}

 

 



Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

Reply via email to