Recording Changes to modified Entity Beans

Hi,
Our application uses a thick client that communicates with the J2EE middle tier (J2EE 1.4). For performance reasons our client has its own data model. We are using JMS Topics to implement the Observer pattern between the client and the middle tier.
The two questions I have are:
1. How can we record changes that occur to Entity beans (CMP) in an automated fashion (ie other than explicitly doing so from the Session bean updating them)?
2. How can we minimise the number of JMS messages sent when multiple Entity beans are updated per business method. We had thought about hooking into the Transaction lifecycle events, and distributing all objects marked as changed (see Q1) following Transaction comitt.
I know that we could do both of these manually, however it relies on developers remembering to record changes to objects and also to distribute them when the method completes. I am more interested in possible uses of Container services to alleviate the burden on the application developer.
thanks in advance.

Hi,
One suggestion, I am not sure whether this is what you want to achieve.
1. I hope by changes to EB you mean inserts, updates and deletes.
2. I hope you either want to keep these changes in DB or create a log of these chages.
3. If you want to use container services, then why not to use ejbCreate(), ejbStore(), ejbRemove () methods.
4.You may create a database table to record changes to your beans. (Bean_Id,Bean_Name,Bean_Field,Bean_Field_Value,TimeStamp).
5.During a TX you may record changes happening to your bean in an object that has a hashmap containing name of bean field and its latest value.
6.After successful completion of a TX a JMS Publisher will send this object to a MDB which will create a state change log or update a DB.
7. You may explore an option of using an entity bean for this as well.
I am not sure of your exact requirements, bu hop this may help.
Do revert back.
VJ

