0 Replies Latest reply on Jan 17, 2006 5:00 AM by Prashant Tiwari

    Error in accesing CMP Bean........

    Prashant Tiwari Newbie

      Hi,
      I am developing a simple bean application. The Bean gets deployed successfully. But the problem is that when i run client against bean for inserting data in database i get following error.
      =======
      15:10:30,593 ERROR [CartMaster] Error checking if entity exists
      java.sql.SQLException: ERROR: syntax error at end of input
      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
      at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
      ........................................................
      ========

      My code for Client application is:-
      ===================
      package econify.eb;

      import java.util.Hashtable;

      import javax.transaction.UserTransaction;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.rmi.PortableRemoteObject;
      import javax.naming.*;

      public class testClient {

      private static UserTransaction utx = null;

      public static void main(String[] args) {

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL,
      "localhost:1099");
      Context initialContext=null;
      try {
      initialContext = new InitialContext(env);

      } catch (Exception e) {
      System.err.println("Cannot get initial context for JNDI: " + e);
      System.exit(2);
      }

      // We want to start transactions from client: get UserTransaction
      System.out.println("Getting a UserTransaction object from JNDI");

      try {
      utx = (UserTransaction) initialContext.lookup("UserTransaction");
      } catch (Exception e) {
      System.err.println("Cannot lookup UserTransaction: "+e);
      System.exit(2);
      }

      // Connecting to Home thru JNDI
      System.out.println("Connecting to the CDBeanHome");
      testHome home = null;
      try {
      home = (testHome)PortableRemoteObject.narrow(initialContext.lookup("ejb/testbeanHome"),
      testHome.class);
      } catch (Exception e) {
      System.err.println("Cannot lookup "+": " +e);
      System.exit(2);
      }
      // Create a first CDBean
      System.out.println("Creating a new CDBean in database");
      test a1 = null;
      try {
      System.out.print(home.getEJBMetaData().toString());
      a1 = home.create("Prashant","prashantpassword");

      System.out.println("Created cd bean successfully ......");

      } catch (Exception e) {
      System.err.println("Cannot create CDBean: " + e);
      System.exit(2);
      }
      }

      }
      ======================

      & My ejb-jar.xml file is as follows:-
      =======
      <?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>

      <![CDATA[Description for test]]>
      <display-name>Name for test</display-name>
      <ejb-name>test</ejb-name>
      econify.eb.test.testHome
      econify.eb.test.test
      <local-home>econify.eb.test.testLocalHome</local-home>
      econify.eb.test.testLocal

      <ejb-class>econify.eb.test.testCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>econify.eb.test.testPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>test</abstract-schema-name>
      <cmp-field >
      <![CDATA[]]>
      <field-name>name</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>pass</field-name>
      </cmp-field>

      </enterprise-beans>
      <assembly-descriptor >
      </assembly-descriptor>

      </ejb-jar>
      =========

      Pls help me.....
      How to solve this problem
      I am using JBOSS 4.0 app server.

      Thanx in advance,

      Prash