Problem deploying EJB entity bean

Hi all!
I'm trying to deploy an CMP entity bean with composite primary key.
My environment is Oracle 8i (8.1.7) on W2K Professional and I'm using JDK 1.3.1_02.
The error I get is:
Compiling Stubs...done
Generating Jar File...done
Loading EJB Jar file and Comm Stubs Jar file...done
Generating EJBHome and EJBObject on the server...
An exception occurred during code generation: null
I don't understand what am I doing wrong...
Any help will be highly appreciated.
[Could anyone point me out sample code for CMP entity beans with composite primary key?]
Apologies for the length of the POST, just trying to pass as much info as I can...
The table is the following:
CREATE TABLE GPS_HIST (
gps_date_of_fix     VARCHAR2(40) NOT NULL,
gps_time_of_fix     VARCHAR2(40) NOT NULL,
issi               NUMBER(10) NOT NULL,
gps_condition          NUMBER(5),
gps_latitude          VARCHAR2(40),
gps_longitude          VARCHAR2(40),
gps_speed_knt          NUMBER(10),
constraint gps_hist_pk primary key (gps_date_of_fix, gps_time_of_fix, issi))
TABLESPACE AVLDATA
PCTFREE 10     PCTUSED 40
INITRANS 1     MAXTRANS 255
STORAGE (
INITIAL 128K NEXT 128K PCTINCREASE 0
MINEXTENTS 1 MAXEXTENTS 4096)
NOCACHE;
The primary key class is the following:
package gps;
public class GPSEntryPK implements java.io.Serializable
     public int ISSI;
     public String gpsTimeOfFix;
     public String gpsDateOfFix;
     public GPSEntryPK() {}
     public GPSEntryPK (String gpsDateOfFix, String gpsTimeOfFix, int ISSI)
          this.gpsDateOfFix = gpsDateOfFix;
          this.gpsTimeOfFix = gpsTimeOfFix;
          this.ISSI = ISSI;
     public String getGPSDateOfFix()
          return this.gpsDateOfFix;
     public String getGPSTimeOfFix()
          return this.gpsTimeOfFix;
     public int getISSI()
          return this.ISSI;
     public boolean equals(Object obj) {
          if ((obj instanceof GPSEntryPK) &&
               (this.ISSI == ((GPSEntryPK)obj).ISSI) &&
               (this.gpsTimeOfFix.equals(((GPSEntryPK)obj).gpsTimeOfFix)) &&
               (this.gpsDateOfFix.equals(((GPSEntryPK)obj).gpsDateOfFix)))
               return true;
          return false;
     public int hashCode() {
          return (this.gpsTimeOfFix.concat(this.gpsDateOfFix)).hashCode() * this.ISSI;
The bean implemantation (part of it) is as follows:
public void setEntityContext(EntityContext ctx)
this.ctx = ctx;
Properties props = ctx.getEnvironment();
public void unsetEntityContext()
this.ctx = null;
public GPSEntryPK ejbCreate(String gpsDateOfFix, String gpsTimeOfFix, int ISSI, int gpsCondition,
String gpsLatitude, String gpsLongitude, double gpsSpeedKnt)
throws CreateException, RemoteException
try {
setGPSDateOfFix(gpsDateOfFix);
setGPSTimeOfFix(gpsTimeOfFix);
setISSI(ISSI);
setGPSCondition(gpsCondition);
setGPSLatitude(gpsLatitude);
setGPSLongitude(gpsLongitude);
setGPSSpeedKnt(gpsSpeedKnt);
} catch (java.rmi.RemoteException e) {
throw new CreateException();
return null;
public GPSEntryPK ejbFindByPrimaryKey(GPSEntryPK pk) throws RemoteException, FinderException {
return null;
public void ejbPostCreate(String gpsDateOfFix, String gpsTimeOfFix, int ISSI, int gpsCondition,
String gpsLatitude, String gpsLongitude, double gpsSpeedKnt)
     throws CreateException
// get primarykey
GPSEntryPK pk = (GPSEntryPK)ctx.getPrimaryKey();
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void ejbLoad()
// You can get to the primary key
GPSEntryPK pk = (GPSEntryPK)ctx.getPrimaryKey();
public void ejbStore(){}
The descriptors are the following:
"gpsentry.xml"
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems Inc.//DTD Enterprise JavaBeans 1.1//EN" "ejb-jar.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<description>no description</description>
<ejb-name>GPSEntry</ejb-name>
<home>gps.GPSEntryHome</home>
<remote>gps.GPSEntry</remote>
<ejb-class>gpsServer.GPSEntryBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>gps.GPSEntryPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-field><field-name>gpsDateOfFix</field-name></cmp-field>
<cmp-field><field-name>gpsTimeOfFix</field-name></cmp-field>
<cmp-field><field-name>ISSI</field-name></cmp-field>
<env-entry>
<env-entry-name>realmName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>gps.realm</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>GPSEntryBean.databaseURL</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>jdbc:oracle:kprb:</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>GPSEntryBean.JDBCDriverName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>oracle.jdbc.driver.OracleDriver</env-entry-value>
</env-entry>
</entity>
</enterprise-beans>
</ejb-jar>
"oracle_gpsentry.xml"
<?xml version="1.0"?>
<!DOCTYPE oracle-descriptor PUBLIC "-//Oracle Corporation.//DTD Oracle 1.1//EN" "oracle-ejb-jar.dtd">
<oracle-descriptor>
<mappings>
<ejb-mapping>
<ejb-name>GPSEntry</ejb-name>
<jndi-name>test/gpsentry</jndi-name>
</ejb-mapping>
</mappings>
<persistence-provider>
<description> specifies a type of persistence manager </description>
<persistence-name>psi-ri</persistence-name>
<persistence-deployer>oracle.aurora.ejb.persistence.ocmp.OcmpEntityDeployer</persistence-deployer>
</persistence-provider>
<persistence-descriptor>
<description> This specifies a particular type of persistence manager to be used for a bean. param is where you would put bean specific persistence info in the format of params. The deployment process just passes what's in the param to the persistence deployer. For the baby persistence, we do parse the persistence-mapping but for other persistence backend we don't do anything with the params </description>
<ejb-name>customerbean</ejb-name>
<persistence-name>psi-ri</persistence-name>
<psi-ri>
<schema>AVLMIS</schema>
<table>gps_hist</table>
<attr-mapping>
<field-name>gpsDateOfFix</field-name>
<column-name>gps_date_of_fix</column-name>
</attr-mapping>
<attr-mapping>
<field-name>gpsTimeOfFix</field-name>
<column-name>gps_time_of_fix</column-name>
</attr-mapping>
<attr-mapping>
<field-name>ISSI</field-name>
<column-name>issi</column-name>
</attr-mapping>
<attr-mapping>
<field-name>gpsCondition</field-name>
<column-name>gps_condition</column-name>
</attr-mapping>
<attr-mapping>
<field-name>gpsLatitude</field-name>
<column-name>gps_latitude</column-name>
</attr-mapping>
<attr-mapping>
<field-name>gpsLongitude</field-name>
<column-name>gps_longitude</column-name>
</attr-mapping>
<attr-mapping>
<field-name>gpsSpeedKnt</field-name>
<column-name>gps_speed_knt</column-name>
</attr-mapping>
</psi-ri>
</persistence-descriptor>
</oracle-descriptor>
Thanks in advance.

Hi Nikos,
I obviously don't know what your entire situation is, but you may not
be aware that Oracle's DBMS embedded EJB container does not work well,
and as a result, Oracle decided to replace it with an external EJB
container which is part of a product called "Oracle Containers for
J2EE" (otherwise known as "OC4J"). The "other" forum (the J2EE forum)
deals mainly with OC4J.
As far as I know, Oracle recommends doing your EJB related work with
OC4J and not with the embedded EJB container.
Good Luck,
Avi. That's correct
Java code, implementing data bound logic, can still run in the database as Java stored procedures/packages/functions/triggers
while J2EE componentsdeployed in middle-tier implement business logic. Java in database enable the database to be an active participant to your deployment platform
in 9iDB R2 you will even be able to call-out Web client (using HTTP Client), EJB client (using oc4jclient.jar) or Web Service client
(using SOAP libraries)
Kuassi

Similar Messages

  • Deploying CMP Entity Beans in Weblogic

    How to generate/convert the Orion xml file to Weblogic_RDBMS ?
    Thx

    petstore 1.3 will be available for the upcoming beta of weblogic 7.0...
    Andrew Sliwkowski(BEA)
    [email protected]
    "Nitin Sawant" <[email protected]> wrote in message
    news:3c04f6cd$[email protected]..
    >
    Appreciate if you can share your plans on releasing a petstore 1.3 patchfor weblogic.
    >
    >
    i am having problems deploying CMP Entity Beans in petstore 1.3 where theprimary
    key class is defined as java.lang.Object in the ejb-jar.xml descriptor(<prim-key-class>java.lang.Object</prim-key-class>).
    Does weblogic 6.1 with 1.3 features enabled support the above feature.
    Thanks,

  • Problems accessing tables in oracle database with ejb entity bean

    I have created a simple server application that uses an entity bean (version 2.0) for an existing table in oracle database, and a session bean that is used as an outside interface for performing operations on that table.
    after deploying the server and client application the client attempts to perform an operation with the session bean remote interface it obtained.
    The session bean uses a locale interface to communicate with the entity bean, but when it tries to use its methods (create, findByXXX) it always get the following Exception: java.sql.SQLException: ORA-00942: table or view does not exist.
    the table of course exists, and the username password I'm using has all the permissions needed for this table.
    note - I'm using the Forte enterprise edition 4.0 as developer tool.
    I'll be glad to get some help.
    Here is the full stack trace of the exception:
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    java.sql.SQLException: ORA-00942: table or view does not exist
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1674)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:314)
    at com.sun.ejb.persistence.SQLEngine.ejb20Finder(SQLEngine.java:226)
    at com.sun.ejb.persistence.PartitionImpl.ejbFinder(PartitionImpl.java:736)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM.ejbFindByEmail(UserInfoEJB_PM.java:393)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM_LocalHomeImpl.findByEmail(UserInfoEJB_PM_LocalHomeImpl.java:64)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:77)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:68)
    at com.cti2.telco.core.ejb.UserManagerEJB_EJBLocalObjectImpl.authenticate(UserManagerEJB_EJB
    LocalObjectImpl.java:63)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB.userLogin(TelcoFacadeEJB.java:80)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB_EJBObjectImpl.userLogin(TelcoFacadeEJB_EJBObjectImpl.java:24)
    at com.cti2.telco.core.ejb.dispatch._TelcoFacadeEJB_EJBObjectImpl_Tie._invoke(Unknown Source)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:519)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:204)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:112)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
    at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
    at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)
    ...

    Well it seems like the problems has a simple explanation. The Forte assigns a default table name (<entityName>EJBTable) when creating an entity bean from an existsing table in DB (which is not the same as the one it was created from !!!). Also, for reason unknown, when you deploy these entity beans, it doesn't even create the new table under its new name (even if instructed to).
    So using the Forte we managed to use successfuly only entity beans that were created "from scretch" (when deployed their tables are created).
    Does anyone know how to change the default name the Forte uses, and make it work properly with entity beans created from an existsing table (without going over the xml's) ?

  • I am facing a problem while deploying an Entity bean in iPlanet(sp3).I have attached the exception thrown.Why has this exception occured?

    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)

    Hi,
    I think you are trying to test the Hello world EJB example shipped with the product. As a first
    step I would recomend you to go through every line of the document on deploying this application,
    since, I too have experienced many errors while trying to deploy the sample applications, but on
    following the documentation, I subsequently overcame all the errors and have been working with the
    applications. So please follow the steps in documentation and let me know, if you still encounter any
    issues.
    Regards
    Raj
    Sandhya S wrote:
    I am facing a problem while deploying an Entity bean in iPlanet(sp3).I
    have attached the exception thrown.Why has this exception occured?
    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal
    exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at
    com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at
    com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown
    Source)
    at
    samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at
    samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at
    samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Problem in deploying CMP entity bean 2.0 in J2EE 1.4

    i am trying to deploy a cmp entity bean 2.0 using j2ee1.4 deployment tool. the bean uses sql server as the database. i have successfully created a coonection pool for sql server using j2ee admin console. the entity bean class files are successfully compiled. but while deploying the entity bean i am not able to set the database settings and jndi name for the bean. can one please guide me in the deployment steps in j2ee1.4.
    mohit

    Mohit,
    We are discussing this topic in the fourm below. I'm having the same problem so feel free to join our conversation.
    ~Howard
    http://forum.java.sun.com/thread.jsp?forum=13&thread=478054

  • Error while deploying an entity bean

    Hi,
    I am trying to deploy an entity bean in weblogic 7.0 .
    My weblogic-ejb-jar.xml has the entry as :
    <weblogic-enterprise-bean>
    <ejb-name>enroleejb.ManagedObjectImplHome</ejb-name>
    <stateless-session-descriptor>
    <pool>
    <max-beans-in-free-pool>100</max-beans-in-free-pool>
    <initial-beans-in-free-pool>0</initial-beans-in-free-pool>
    </pool>
    <stateless-clustering>
    <stateless-bean-is-clusterable>True</stateless-bean-is-clusterable>
    <stateless-bean-methods-are-idempotent>False</stateless-bean-methods-are-ide
    mpotent>
    </stateless-clustering>
    </stateless-session-descriptor>
    <transaction-descriptor>
    <trans-timeout-seconds>60</trans-timeout-seconds>
    </transaction-descriptor>
    <enable-call-by-reference>True</enable-call-by-reference>
    <jndi-name>enroleejb.ManagedObjectImplHome</jndi-name>
    </weblogic-enterprise-bean>
    When I run ejbc it gives the following error.
    [java] The file /meta-inf/weblogic-cmp-rdbms-jar.xml, specified in a
    type-storage element
    of your weblogic-ejb-jar.xml descriptor, does not exist in the jar
    file.
    [java] at
    weblogic.ejb20.persistence.PersistenceType.setTypeSpecificFile(PersistenceTy
    pe.java:475)
    [java] at
    weblogic.ejb20.persistence.PersistenceType.setupDeployer(PersistenceType.jav
    a:407)
    [java] at
    weblogic.ejb20.deployer.CMPInfoImpl.setup(CMPInfoImpl.java:114)
    [java] at
    weblogic.ejb20.ejbc.EJB20CMPCompiler.generatePersistenceSources(EJB20CMPComp
    iler.java:64)
    [java] at
    weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:223)
    [java] at
    weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:344)
    [java] at weblogic.ejbc20.runBody(ejbc20.java:470)
    [java] at weblogic.utils.compiler.Tool.run(Tool.java:126)
    [java] at weblogic.ejbc.main(ejbc.java:29)
    In the generated jar file I have meta-inf\weblogic-cmp-rdbms.jar file.
    Still it gives the error.
    What could be the problem?
    Any help would be appreciated.
    Thanks,
    Namrata

    Ejb jar file should have META-INF/weblogic-cmp-rdbms-jar.xml
    "Sarita Satoor" <[email protected]> wrote:
    Hi,
    I am trying to deploy an entity bean in weblogic 7.0 .
    My weblogic-ejb-jar.xml has the entry as :
    <weblogic-enterprise-bean>
    <ejb-name>enroleejb.ManagedObjectImplHome</ejb-name>
    <stateless-session-descriptor>
    <pool>
    <max-beans-in-free-pool>100</max-beans-in-free-pool>
    <initial-beans-in-free-pool>0</initial-beans-in-free-pool>
    </pool>
    <stateless-clustering>
    <stateless-bean-is-clusterable>True</stateless-bean-is-clusterable>
    <stateless-bean-methods-are-idempotent>False</stateless-bean-methods-are-ide
    mpotent>
    </stateless-clustering>
    </stateless-session-descriptor>
    <transaction-descriptor>
    <trans-timeout-seconds>60</trans-timeout-seconds>
    </transaction-descriptor>
    <enable-call-by-reference>True</enable-call-by-reference>
    <jndi-name>enroleejb.ManagedObjectImplHome</jndi-name>
    </weblogic-enterprise-bean>
    When I run ejbc it gives the following error.
    [java] The file /meta-inf/weblogic-cmp-rdbms-jar.xml, specified
    in a
    type-storage element
    of your weblogic-ejb-jar.xml descriptor, does not exist in the jar
    file.
    [java] at
    weblogic.ejb20.persistence.PersistenceType.setTypeSpecificFile(PersistenceTy
    pe.java:475)
    [java] at
    weblogic.ejb20.persistence.PersistenceType.setupDeployer(PersistenceType.jav
    a:407)
    [java] at
    weblogic.ejb20.deployer.CMPInfoImpl.setup(CMPInfoImpl.java:114)
    [java] at
    weblogic.ejb20.ejbc.EJB20CMPCompiler.generatePersistenceSources(EJB20CMPComp
    iler.java:64)
    [java] at
    weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:223)
    [java] at
    weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:344)
    [java] at weblogic.ejbc20.runBody(ejbc20.java:470)
    [java] at weblogic.utils.compiler.Tool.run(Tool.java:126)
    [java] at weblogic.ejbc.main(ejbc.java:29)
    In the generated jar file I have meta-inf\weblogic-cmp-rdbms.jar file.
    Still it gives the error.
    What could be the problem?
    Any help would be appreciated.
    Thanks,
    Namrata

  • SOS problem using one Entity bean for editing records. please help me

    Hello
    I have one great problem using one entity bean 2.1 and i am working with this problem several days and i dont solve it.
    i am using this jb 2.1 for add new records to one oracle database and for editing records.
    I have one great problem for editing records
    I have one objets that is as one of my database table. (PersonaObj.java)
         //personaObj.java
         public class PersonaObj implements Serializable{
              private Integer id_persona; //this ishte database table autonumeric
              private java.lang.String nombre;
              now the set/get methods.
         One field of this objets (bean) is the primary key of the table, and this field is one part of the pk from the entity bean.
         From one session bean i call the entity bena passing the objet
         into the entity bean (interface) i have one methods:
              public getPersona getT56aaat04();
         public void setPersona(PersonaObj obj);
         into the entitybean bean i have:
         public PersonaEntityPK ejbCreate(PersonaObj obj) throws CreateException {
              this.setT56aaat04(obj);
              public abstract Integer getId_persona();
         public abstract void setId_persona(Integer Id_persona);
         public abstract java.lang.String getNombre();
         public abstract void setNombre(java.lang.String Nombre);
         public PersonaObj getPersona() {
              PersonaObj obj = new PersonaObj();
              obj.setId_persona(getId_persona());
              obj.setNombre(getNombre());
              return obj;
         public void setPersona(PersonaObj obj) {
              setId_persona(obj.getId_persona());
              setNombre(obj.getNombre());
    But i have one graet problem.
    adding new record to the database i runs well but if i want to edit one recor appears this error:
    => Error <=
    java.rmi.RemoteException: EJB Exception: ; nested exception is: javax.ejb.EJBException: EJB Exception: : java.lang.IllegalStateException:[EJB:010144]The setXXX method for a primary key field may only be called during ejbCreate.
    at PersonasEJB_a43o8n__WebLogic_CMP_RDBMS.setId_persona(PersonasEntityEJB_a43o8n__WebLogic_CMP_RDBMS.java:328)
    at PersonasEntityBean.setPersona(PersonasEntityBean.java:114)
    at PersonasEntityEJB_a43o8n_ELOImpl.setPersona(PersonasEntityEJB_a43o8n_ELOImpl.java:45)
    at PersonasSessionBean.editarPersona(PersonasSessionBean.java:849)
    at PersonasSessionBean_bszo9t_EOImpl.editarPersona(PersonasSessionBean_bszo9t_EOImpl.java:208)
    at PersonasSessionBean_bszo9t_EOImpl_WLSkel.invoke(Unknown Source)
    into the session bean i make this (the session recibes one PersonaObj obj):
    T56aContactosEntityLocal personaLocal ;
                   try {
                        personaLocal = personaHome.findByPrimaryKey(new T56aContactosEntityPK(obj.getId_a04()));
                        T56aaat04Obj objTmp = new T56aaat04Obj();
                        objTmp.setAp1_a04(obj.getAp1_a04());
                        objTmp.setEstado_a04("false");
                        personaLocal.setT56aaat04(obj);
    Please can you help me to solve this problem?

    Hello Werner,
    The mappings seem to be alright at a first glance.
    Have you tried out un- and redeploying your application? Sometimes values appear to be cached in the server. So if you have deployed the application before you entered DB_BANK as alias this might solve the problem...
    BR
    Daniel

  • EJB entity beans and BC4J

    I have looked at BC4J and it looks good. Buy my question is that isn't this frame work in direct conflict with EJB entity beans. I know lot of stuff that is there in BC4J should have been in EJB enitiy beans, but as a developer why should I go with BC4J and not the standard EJB stuff considering the fact that BC4J is properietery to Oracle?Any thoughts?

    Vimal,
    Without going into exhaustive detail here, I would like to recommend that you take a look at the BC4J Technical White Paper available from the JDeveloper page on OTN (in the 3.0 Technical Information section):
    http://technet.oracle.com/products/jdev/info/techwp20/wp.html
    Amoung other things to note, BC4J is based on pure Java, and is what we consider a 'white box', meaning, you as a developer have complete control over what is going on. You can extend any of the code generated to customize it.
    Primarily though, the major benefit of BC4J is that we have taken care of most of the complicated communication code for you. Communication between the client and the data server, transaction handling, row locking, etc are already written for you. You just use, extend, customize what we have provided.
    In addition, BC4J allows you flexibility in your deployment environment decision. Regardless of where and how you deploy your BC4J Application Module, the client is unchanged.
    Those are the key advantages. Again, for more details, I would take a look at the white paper to see if it more fully addresses your questions.

  • How to delete a database record by using EJB entity beans

    Hi, All,
    Does anyone know how to use entity bean to delete a database record? I have all the EJB entity beans created, including access beans to each. I can successfully create records, find and update records, however, I haven't find a way to delete records yet.
    Your response is appreciated.
    Cathy

    Please see EJB Forums for continue discussion on this subject.
    Reference titile: "how to delete database record by using CMP entity beans "

  • Are EJB ( entity beans) are cached ?

    Are EJB ( entity beans) are cached ?
    I have a doubt here . As per my understanding , the entity beans are cached from the database. In that case , If I delete a row in the database by an external application ( say using TOAD tool) , how the Entity bean will be updated / reloaded ? Entity bean will be out of sync then .
    Application server : weblogic/webspehere .

    >
    You can use the refresh method of the EntityManager interface to read new values from the database (if you expect it to be out of sync), and use locks to prevent others from changing your data while the application is performing actions in a transaction.Did you mean I have to write code for this ? can't be made it automatic refresh by the container ? Is there any settings I can configure so that container can do it by itself proactively ?
    Also, using locks ...is this a container settings or I need to configure myself in ejb-jar.xml ? Could you please shed some light here ?

  • Does JServer support EJB/Entity beans

    What version of JServer lives in the following applications, and does it support EJB/Entity Beans or when will it.
    8.1.5 OAS
    8.1.5 8i
    8.1.6 OAS
    8.1.6 8i

    Check out the following link for details about the Beta Program: http://technet.oracle.com/products/oracle8i/java_beta/index.htm
    New features that will be available in the Beta include support for Entity Beans, and support for Servlets. It also includes JServer Accelerator (JServer's Native Compiler).

  • I met a problem when I deploy a entity bean!

    I had developed a simple entity--only have
    two columns use Jbuilder 6.0 Enterprise,
    when I deploy it with weblogic 6.1,I met
    the following error :
    weblogic.j2ee.DeploymentException: Error deploying application mpassword:
    Unable to deploy EJB: Password1 from mpassword.jar:
    The DataSource with the JNDI name: Oracle could not be located. Please
    ensure that the DataSource has been deployed successfully and that the JNDI
    name in your EJB Deployment descriptor is correct.
    at weblogic.deploy.deploy(deploy.java:665)
    at weblogic.deploy.runBody(deploy.java:358)
    at weblogic.utils.compiler.Tool.run(Tool.java:79)
    at weblogic.deploy.main(deploy.java:1601)
    Error deploying application mpassword:
    Unable to deploy EJB: Password1 from mpassword.jar:
    The DataSource with the JNDI name: Oracle could not be located. Please
    ensure that the DataSource has been deployed successfully and that the JNDI
    name in your EJB Deployment descriptor is correct.

    Hi,
    Within you weblogic-cmp-rdbms-jar.xml file you will have an entry:
    <data-source-name>Oracle</data-source-name>
    This links to a DataSource deployed on WebLogic which in turn links to a
    connection pool to the database where you persist the entity.
    So do you have a DataSource called Oracle?
    Is this correctly deployed?
    Gareth
    "mrliuz" <[email protected]> wrote in message
    news:[email protected]..
    I had developed a simple entity--only have
    two columns use Jbuilder 6.0 Enterprise,
    when I deploy it with weblogic 6.1,I met
    the following error :
    weblogic.j2ee.DeploymentException: Error deploying application mpassword:
    Unable to deploy EJB: Password1 from mpassword.jar:
    The DataSource with the JNDI name: Oracle could not be located. Please
    ensure that the DataSource has been deployed successfully and that theJNDI
    name in your EJB Deployment descriptor is correct.
    at weblogic.deploy.deploy(deploy.java:665)
    at weblogic.deploy.runBody(deploy.java:358)
    at weblogic.utils.compiler.Tool.run(Tool.java:79)
    at weblogic.deploy.main(deploy.java:1601)
    Error deploying application mpassword:
    Unable to deploy EJB: Password1 from mpassword.jar:
    The DataSource with the JNDI name: Oracle could not be located. Please
    ensure that the DataSource has been deployed successfully and that theJNDI
    name in your EJB Deployment descriptor is correct.

  • Error Deploying CMP Entity Bean

    Hi,
    I am new to Entity Beans and am trying to deploy a CMP Entity Bean without any success.
    I did search this forum for similar issues and tried those suggestions as well but that has not helped. Was wondering if someone could help me out on this.
    The Entity bean has 2 fields: name and description.
    The ejb-jar.xml file for this bean is:
    <enterprise-beans>
    <entity>
    <ejb-name>Product</ejb-name>
    <home>example.cmp.ProductHome</home>
    <remote>example.cmp.Product</remote>
    <ejb-class>example.cmp.ProductBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.String</prim-key-class>
    <reentrant>false</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>PRODUCTS</abstract-schema-name>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <primkey-field>name</primkey-field>
    <query>
    </query>
    </entity>
    </enterprise-beans>
    The error that I get while deploying the bean is:
    Error deploying EJB homes for: file:/C:/servers/oc4j1013/j2ee/home/applications/cmptest/cmptest.jar
    java.lang.InstantiationException: Error looking up cmt-datasource at jdbc/OracleDS (name not found)
    at com.evermind.server.ApplicationState.getDataSourceContainer(ApplicationState.java:384)
    Error deploying file:/C:/servers/oc4j1013/j2ee/home/applications/cmptest/cmptest.jar
    homes: Error looking up cmt-datasource at jdbc/OracleDS (name not found)
    [java] [TopLink Severe]: 2005.04.17 10:22:20.156--ServerSession(28816172)--
    Local Exception Stack:
    [java] Exception [TOPLINK-7060] (TopLink (Oracle OC4J CMP) - 10g release 3(10.1.3.0) (Build 041129)): oracle.toplink.exceptions.ValidationException
    [java] Exception Description: Cannot acquire data source [jdbc/OracleDS].
    [java] Internal Exception: javax.naming.NameNotFoundException: jdbc/OracleDS not found
    [java] at oracle.toplink.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:208)
    [java] at oracle.toplink.internal.ejb.cmp.oc4j.Oc4jNonJtaConnector.getOrCreateDataSource(Oc4jNonJtaConnector.java:62)
    If anybody knows what the problem is please let me know.
    Thanks in advance.
    Bhupen

    Please note that the data-source has been re-architectured in 10.1.3 DP3 and you should have DataSource as follows:
    <data-sources xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd' schema-major-version='10' schema-minor-version='1'>
    <managed-data-source connection-pool-name='Example Connection Pool' jndi-name='jdbc/OracleDS' name='OracleManagedDS' />
    <connection-pool name='Example Connection Pool' >
    <connection-factory factory-class='oracle.jdbc.pool.OracleDataSource' user='scott' password='tiger' url='jdbc:oracle:thin:@localhost:1521:orcl'>
    </connection-factory>
    </connection-pool>
    </data-sources>

  • Deploying BMP Entity Bean with primary key calss

    Hi,
    I am using EJB 2.0 with and websphere studio 5.0 and database is sql server 2000.
    My BMP Entity bean has a primary key class.From my client I am invoking the Entity Bean by calling it's findbyprimarykey method.
    The home interface of my findbyprimarykey method returns a class of type Remote.But in the Entity Bean class,the return type is the primarykey class type.
    My problem is invoking this findbyprimarykey from the client to get the remote interface so that the other business methods of the entity bean can be called.
    The control goes into the ejbFindbyPrimaryKey but when it is returing from the Entity Bean class,it gives a remote exception (as the return type in Entity Bean class and Home interface are different for the findbyprimarykey method).
    I think that somewhere in the deployment decriptor in my websphere,i have to specify the primarykey class type,which i am missing out and hence getting the error.
    Please help me out with your advice and solution.
    Thanks
    Rahul Priyadarshi

    Hi,
    Sorry to disturb you again.
    Even my code is also almost the same....i am pasting the code below...Please go through it and let me know if I have made any mistake..
    EditVendorEntityBean.....(Bean Class)
    package code.beans.EditVendor;
    import code.beans.dataAccess.*;
    import javax.ejb.CreateException;
    import javax.ejb.RemoveException;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.EJBException;
    import javax.ejb.FinderException;
    import javax.ejb.ObjectNotFoundException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import java.sql.*;
    import javax.sql.*;
    import java.util.*;
    * Bean implementation class for Enterprise Bean: EditVendorEntity
    public class EditVendorEntityBean implements javax.ejb.EntityBean {
         private static Hashtable dataSources = new Hashtable();
         private String username;
    private int Vendor_ID;
    private int Category_Id;
    private String Category_Name;
    private String Vendor_Name;
    private String Vendor_Address1;
    private String Vendor_Address2;
    private String Contact_Name;
    private String Home_Phone;
    private String Work_Phone;
    private String email;
    private String faxno;
    private String userloginname;
    private boolean dirtyFlag = false;
    private EntityContext context;
    private static final String DS_NAME = "jdbc/spiPOPS";
    Connection con = null;
    Statement stmt = null;
    PreparedStatement st = null;
    ResultSet res = null;
         //***********************Business Methods*********************
    // Begin of Busines Methods
    public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax) {
              System.out.println("in setData where Vendor Id= "+ Vendor_ID);
                   boolean status=false;
                   boolean existing=false;
                   ArrayList cat=new ArrayList();
                   try
                        cat=getcategorylist(this.Vendor_ID);
                   catch(SQLException e)
                        System.out.println("Could not get category list");
                   System.out.println("Size of cat array -->" + cat.size() + " and string array size -->" + catname.length);
                   if(catname.length>0)
                        //Removing unwanted vendor categories for a particular vendor id
                        for(int i=0;i<cat.size();i++)
                                  existing=false;
                                  String tempdata=(String)cat.get(i);
                                  for(int j=0;j<catname.length;j++)
                                       if(tempdata.equals(catname[j]))
                                            existing=true;
                                  if(!existing)
                                       try
                                            delvencat(this.Vendor_ID,tempdata.trim());
                                       catch(SQLException e)
                                            System.out.println("Could not delete record in POPS_VENDOR_CATEGORY for -->" + tempdata);
                   //Adding new vendor categories for a particular vendor
                        try
                                  for(int i=0;i<catname.length;i++)
                                       status=false;
                                       String strcat=catname;
                                       status=checkcat(this.Vendor_ID,strcat.trim());
                                       if(!status)
                                            insertvencat(this.Vendor_ID,strcat.trim());
                        catch(SQLException e)
                                  System.out.println("Could not insert or select from POPS_VENDOR_CATEGORY table");
                   this.Vendor_Name          =vendorname;
              this.Vendor_Address1     =vendadd1;
              this.Vendor_Address2     =vendadd2;
              this.Contact_Name          =vendcontact;
              this.Work_Phone               =venoff;
              this.Home_Phone               =venres;
              this.email                    =mailid;
              this.faxno                    =venfax;
                   dirtyFlag = true;
                   System.out.println("Leaving set data method");
    public Vector getData() {
         Vector vctRec=new Vector();
         ArrayList arrdatas = new ArrayList();
         arrdatas.add(""+this.Vendor_ID);
         arrdatas.add(this.Vendor_Name);
         arrdatas.add(this.Vendor_Address1);
         arrdatas.add(this.Vendor_Address2);
         arrdatas.add(this.Contact_Name);
         arrdatas.add(this.Work_Phone);
         arrdatas.add(this.Home_Phone);
         arrdatas.add(this.email);
         arrdatas.add(this.faxno);
         vctRec.addElement(arrdatas);
         ArrayList cat=new ArrayList();
              try
              System.out.println("Calling getcategorylist from getdata with vendorid-->" + this.Vendor_ID);
              cat          = getcategorylist(this.Vendor_ID);
         catch(SQLException e)
                   System.out.println("Could not get datas for category list");
         vctRec.addElement(cat);
         ArrayList allcats=new ArrayList();
         try
                        allcats          = getallcategorylist();
              catch(SQLException e)
                        System.out.println("Could not get datas for category list");
         vctRec.addElement(allcats);
              dirtyFlag = false;
         System.out.println("Before return statement in getdata with vector size -->" + vctRec.size());
              return vctRec;
    // End of Business Methods
    //**************************Entity Bean Methods*******************************
         * ejbActivate
         public void ejbActivate() {
              Vendor_ID = Integer.parseInt((String)context.getPrimaryKey());
         System.out.println("Inside ejbActivate Vendor_ID-->"+ Vendor_ID);
         * ejbLoad
         public void ejbLoad() {
              System.out.println("Inside ejbLoad ********" );
    try {
    loadRow();
    }catch (Exception ex) {
              System.out.println("Failed in loadRow()");
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * ejbPassivate
         public void ejbPassivate() {
         System.out.println("Inside ejbPassivate " );
    Vendor_ID = 0;
         * ejbRemove
         public void ejbRemove() throws javax.ejb.RemoveException {
              //Empty Method
         * ejbStore
         public void ejbStore() {
    System.out.println("Inside ejbStore " );
    try {
    storeRow();
    }catch (Exception ex) {
              System.out.println("Exception thrown in storeRow" + ex.getMessage());
    throw new EJBException("ejbLoad: " +
    ex.getMessage());
         * getEntityContext
         public javax.ejb.EntityContext getEntityContext() {
              return context;
         * setEntityContext
         public void setEntityContext(javax.ejb.EntityContext ctx) {
              System.out.println("Inside setEntityContext " );
    try{
         con = getConnection(DS_NAME);
         System.out.println("DB Connection Created!!");
    catch(Exception e){
    this.context = ctx;
         * unsetEntityContext
         public void unsetEntityContext() {
    System.out.println("Inside unsetEntityContext " );
    closeDbConnection(con, res, st);
    this.context = null;
         * ejbCreate
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbCreate(String vendorid)
              throws javax.ejb.CreateException {          
              return new EditVendorEntityKey(vendorid);
              //return null;
         * ejbPostCreate
         public void ejbPostCreate(String vendorid) throws javax.ejb.CreateException {
              //Empty
         * ejbFindByPrimaryKey
         //code.beans.EditVendor.EditVendorEntityKey
         public code.beans.EditVendor.EditVendorEntityKey ejbFindByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey primaryKey)
              throws javax.ejb.FinderException {
    try {
    if(selectByPrimaryKey(Integer.parseInt(primaryKey.getVendorId()))) {
              System.out.println("Leaving the findbyprimarykey method from the entity bean");
         return primaryKey;
         //return null;
    }else {
         throw new ObjectNotFoundException
         ("Row for id " + primaryKey + " not found.");
    }catch (Exception ex) {
    throw new EJBException("EXCEPTION IN ejbFindByPrimaryKey :- " + ex.getMessage());
         /*********************** Database Utility Routines *************************/
    private boolean selectByPrimaryKey(int priKey)
    throws SQLException {
         System.out.println("inside selectByPrimaryKey for primary key " + priKey);
    String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR WHERE VENDOR_ID = " + priKey;
    System.out.println("in selectByPrimaryKey where queryString is: "+ queryStr);
              stmt = con.createStatement();
    ResultSet result = stmt.executeQuery(queryStr);
    if(!result.next()) {
    stmt.close();
         System.out.println("Did not find "+priKey);
    return false;
    else { //Found the primaryKey
    Vendor_ID = result.getInt("VENDOR_ID");
    stmt.close();
    return true;
    private void loadRow() throws SQLException {
              System.out.println("inside loadRow ...");
              stmt = con.createStatement();
              String queryStr = "SELECT VENDOR_NAME,VENDOR_ADDRESS1,VENDOR_ADDRESS2,CONTACT_NAME,HOME_PHONE,WORK_PHONE,EMAIL_ID,FAX_NO " +
                                  "FROM POPS_VENDOR WHERE VENDOR_ID=" + Vendor_ID;
              System.out.println("Inside loadRow()***********"+queryStr);
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catadatas=new ArrayList();
         if(!result.next())
         throw new SQLException("No record for primary key" + Vendor_ID);
              this.Vendor_ID               =Vendor_ID;
                        this.Vendor_Name          =result.getString("VENDOR_NAME");
                        this.Vendor_Address1     =result.getString("VENDOR_ADDRESS1");
                        this.Vendor_Address2     =result.getString("VENDOR_ADDRESS2");
                        this.Contact_Name          =result.getString("CONTACT_NAME");
                        this.Home_Phone               =result.getString("HOME_PHONE");
                        this.Work_Phone               =result.getString("WORK_PHONE");
                        this.email                    =result.getString("EMAIL_ID");
                        this.faxno                    =result.getString("FAX_NO");
                             System.out.println("Leaving loadrow method with loaded datas for vendor -->" + Vendor_ID);
                             stmt.close();
    private ArrayList getcategorylist(int vendor) throws SQLException{
              String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID=" + vendor;
              System.out.println("Query for the cat list --> " + queryStr);
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              ArrayList catdatas=new ArrayList();
    try{
                   while(result.next())
                        catdatas.add(result.getString("VENDOR_CAT"));
              catch (SQLException e){
                   stmt.close();
                   System.out.println("Could not retrieve datas for Category list");
              stmt.close();
              System.out.println("size off array for cat -->" + catdatas.size() + " and datas ->" + catdatas);
              return catdatas;
         private ArrayList getallcategorylist() throws SQLException{
                   //String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY";
                   StringBuffer strquery=new StringBuffer(20);
                   strquery.append("SELECT DISTINCT(CATEGORY_NAME) FROM POPS_CATEGORY");
                   stmt = con.createStatement();
                   //ResultSet result = stmt.executeQuery(queryStr);
                   ResultSet result = stmt.executeQuery(strquery.toString());
                   ArrayList catdatas=new ArrayList();
                   try{
                        while(result.next())
                                  //catdatas.add(result.getString("VENDOR_CAT"));
                                  catdatas.add(result.getString("CATEGORY_NAME"));
                   catch (SQLException e){
                             stmt.close();
                             System.out.println("Could not retrieve datas for All Category list");
                   stmt.close();
                   return catdatas;
         private void delvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              stmt = con.createStatement();
              String queryStr ="DELETE FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + vencat.toUpperCase() + "'";
              System.out.println("Delete query --> " + queryStr);
              update= stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Did not find data to delete");
              stmt.close();
         private void insertvencat(int vendor,String vencat) throws SQLException {
              int update=-1;
              String queryStr ="INSERT INTO POPS_VENDOR_CATEGORY(VENDOR_ID,VENDOR_CAT)" +
                                  " VALUES(" + vendor +",'" + vencat + "')";
              System.out.println("Insert query --> " + queryStr);
              stmt = con.createStatement();
              update=stmt.executeUpdate(queryStr);
              if(update!=1)
                   System.out.println("Could not insert records in the database");
              stmt.close();
         private boolean checkcat(int vendor,String catven) throws SQLException {
              boolean datastatus=false;
              String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + catven.toUpperCase() + "'";
              stmt = con.createStatement();
              ResultSet result = stmt.executeQuery(queryStr);
              datastatus=result.next();
              stmt.close();
              return datastatus;
    private void storeRow() throws SQLException {
                   System.out.println("Inside ejb store");
         if (!dirtyFlag) {
         System.out.println("Skipping the UPDATE because object is not dirty");
         return;
         CallableStatement cs=null;
    try{
                        cs = con.prepareCall("EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        System.out.println("\n\n SQL Statement : \n " + "EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                        cs.executeUpdate();
              catch (SQLException e){
                        cs.close();
                        System.out.     println("\n\n Error in calling stored procedure POPS_INSERT_NEW_REQUEST \n\n"+ e.getMessage() + "\n\n");
              cs.close();
              dirtyFlag = false;
         private Connection getConnection(String dbName) throws SQLException
              String configuredDataSourceName = null;
              if (dbName == null) {
                   System.out.println("Attemp to get connection failed. The requested database name is null");
              DataSource dbSource = getDataSource(dbName);
              return dbSource.getConnection();
         private DataSource getDataSource(String dbName)
              // looking from cache;
              DataSource dbSource = (DataSource) dataSources.get(dbName);
              if (dbSource == null) { //we need to find it from JNDI
                   try {
                        Context ic = new InitialContext();
                        dbSource = (DataSource) ic.lookup(dbName);
                        dataSources.put(dbName, dbSource);
                   }catch (NamingException e){
              return dbSource;
         * User calls this function to safely close an connection
         * @param connt The connection a datasource
         * @param rs The resulSet inside this connection
         * @param statement The statement associate with this connection
         private void closeDbConnection(Connection cont,ResultSet rs,Statement statement)
              if (rs != null)
              try {
                        rs.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (statement != null)
                   try {
                        statement.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
              if (cont != null)
                   try {
                        cont.close();
                   } catch (SQLException ignored) {
                        ignored.printStackTrace();
         } //closeDbConnection
    EditVendorEntity (Remote Interface)
    package code.beans.EditVendor;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.util.*;
    * Remote interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntity extends javax.ejb.EJBObject {
         public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax)
                   throws RemoteException;
    public Vector getData() throws RemoteException;
    EditVendorEntityHome (Home Interface)
    package code.beans.EditVendor;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.FinderException;
    import javax.ejb.DuplicateKeyException;
    import javax.ejb.EJBHome;
    import java.util.*;
    * Home interface for Enterprise Bean: EditVendorEntity
    public interface EditVendorEntityHome extends javax.ejb.EJBHome {
         * Creates an instance from a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity create(String vendorid)
              throws javax.ejb.CreateException, java.rmi.RemoteException;
         * Finds an instance using a key for Entity Bean: EditVendorEntity
         public code.beans.EditVendor.EditVendorEntity findByPrimaryKey(
              code.beans.EditVendor.EditVendorEntityKey Vendor_ID)
              throws javax.ejb.FinderException, java.rmi.RemoteException;
    EditVendorEntityKey (Primary Key Class)
    package code.beans.EditVendor;
    * Key class for Entity Bean: EditVendorEntity
    public class EditVendorEntityKey implements java.io.Serializable {
         static final long serialVersionUID = 3206093459760846163L;
         public String primkey;
         * Creates an empty key for Entity Bean: EditVendorEntity
         public EditVendorEntityKey() {  }
         public EditVendorEntityKey(String primarykey) {     
              this.primkey=primarykey;
         public String getVendorId() {
    return primkey;
         * Returns true if both keys are equal.
         public boolean equals(java.lang.Object otherKey) {
              if (otherKey instanceof code.beans.EditVendor.EditVendorEntityKey) {
                   code.beans.EditVendor.EditVendorEntityKey o =
                        (code.beans.EditVendor.EditVendorEntityKey) otherKey;
                   return (primkey.equals(otherKey));
              return false;
         * Returns the hash code for the key.
         public int hashCode() {
              return (primkey.hashCode());
    Please go through and give me your comments and solution...
    Thanks in advance
    Rahul

  • How to specify JDBC Oracle url using deployment tool - Entity Bean

    Hello I'am new to EJB.
    When creating a entity bean-managed persistence and you need to specify the jdbc url with user name
    and password to establish a connection object, how does one specify that in the deployment
    tool?
    Heres an example of what has in the J2EE tutorial has in AccountEJB to get an connection object
    private String dbName = "java:comp/env/jdbc/AccountDB";
    private void makeConnection() throws NamingException, SQLException {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup(dbName);
    con = ds.getConnection();
    Now if my oracle jdbc url is to be jdbc:oracle:thin:@Abe:1521:dev
    ie My host is Abe, port number 1521 and database name of dev and username/password will be system/manager.
    what would my dbName be at the top?
    Would my JNDI lookup of a DataSource resource "java:comp/env/jdbc/AccountDB" become "java:comp/env/jdbc/dev" for starters?
    In the Resource Factories Reference Code I've add a reference of
    Coded Name: jdbc/dev
    Type: javax.sql.DataSource
    Authentication: Container
    and down the bottom of the I've put JNDI Name: MyAccount
    according to the AccountClient code of:
    Context initial = new InitialContext();
    Object objref = initial.lookup("MyAccount");
    and put User Name of "system" and Password of "manager"
    I'am sure in the source code I have to put
    Class.forName("oracle.jdbc.driver.OracleDriver")
    else you would get that no sutitable driver error, maybe you don't have to if ejb server is smart enough?
    What I'am confuse about is where to specify the jdbc url of "jdbc:oracle:thin:@Abe:1521:dev" ??
    Know it won't work because of this vital part. Do you have to put that somewhere else in the deployment tool or properties file, or some other tool??
    Please help
    Thanks
    Abraham Khalil

    When running the client after successful deployment with jdbc, I'am getting
    javax.naming.CommunicationException: java.rmi.MarshalException: CORBA MARSHAL 1398079699 Maybe; nested exception is:
    org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : minor code: 1398079699 completed: Maybe
    org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : minor code: 1398079699 completed: Maybe
    at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:923)
    at com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:281)
    at com.sun.corba.ee.internal.corba.TCUtility.unmarshalIn(TCUtility.java:274)
    at com.sun.corba.ee.internal.corba.AnyImpl.read_value(AnyImpl.java:554)
    at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:605)
    at com.sun.corba.ee.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:252)
    at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.readAny(Util.java:203)
    at javax.rmi.CORBA.Util.readAny(Unknown Source)
    at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Unknown Source)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:133)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at AccountClient.main(AccountClient.java:21)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:151)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at AccountClient.main(AccountClient.java:21)
    One thing I don't like about EJB is that everything is transparent which is good! But its much
    harder to debug! :( Tried to see if I can figure it out. Hope someone has seen this problem before?

Maybe you are looking for