Similar Messages

  • 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 "

  • What happens to cached entity beans when directly change record in database?

    hi:
    i am working on a project which weblogic as app server. there's many case
    in my application where we have to update large number of records(about
    fifty thousands) in
    a loop one at a time. we have tried with entity beans but it 's so slow.
    so in this case we have to update database directly. but i am worried about
    my code accessing record with entity beans. the entities caches state and i
    am
    afraid there will be trouble if the state in ejb caches and record in db
    mismatch . i change state in db directly and ejbs has no way to know about
    it.
    is there any solution?
    thanks in advance!
    daniel

    Depends on the way you have implemented your entity bean. Normally, a bean
    method invocation will trigger a transaction (based on the bean's method
    transaction attribute), which will in turn call the ejbLoad(). In CMP's the
    container will automatically load the data from the underlying datastore. In
    BMP's a transactional method call will invoke the ejbLoad(), and the
    ejbLoad() implementation would be responsible for loading the data.
    "daniel wang" <[email protected]> wrote in message
    news:3c5e01b9$[email protected]..
    hi:
    i am working on a project which weblogic as app server. there's manycase
    in my application where we have to update large number of records(about
    fifty thousands) in
    a loop one at a time. we have tried with entity beans but it 's so slow.
    so in this case we have to update database directly. but i am worriedabout
    my code accessing record with entity beans. the entities caches state andi
    am
    afraid there will be trouble if the state in ejb caches and record in db
    mismatch . i change state in db directly and ejbs has no way to know about
    it.
    is there any solution?
    thanks in advance!
    daniel

  • Will updates to an EJB3 entity bean update ONLY changed columns?

    Hello,
    If you have an EJB3 entity bean that maps to a table, and then you change the value of ONE of the fields in the entity bean, will each column in the row be updated, OR just the column that changed in the row?
    Thanks

    Only fields detected as persistent-dirty will be updated in the database record.
    Laurent

  • 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

  • Change one entity bean query, errors pop up in another... why?

    In my application I have the following entity bean:
    @Entity
    @Table(name = "ventureprofile")
    @SecondaryTable(name = "venture")
    @NamedQueries( {       
            @NamedQuery(name = "Ventureprofile.findByVentureprofileid", query = "SELECT v FROM Ventureprofile v WHERE v.ventureprofileid = :ventureprofileid"),
            @NamedQuery(name = "Ventureprofile.findByVentureid", query = "SELECT v FROM Ventureprofile v WHERE v.ventureid = :ventureid"),
            @NamedQuery(name = "Ventureprofile.findByLogoimagelocation", query = "SELECT v FROM Ventureprofile v WHERE v.logoimagelocation = :logoimagelocation"),
            @NamedQuery(name = "Ventureprofile.findByVisible", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename")
            //@NamedQuery(name = "Ventureprofile.findByVisibleRange", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename OFFSET 1 LIMIT 2")
    public class Ventureprofile implements Serializable {
        @GeneratedValue(strategy=GenerationType.AUTO, generator="Ventureprofile.ventureprofileid.seq")
        @SequenceGenerator(name="Ventureprofile.ventureprofileid.seq", sequenceName="ventureprofile_ventureprofileid_seq", allocationSize=1) 
        @Column(name = "ventureprofileid", nullable = false)
        private BigInteger ventureprofileid;
        @Id
        @JoinColumn(name = "ventureid", referencedColumnName = "ventureid")
        private long ventureid;  
        @Lob
        @Column(name = "venturesummary")
        private String venturesummary;
        @Column(name = "logoimagelocation")
        private String logoimagelocation;
        @Column(name = "visible", nullable = false)
        private char visible;
        @Column(table = "venture", name = "venturename", insertable=false)
        private String venturename;
    ...and another entity bean:
    @Entity
    @Table(name = "venturelink")
    @NamedQueries( {
            @NamedQuery(name = "Venturelink.findByVenturelinkid", query = "SELECT v FROM Venturelink v WHERE v.venturelinkid = :venturelinkid"),
            @NamedQuery(name = "Venturelink.findByVentureprofileid", query = "SELECT v FROM Venturelink v WHERE v.ventureprofileid = :ventureprofileid"),
            @NamedQuery(name = "Venturelink.findByLinkurl", query = "SELECT v FROM Venturelink v WHERE v.linkurl = :linkurl"),
            @NamedQuery(name = "Venturelink.findByLinkname", query = "SELECT v FROM Venturelink v WHERE v.linkname = :linkname")
    public class Venturelink implements Serializable {
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO, generator="Venturelink.venturelinkid.seq")
        @SequenceGenerator(name="Venturelink.venturelinkid.seq", sequenceName="venturelink_venturelinkid_seq", allocationSize=1)  
        @Column(name = "venturelinkid", nullable = false)
        private BigInteger venturelinkid;
        @Column(name = "ventureprofileid", nullable = false)
        private long ventureprofileid;
        @Column(name = "linkurl", nullable = false)
        private String linkurl;
        @Column(name = "linkname", nullable = false)
        private String linkname;
    ...    If I uncomment the last NamedQuery ~
    @NamedQuery(name = "Ventureprofile.findByVisibleRange", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename OFFSET 1 LIMIT 2")I experience the following runtime error:
    javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.lang.IllegalArgumentException: NamedQuery of name: Venturelink.findByVentureprofileid not found.Container: Glassfish
    Database: Postgres
    OS: WinXP sp2
    Persistence provider: Toplink
    Note that I am not altering 'Venturelink', I am only altering 'Ventureprofile', however errors are manifesting themselves in 'Venturelink'.
    I have heard a rumor that 'OFFSET' and 'LIMIT' are not supported by the majority of persistence providers, but that would be a ridiculous situation... unless the majority of persistence providers lazy-load results when they are pulled from a result set. Is that the case?
    Regardless, this is making me guess what is going on behind the scenes. So, at some point during runtime, is all of my EJB query code getting munged together? And then whatever interprets them into SQL is giving up as soon as it finds a query it doesn't like? That's what this smells like, at least...
    Typically, I find weird errors like this crop up when I'm doing something stupid that a system wasn't designed to handle. So I'd really appreciate it if someone would set me straight.

    Solution, via Doug Clarke at the TopLink forums:
    2. JPA's query language does not support OFFSET and LIMIT. Instead JPA offers setFirstResult(int) and setMaxResult(int) on the Query object. In TopLink this generally translates to JDBC calls of similar names.
    (Thanks Doug!)
    so yeah... unless somebody knows otherwise and I'm wrong (often the case), looks like things choke across multiple entity beans as soon as one malformed query is found. Not good.

  • Entity Bean Rollback fails: caches are out of synch with the database

    We are encountering a critical issue where the rollback of a session transaction rolls back any database changes, but doesn't roll back bean changes in memory. When we next access the bean, it returns information that should have been rolled back. The memory cache is out of synch with the database.
    We have a simple session bean S, using container managed transactions. We also have an entity bean E using bean managed persistence. E has a single member <name>.
    We implement a method s() in S with <trans-attribute> Required as follows:
    public void s() {
    Context lookupContext = getLookupContext();
    SHome shome = (SHome) lookupContext.lookup(SHome.NAME);
    S s = shome.findByPrimaryKey(thePrimaryKey);
    System.out.println("-- current name = " + s.getName());
    s.setName("IGNORE");
    EJBContext ejbContext = (EJBContext) getContext();
    ejbContext.setRollbackOnly();
    Since this is BMP, the setName call issues our SQL update against the S record. When the session transaction rolls back, the database changes are also rolled back. But the entity bean in memory shows the modified name. We can see this in the next call to s() since the getName() returns IGNORE rather than the original value. We have also gotten debugged into the underlying instance cache associated with the S bean descriptor. I.e.
    AbstractEJBHome ejbHome = (AbstractEJBHome) lookupContext.lookup(SHome.NAME);
    AlternateHashTable aht = ejbHome.getBeanDescriptor().getCache();
    Looking at this map of bean instances also shows that the bean instance for S is not rolled back.
    From previous conversations with the server technologies team, we understand that during the transaction, we should be working on a cloned copy of the S bean. Upon rollback, the copies should be discarded rather than merged back to the cached bean. They seem to be merged regardless of rollback state.
    We are using OC4J 10.1.3.0.0 (build 060119.1546.05277).

    Actually, what one or the developers in my group found out is two things:
    1) The clone is a shallow copy.They copy the references but not objects themselves. This has been causing problems for us.
    2) It seems that you don't work on a copy and you work on the original and they keep a copy. Now, this is fine IF you don't have multiple threads working on the same Entity bean and we moved our application from Weblogic where it throws an exception if that Entity bean is in use to OC4J which is suppose to copy the bean and doesn't so you have multiple threads possibly modifying the same object.

  • Entity bean (ejb 3.0) refactoring problem

    I didn't find a better method than regenerating an entity bean after modifying the table definition and renaming the class after deleting the old one.
    I'm not sure i can delete the old class representing the entity bean before regenerating it without any effects into the others entity beans.
    It work fine but still a little problem. The refactoring process didn't change the name of the entity bean into the select clauses into queynamed injection.

    I am facing a similar problem. Does JDeveloper 10g (10.1.3.3.0) provide an automatic process to update an Entity Bean definition when the underlying database table definition changes?
    I also noticed that for JDeveloper to create all the relationships (i.e. @OneToMany, @ManyToOne) between multiple Entity beans, I need to create all the Entity beans together in one pass using the wizard. If two entities depend on each other, and not created together, JDeveloper will not create the relationships between them. Is there a way around that?
    Thank you

  • Entity bean with primary key generated by trigger

    Hi,
    We have a table(oracle) with one column as primary key,
    but the primary key is generated by trigger every time
    a new row is inserted into this table, inside the trigger,
    it uses oracle sequence to get the next val.
    If we want to use entity bean with it, what should we specify, it's not application-managed primay key, it's
    not auto-generated primary key either. How can we resolve
    it without change the database part.
    Any thought is appreciated.
    Thanks
    afang

    The code is already there with JDBC call inserting
    into the table, the inserting trigger then will generate
    sequence key and being inserted into primary key column.
    Now wondering if it's possible to change the code to use entity bean but without modifying the trigger (since it contains other business logics).

  • Global Variable in entity beans

    Dear Friends,
    For example let us think that we have an entity bean for Customer.
    and we created an instance of that bean for customer A and then for customer B.
    So will the global variables in Customer bean be shared across Customer A and Customer B or will there be seperate instances for both Customers.
    Thanking You,
    Chamal.

    Your concepts seem to be a little messed up.
    For entity bean, remember the following:
    1. each object/instance of entity bean represents a record in a database
    2. when a client looks up an entity bean (typcially by using findByPrimaryKey method on home object), the record from database is searched and its values are stored in Entity Beans variables (this is probably what you mean by Global Variable. But thats an incorrect terminology in Java/J2EE. Class attribute is the correct word)
    3. In step 2, you fetched a record and that record is represented by a java object, which is nothing but entity bean.
    4. Now if you make changes to this java object, these changes will persist in the database. That is the essence of entity bean.
    5. If you use the home object's findByPrimaryKey method and look for the same record, no new object will be created. The 2 remote objects will point to the same entity bean on the server.
    6. If yo use the home object's findByPrimaryKey method and look for another record/customer, a new object will be created on the server. This new entity bean will map to the new record.
    Note taht the attribtues of CustomerA and customerB will never be shared.
    hope that helps

  • Entity beans storing client callbacks...how?

    Ok, here's my situation. Multiple clients might be modifying the same entity bean so I have implemented client callbacks. A client registers a callback with the bean, and the bean will call it back when someone modifies the beans data.
    Now my question is entity beans can be removed by the container for various reasons, so how can I have the bean save the callback so when the container reloads the bean it reloads the callbacks? How do you store a callback to a database?
    Thanks,
    Jeff Plummer

    Shaft, let's look at it this way.
    How do you register a client as a callback? Anything "sent" to the EntityBean is serialized. That means when the EntityBean receives the information, it is not the same instance as your client class. Ergo, the "callback" method would operate only on the local instance the EntityBean has at the time, not the one on your client side.
    Now, as for the differences of "state." Yes, the EntityBean persists state as represented by the persistence store (e.g. a row in a table in database). However, in order to register an Object as you would for a callback, then the EntityBean must maintain a reference to that Object - which it can't because the only information that an EntityBean can maintain is that of the persistent store. Only static final Objects are allowed (ones that cannot change during the lifetime of an instance of the EntityBean). Even if you managed to circumvent this restriction, then you have to figure out how all of the EntityBeans would have exactly the same Object references for the callback objects.
    The only way to do what you want is to make it a "non-reference" type of relationship. Which means some sort of message-based system. If you use a JMS Topic, you can get a "broadcast" type of notification out to all your clients and, while there is a bit of a performance trade-off, it's a solution that will work.
    Finally, if there's "tons of data," you might want to go back and look at your Use Case(s) and determine if you really should be using EntityBeans anyway. EntityBeans are great stuff - when used in the right situations.

  • Does an entity bean update result in ALL DB columns being updated?

    Hello,
    If I update a single field in my entity bean, will all the columns for the DB row be updated? -OR will only the changed column value be updated?
    Thank,
    Keith

    Only fields detected as persistent-dirty will be updated in the database record.
    Laurent

  • How do the Entity Bean in SUN J2EE1.3 Connect to Oracle Database9i

    I can connect to Database in my applications with codes:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@172.28.200.43:1521:s
    hcd",
    "system", "manager");
    Statement stmt = conn.createStatement();
    But I can not connect to DB in my EJB, I have config J2EE1.3
    Server and my EJB
    1.in EJB,the code is:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup(dbName);
    con = ds.getConnection();
    2.When I assemble the EJB, I set Resource Refs for JNDI and fill
    user name, password
    3. modify the config/resource.propertities
    jdbcDataSource.5.name=jdbc/ora/test
    jdbcDataSource.5.url=jdbc:oracle:thin:@172.28.200.43:1521:shcd;cr
    eate=true
    when I use cloudscape, it runs OK(with JNDI jdbc/Cloudscape),
    but after i change to use Oracle , the EJB return a Exception:
    Caught an exception.
    java.rmi.ServerException: RemoteException occurred in server
    thread; nested exce
    ption is:
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: U
    nable to connect to database. Io Exception: Connection refused
    (DESCRIPTION=(TMP=)(VSN
    NUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)
    (EMFI=4)))); nested exc
    eption is:
    javax.ejb.EJBException: Unable to connect to database.
    Io Exception: Connecti
    on refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)
    (ERROR_STACK=(ERROR=(C
    ODE=12505)(EMFI=4))))
    java.rmi.RemoteException: nested exception is:
    javax.ejb.EJBException: Unable to
    connect to database. Io Exception: Connection refused
    (DESCRIPTION=(TMP=)(VSNNUM=1509
    99297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))));
    nested exception i
    s:
    javax.ejb.EJBException: Unable to connect to database.
    Io Exception: Connecti
    on refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)
    (ERROR_STACK=(ERROR=(C
    ODE=12505)(EMFI=4))))
    javax.ejb.EJBException: Unable to connect to database. Io
    Exception: Connection refus
    ed(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=
    (ERROR=(CODE=1250
    5)(EMFI=4))))
    <<no stack trace available>>

    Hi,
    Just run the db_setup.sh script located in the bin directory of ias
    If you just give the Oracle Home directory the libraries will be found.
    Register a Datasource pointing to the service you defined in tnsnames.ora
    Cheers, Robert
    Malay Biswas wrote:
    Hi,
    How can I configure native and third party database drivers for
    connecting to Oracle. The oracle client is set up. Also, which one is
    advisable to work with, third party or native? I am using iAS EE 6.0
    Test Drive on Solaris 8.0. Also I am not sure what should be the
    Client library file in this case for ORACL_OCI driver.
    I am trying to run a Entity bean which gives null pointer error while
    doing home.create() or home.findByPrimaryKey, and I don't know what's
    the problem, but my guess is it cannot find or instantiate the object
    since it cannot connect to the proper database.
    Could anybody help me with it?
    Thanks
    Malay
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!--
    Robert Schrijvers
    Javix Training & Software development
    e-mail: [email protected]
    website: www.javix.nl
    phone +31 (0) 629594749

  • Problem in creating CMP Entity Bean - Pls Help

    I am trying to build one simple project having jsps to get connected to CMP Entity Bean.
    But while deploying I am getting the following error...
    Nov 15, 2004 10:59:09... Info: End of log messages of the target system.
    Nov 15, 2004 10:59:09... Info: ***** End of SAP J2EE Engine Deployment (J2EE Application) *****
    Nov 15, 2004 10:59:09... Error: Execution of deployment action for "EntityCMPAppln" aborted:
    Caught exception during application deployment from SAP J2EE Engine's deploy service:
    java.rmi.RemoteException: Error occurred while starting application bcone.com/EntityCMPAppln and wait.
    Reason: Complex error : server ID 6155350:Application bcone.com/EntityCMPAppln cannot be started, because it has hard reference to resource CONFIG_DB with type javax.sql.DataSource, but it is not active on the server.
    (message ID: com.sap.sdm.serverext.servertype.inqmy.extern.EngineApplOnlineDeployerImpl.performAction(DeploymentActionTypes).REMEXC)
    Nov 15, 2004 10:59:09... Error: Deployment NOT successful for EntityCMPAppln
    Nov 15, 2004 10:59:09... Info: SDM configuration: Do not automatically start/stop J2EE Engine. Do not restore state of J2EE Engine now.
    Nov 15, 2004 10:59:09... Error: -
    At least one of the Deployments failed -
    Nov 15, 2004 11:05:16... Info: Request for Logon as admin accepted
    ===========================================
    Nov 15, 2004 11:05:08... Info: =   Starting to execute command 'remotegui'   =
    Nov 15, 2004 11:05:08... Info: ===============================================
    Nov 15, 2004 11:05:10... Info: SDM started successfully.
    Please tell me how to activate the CONFIG_DB reference in database. Or what Extra I have to do to run this example.
    Regards,
    Vivek Ojha

    Dear Benny,
    The code of the required files is pasted below....
    Application.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
                                 "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
        <display-name>EntityCMPAppln</display-name>
        <description>EAR description</description>
        <module>
            <ejb>EntityCMPEjb.jar</ejb>
        </module>
        <module>
            <web>
                <web-uri>EntityCMPWeb.war</web-uri>
                <context-root>/student</context-root>
            </web>
        </module>
    </application>
    Application-j2ee-engine.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
         <provider-name>bcone.com</provider-name>
         <fail-over-enable
              mode="disable"/>
    </application-j2ee-engine>
    data-source-aliases.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE data-source-aliases SYSTEM "data-source-aliases.dtd">
    <data-source-aliases>
         <aliases>
              <data-source-name>${com.sap.datasource.default}</data-source-name>
              <alias>STUDENTDB</alias>
         </aliases>
    </data-source-aliases>
    ejb-j2ee-engine.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-j2ee-engine SYSTEM "ejb-j2ee-engine.dtd">
    <ejb-j2ee-engine>
         <enterprise-beans>
              <enterprise-bean>
                   <ejb-name>StudentBean</ejb-name>
                   <resource-ref>
                        <res-ref-name>jdbc/STUDENTDB</res-ref-name>
                        <res-link>STUDENTDB</res-link>
                   </resource-ref>
                   <entity-props/>
              </enterprise-bean>
         </enterprise-beans>
    </ejb-j2ee-engine>
    ejb-jar.xml
    <?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>
         <description>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <entity>
                   <ejb-name>StudentBean</ejb-name>
                   <home>com.bcone.ejb.StudentHome</home>
                   <remote>com.bcone.ejb.Student</remote>
                   <ejb-class>com.bcone.ejb.StudentBean</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>StudentBean</abstract-schema-name>
                   <cmp-field>
                        <field-name>studentId</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>lname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>standard</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>fyear</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>fname</field-name>
                   </cmp-field>
                   <primkey-field>studentId</primkey-field>
                   <resource-ref>
                        <res-ref-name>jdbc/STUDENTDB</res-ref-name>
                        <res-type>javax.sql.DataSource</res-type>
                        <res-auth>Container</res-auth>
                   </resource-ref>
              </entity>
         </enterprise-beans>
    </ejb-jar>
    persistent.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE persistent-ejb-map SYSTEM "persistent.dtd">
    <persistent-ejb-map>
         <locking
              type="Table"/>
         <db-properties>
              <data-source-name>CONFIG_DB</data-source-name>
              <database-vendor
                   name="SAPDB"/>
         </db-properties>
         <entity-beans>
              <entity-bean>
                   <ejb-name>StudentBean</ejb-name>
                   <table-name>TMP_STUDENTNEW</table-name>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>studentId</field-name>
                        <column>
                             <column-name>STUDENTID</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>lname</field-name>
                        <column>
                             <column-name>LNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>standard</field-name>
                        <column>
                             <column-name>STANDARD</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>fyear</field-name>
                        <column>
                             <column-name>FYEAR</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>fname</field-name>
                        <column>
                             <column-name>FNAME</column-name>
                        </column>
                   </field-map>
              </entity-bean>
         </entity-beans>
         <relationships/>
    </persistent-ejb-map>
    StudentBean.java
    package com.bcone.ejb;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;
    import javax.ejb.CreateException;
    @abstractSchemaName StudentBean
    @cmpVersion 2.x
    @ejbHome <{com.bcone.ejb.StudentHome}>
    @ejbPrimaryKey <{java.lang.String}>
    @ejbRemote <{com.bcone.ejb.Student}>
    @hasSimplePK true
    public abstract class StudentBean implements EntityBean {
         public void ejbLoad() {
         public void ejbStore() {
         public void ejbRemove() throws RemoveException {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setEntityContext(EntityContext context) {
              myContext = context;
         public void unsetEntityContext() {
              myContext = null;
         private EntityContext myContext;
    @primKeyField
         public abstract String getStudentId();
         public abstract void setStudentId(String studentId);
         public abstract String getLname();
         public abstract void setLname(String lname);
         public abstract String getFname();
         public abstract void setFname(String fname);
         public abstract String getStandard();
         public abstract void setStandard(String standard);
         public abstract String getFyear();
         public abstract void setFyear(String fyear);
    Create Method.
         public String ejbCreate(
              String studentId,
              String fname,
              String lname,
              String standard,
              String fyear)
              throws CreateException {
              setStudentId(studentId);
              setFname(fname);
              setLname(lname);
              setStandard(standard);
              setFyear(fyear);
              return null;
    Post Create Method.
         public void ejbPostCreate(
              String studentId,
              String fname,
              String lname,
              String standard,
              String fyear) {
              // TODO : Implement
    StudentData.java
    Created on Nov 14, 2004
    To change the template for this generated file go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package com.bcone.data;
    @author Administrator
    To change the template for this generated type comment go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    public class StudentData {
         private String studentId;
         private String fname;
         private String lname;
         private String standard;
         private String fyear;
    @return
         public String getFname() {
              return fname;
    @return
         public String getFyear() {
              return fyear;
    @return
         public String getLname() {
              return lname;
    @return
         public String getStandard() {
              return standard;
    @return
         public String getStudentId() {
              return studentId;
    @param string
         public void setFname(String string) {
              fname = string;
    @param string
         public void setFyear(String string) {
              fyear = string;
    @param string
         public void setLname(String string) {
              lname = string;
    @param string
         public void setStandard(String string) {
              standard = string;
    @param string
         public void setStudentId(String string) {
              studentId = string;
    student.jsp
    <%@ page language="java" %>
    <html>
         <head>
              <title>
                   Title
              </title>
         </head>
         <body>
              <form method="POST" action="WEBBOT-SELF" name="Student" onSubmit="">
      <!--webbot bot="SaveResults" startspan U-File="_private/form_results.txt"
      S-Format="TEXT/CSV" S-Label-Fields="TRUE" ><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!webbot
      bot="SaveResults" endspan -->
      <br>
      <a href="/student/manageStudent.jsp?action=add" method="post"> Create </a>   
      <a href="/student/manageStudent.jsp?action=modify" method="post"> Modify </a>   
      <a href="/student/manageStudent.jsp?action=delete" method="post"> Delete </a>
      <br><br>
      <table border="1" width="32%">
        <tr>
          <td width="39%">Student ID </td>
          <td width="61%"><input type="text" name="studentId" size="20"></td>
        </tr>
        <tr>
          <td width="39%">First Name</td>
          <td width="61%"><input type="text" name="fname" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Last Name</td>
          <td width="61%"><input type="text" name="lname" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Standard</td>
          <td width="61%"><input type="text" name="standard" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Fiscal Year</td>
          <td width="61%"><input type="text" name="fyear" size="20"></td>
        </tr>
        <tr>
          <td width="39%" align="center"><input type="submit" value="Submit" name="submit"></td>
          <td width="61%" align="center"><input type="reset" value="Reset" name="reset"></td>
        </tr>
      </table>
    </form>
         </body>
    </html>
    mamageStudent.jsp
    <%@ page language="java"
    import="javax.naming.,java.sql.,javax.sql,com.bcone.ejb."
    %>
    <html>
         <head>
              <title>
                   Manage Student
              </title>
         </head>
         <body>
              <h1>
              </h1>
    <jsp:useBean id="stu" class="com.bcone.data.StudentData" ></jsp:useBean>
    <jsp:setProperty name="stu" property="*" />
    <%
    try {
         InitialContext ctx = new InitialContext();
         StudentHome home = (StudentHome) ctx.lookup("java:comp/env/StudentBean");
         String str = request.getParameter("action");
         if("action".equals(str)) {
              Student rem = home.create(remote.setFname(stu.getStudentId(),stu.getFname(),stu.getLname(),stu.getStandard(),stu.getFyear());
              out.println(stu.getStudentId() + "Student Created");
         } else if ("modify".equals(str)) {
              Student remote  = home.findByPrimaryKey(stu.getStudentId());
              remote.setFname(stu.getFname());
              remote.setFname(stu.getLname());
              remote.setFname(stu.getStandard());
              remote.setFname(stu.getFyear());
              out.println(stu.getStudentId() + "Student modified");
         } else if ("delete".equals(str)) {
              Student stu1  = home.findByPrimaryKey(stu.getStudentId());
              stu1.remove();
              out.println(stu.getStudentId() + "Student deleted");
    } catch (Exception e) {
         out.println("Exception e"+e.toString());
    %>
         </body>
    </html>
    Regards,
    Vivek Ojha

  • Does WLS 6.1 sp2 allow (bean managed) entity beans to have transaction mode NOTSUPPORTED?

    Hi,
    I have created two bean managed entity beans, User and Role, abstracting users
    and groups in a ldap base. A User may have more than one Role. This is represented
    by a (bean managed) 1:many relationship directed from User to Role. For some weird
    reasons I get a transaction rollback when reading data, when transactions are
    turned on (REQUIRED).
    While we where running WLS 6.1 sp1 we had no problems with this as we could set
    transaction to NOTSUPPORTED for these two EJBs. Due to other hickups we had to
    upgrade to sp2 and suddenly the error reappears leading me to believe that NOTSUPPORTED
    isn't allowed anymore by the WLS. I know that NOTSUPPORTED isn't required by the
    EJB spec, but containers may support it and obviously WLS used to do just that.
    I have not seen any change in the release notes of sp2 that indicates that this
    behaviour has changed.
    Does anybody know if WLS really doesn't support NOTSUPPORTED for enity beans anymore
    in sp2?
    If anybody are curiuos or have any good ideas, the stacktrace I get is:
    javax.ejb.TransactionRolledbackLocalException: EJB Exception:
    - with nested exception:
    [javax.ejb.EJBException
    - with nested exception:
    [weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion:
    sync=weblogic.ejb20.internal.TxManager$TxListener@1c2906 - with nested exception:
    [java.util.ConcurrentModificationException]]]
    Start server side stack trace:
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
         javax.ejb.TransactionRolledbackLocalException: EJB Exception:
    - with nested exception:
    [javax.ejb.EJBException
    - with nested exception:
    [weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion:
    sync=weblogic.ejb20.internal.TxManager$TxListener@1c2906 - with nested exception:
    [java.util.ConcurrentModificationException]]]
    java.util.ConcurrentModificationException
         at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:535)
         at java.util.LinkedList$ListItr.next(LinkedList.java:476)
         at weblogic.ejb20.manager.DBManager.beforeCompletion(DBManager.java:370)
         at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManager.java:481)
         at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:551)
         at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:88)
         at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:980)
         at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1504)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:216)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:190)
         at weblogic.ejb20.internal.BaseEJBLocalObject.postInvoke(BaseEJBLocalObject.java:207)
         at com.takecargo.domainentities.role.RoleBean_1ipw6_ELOImpl.getName(RoleBean_1ipw6_ELOImpl.java:86)
         at com.takecargo.domainentities.role.RoleConverter.getVOforRoleLocal(RoleConverter.java:51)
    Any kind of help would be appreciated:)
    Regards,
    Brynjar Glesnes

    WLS support NotSupported on Entity Beans.
    It looks like you've hit a bug in the EJB container where an internal Collection class has been modified while the
    container is running through an iterator on it.
    You should open a case with [email protected]
    -- Rob
    Brynjar Glesnes wrote:
    Hi,
    I have created two bean managed entity beans, User and Role, abstracting users
    and groups in a ldap base. A User may have more than one Role. This is represented
    by a (bean managed) 1:many relationship directed from User to Role. For some weird
    reasons I get a transaction rollback when reading data, when transactions are
    turned on (REQUIRED).
    While we where running WLS 6.1 sp1 we had no problems with this as we could set
    transaction to NOTSUPPORTED for these two EJBs. Due to other hickups we had to
    upgrade to sp2 and suddenly the error reappears leading me to believe that NOTSUPPORTED
    isn't allowed anymore by the WLS. I know that NOTSUPPORTED isn't required by the
    EJB spec, but containers may support it and obviously WLS used to do just that.
    I have not seen any change in the release notes of sp2 that indicates that this
    behaviour has changed.
    Does anybody know if WLS really doesn't support NOTSUPPORTED for enity beans anymore
    in sp2?
    If anybody are curiuos or have any good ideas, the stacktrace I get is:
    javax.ejb.TransactionRolledbackLocalException: EJB Exception:
    - with nested exception:
    [javax.ejb.EJBException
    - with nested exception:
    [weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion:
    sync=weblogic.ejb20.internal.TxManager$TxListener@1c2906 - with nested exception:
    [java.util.ConcurrentModificationException]]]
    Start server side stack trace:
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
    javax.ejb.TransactionRolledbackLocalException: EJB Exception:
    - with nested exception:
    [javax.ejb.EJBException
    - with nested exception:
    [weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion:
    sync=weblogic.ejb20.internal.TxManager$TxListener@1c2906 - with nested exception:
    [java.util.ConcurrentModificationException]]]
    java.util.ConcurrentModificationException
    at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:535)
    at java.util.LinkedList$ListItr.next(LinkedList.java:476)
    at weblogic.ejb20.manager.DBManager.beforeCompletion(DBManager.java:370)
    at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManager.java:481)
    at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:551)
    at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:88)
    at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:980)
    at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1504)
    at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:216)
    at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:190)
    at weblogic.ejb20.internal.BaseEJBLocalObject.postInvoke(BaseEJBLocalObject.java:207)
    at com.takecargo.domainentities.role.RoleBean_1ipw6_ELOImpl.getName(RoleBean_1ipw6_ELOImpl.java:86)
    at com.takecargo.domainentities.role.RoleConverter.getVOforRoleLocal(RoleConverter.java:51)
    Any kind of help would be appreciated:)
    Regards,
    Brynjar Glesnes

Maybe you are looking for

  • Keyboard Tips & Tricks

    Hello, First of all Happy Holidays to all. I have an old keyboard (the kind that was shipped out with the first iMacs 233-350MHz, the ones before the pro keyboards came out.) I was wondering if anyone of you can give some tips on shortcuts that can b

  • Crossing Platforms

    Do I have to pay to switch platforms from windows to mac? I have CS3 for windows, and was originally told by customer service that I could switch for free. Now that my new Mac has arrived I called again and was told that I had to buy the software aga

  • Budget Exceeded Error in CJ88

    Dear Friend's When i am doing a perodic settlement of project then system shows error message "Budget Exceeded." But actually sufficient budget is available against that wbs element. Why this error is showing at the time of settlement. Pls guide me o

  • BC4J Conneciton Pooling issue

    I am having an issue in JDeveloper where when the jbo.doconnectionpooling property is set to 'true'. When my HttpContainer is being released, a NullPointerException is thrown from the DefaultTxnHandlerImpl. Any ideas as to why this is happening or ho

  • Whilst Charging, Iphone is almost unresponsive

    Not sure if anybody else has issues with this, but since the IOS4 update, whenever my phone is on charge the phone becomes really slow and jumpy. Cant even type or browse apps as it slows down to much and then tries to catch up and does a billion thi