Container Managed Entity Beans and Client Identifier in Oracle

Is it possible to use Container Managed Entity Beans (EJB with CMP)
in a way that the Oracle database sessions still know the
individual Client Identifiers of the actual users
(not just the Identifier of the proxy user defined in the
Connection Pool)?
If Yes: How?
If No: The consequence would be that the
technologies EJB with CMP cannot be user together with
Oracle Virtual Private Databases (VPN) because VPN requires
some kind of Client Identifier.
I am grateful for any hint.
Regards,
Martin Siepmann
+49 (0)163 / 7765328

Not quite an auto-incrementing PK, but it is managed by the container. the following is from the turorial
Generating Primary Key Values
For some entity beans, the value of a primary key has a meaning for the business entity. For example, in an entity bean that represents a phone call to a support center, the primary key might include a time stamp that indicates when the call was received. But for other beans, the key's value is arbitrary--provided that it's unique. With container-managed persistence, these key values can be generated automatically by the EJB container. To take advantage of this feature, an entity bean must meet these requirements:
* In the deployment descriptor, the primary key class is defined as a java.lang.Object. The primary key field is not specified.
* In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object.
* In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
In these entity beans, the primary key values are in an internal field that only the EJB container can access. You cannot associate the primary key with a persistent field or any other instance variable. However, you can fetch the bean's primary key by invoking the getPrimaryKey method, and you can locate the bean by invoking its findByPrimaryKey method.
Maybe that is good enough
christina

Similar Messages

  • Setting composite key in Container Managed Entity Bean

    In my database table i set primary key to two columns making them as composite key. how do i set that in my container managed entity bean home interface findByPrimaryKey() method and in deployment descriptor file.

    1. create another class (say CompositePK) that will embed the two fields keyA and keyB corresponding to the two pk of your table (declare them public) .
    2. in your Bean declare keyA and keyB public.
    3. in the dd declare your bean primary-key-class as CompositePK and the primary-key-field as keyA and keyB.
    this is the method i use (with BAS) even if the key is simple (such as Integer).

  • Finder method in container-managed entity bean

    Finder method of a container entity bean is taking the primary key class object of another entity bean. How to map this in the xml descriptor file weblogic-cmp-rdbms.xml for this type of beans.
    I am trying to deploy the jasmine computer store of Mastering EJB by EdRoman.
    I couldn't write the deployment file weblogic-cmp-rdbms.xml for Order Entity bean which uses CustomerPK as an argument in its finder method.
    Please tell me how to write this. I am trying on weblogic 5.1
    Thanx in advance
    Srivatsa

    hello,
    in container managed persistence, you specify on your xml file the name of your table. so the primary key you want to use have to be a foreign key in your table. otherwise i don't think that you can use a container managed persistence.
    Najib.

  • Unable to call Container Managed Entity Bean

    Hi
    I am developing a JMS application using NetBeans 5.5.1 and Sun Java Application Server 9.0 and J2EE 1.4.When I run the application client it throws me following EXCEPTION:
    {color:#ff0000}Sep 9, 2010 1:43:43 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>
    WARNING: ACC003: Application threw an exception.
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MDBDestinationFactory
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at jmsdemo.Main.main(Main.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
    at com.sun.enterprise.appclient.Main.main(Main.java:180)
    Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:340)
    at com.sun.enterprise.appclient.Main.main(Main.java:180)
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
    ... 1 more
    Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MDBDestinationFactory
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at jmsdemo.Main.main(Main.java:30)
    ... 7 more
    {color}{color:#000000}Source Code for Message Driven Bean:
    package jmsdemo;
    import javax.ejb.*;*
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.TextMessage;
    *public class MDBBean implements MessageDrivenBean, MessageListener {*
    private MessageDrivenContext context;
    *public void setMessageDrivenContext(MessageDrivenContext aContext) {context = aContext;}*
    public void ejbCreate() {}
    public void ejbRemove() {}
    *public void onMessage(Message aMessage) {*
    if(aMessage instanceof TextMessage)
    TextMessage t = (TextMessage)aMessage;
    try
    System.out.println("Received message : " + t.getText());
    *}catch(Exception e) {e.printStackTrace();}*
    Source code for JMS Client:
    package jmsdemo;*
    import javax.jms.;
    import javax.naming.*;*
    *public class Main {*
    *public Main() {*
    public static void main(String[] args) throws Exception
    *// TODO code application logic here*
    InitialContext ic = new InitialContext();
    ConnectionFactory cf = (ConnectionFactory)ic.lookup("java:comp/env/jms/MDBDestinationFactory");
    Destination dest = (Queue) ic.lookup("java:comp/env/jms/MDBBean");
    Connection con = cf.createConnection();
    Session session = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
    MessageProducer mp = session.createProducer(dest);
    TextMessage tm = session.createTextMessage();
    tm.setText("Hello world .,.");
    System.out.println("Sending message ...");
    mp.send(tm);
    con.close();
    Generating code for ejb-jar.xml
    <?xmlversion="1.0"encoding="UTF-8"?>*
    *<ejb-jarversion="2.1"xmlns="[http://java.sun.com/xml/ns/j2ee%22xmlns:xsi=%22http://www.w3.org/2001/XMLSchema-instance%22xsi:schemaLocation=%22http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd]">*
    *<display-name>JMSDemo-ejb</display-name>*
    *<enterprise-beans>*
    *<message-driven>*
    *<display-name>MDBMDB</display-name>*
    *<ejb-name>MDBBean</ejb-name>*
    *<ejb-class>jmsdemo.MDBBean</ejb-class>*
    *<transaction-type>Container</transaction-type>*
    *<message-destination-type>javax.jms.Queue</message-destination-type>*
    *<message-destination-link>MDBDestination</message-destination-link>*
    *<activation-config>*
    *<activation-config-property>*
    *<activation-config-property-name>acknowledgeMode</activation-config-property-name>*
    *<activation-config-property-value>Auto-acknowledge</activation-config-property-value>*
    *</activation-config-property>*
    *<activation-config-property>*
    *<activation-config-property-name>destinationType</activation-config-property-name>*
    *<activation-config-property-value>javax.jms.Queue</activation-config-property-value>*
    *</activation-config-property>*
    *</activation-config>*
    *</message-driven>*
    *</enterprise-beans>*
    *<assembly-descriptor>*
    *<container-transaction>*
    *<method>*
    *<ejb-name>MDBBean</ejb-name>*
    *<method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <message-destination>
    <display-name>DestinationforMDB</display-name>
    <message-destination-name>MDBDestination</message-destination-name>
    </message-destination>
    </assembly-descriptor>
    </ejb-jar>
    Please let me when I am going wrong.
    Thanks in advance
    Senthil{color}

    Hi
    I am using sun java application server 9.0 and netbeans 5.5.1. For your information the Netbeans 5.5.1 has created already Queue in the sun java application server 9.0 when I created Message driven bean and I am able to see the queue connection in the Sun application server admin console. Even then I getting the same exception displayed below:
    {color:#ff0000}Sep 11, 2010 11:45:17 AM com.sun.enterprise.appclient.MainWithModuleSupport <init>
    WARNING: ACC003: Application threw an exception.
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MDBDestinationFactory
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at jmsdemo.Main.main(Main.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
    at com.sun.enterprise.appclient.Main.main(Main.java:180)
    Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:340)
    at com.sun.enterprise.appclient.Main.main(Main.java:180)
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
    at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
    ... 1 more
    Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MDBDestinationFactory
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at jmsdemo.Main.main(Main.java:30)
    ... 7 more
    Java Result: 1
    {color}
    The following connection properties {color:#0000ff}*jmsCF-jms_MDBBean.sun-resource_*{color} file:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
    <connector-resource enabled="true" jndi-name="jms/MDBDestinationFactory" object-type="user" pool-name="jms/MDBDestinationFactory">
    <description/>
    </connector-resource>
    <connector-connection-pool connection-definition-name="javax.jms.QueueConnectionFactory" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" max-pool-size="32" max-wait-time-in-millis="60000" name="jms/MDBDestinationFactory" pool-resize-quantity="2" resource-adapter-name="jmsra" steady-pool-size="8"/>
    </resources>
    The following connection properties {color:#0000ff}_jms-jms_MDBBean.sun-resource_{color} file:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
    <admin-object-resource enabled="true" jndi-name="jms/MDBBean" object-type="user" res-adapter="jmsra" res-type="javax.jms.Queue">
    <description/>
    <property name="Name" value="MDBBean"/>
    </admin-object-resource>
    </resources>
    Please help.
    Thanks in advance
    Senthil

  • Use same transaction in entity-bean and Datasource

    Hello
    I've got following problem. In my stateless container managed transaction Sessionbean i do some inserts and update on my container managed entity bean. In the same transaction I have to read some informations on the database. Some of those informations are already set by the entity bean, but not yet commited. Now I want to read them through a javax.sql.DataSource. But this Datasource doesn't use the same transaction as the session bean.
    Question: Is it possible to let a Datasoucre use the same Transaction as Sessionbean?
    (i work with WSAD 4.0.3)
    Thanks

    Hi,
    You would have to check that you are using an XADataSource instance, instead of a 'regular' DataSource instance (which will not adopt the transaction started by the application server). In particular, the JNDI lookup name of the DataSource should actually point to an instance of XADataSource; a special type for container transactions.
    The administration/deployment tools of the WS will allow you to do that, under Resource Factories or DataSources somewhere.
    Both types look the same towards your application code, so your session bean is probably fine the way it is and does not need rewriting. It is merely in the setup of the WS server that the difference lies.
    Best,
    Guy
    http://www.atomikos.com

  • Problem with non-container managed entity manager

    i am working on a project, in which i am using entity beans.i use netbeans, glassfish as application server and toplink as persistence provider .
    i created a java class that handles all the operations with the entitys, which means i using non-container managed entity manager.
    in the constructor
    try{
                EntityManagerFactory emf = Persistence.createEntityManagerFactory("voidPU");
                entityManager = emf.createEntityManager();
            catch(Exception ex){
                throw new EJBException(ex.getMessage());
            }then i call a function in this class from a servlet
    the code of the function
    List users = null;
            try {
                ProgLanguages progLanguage = entityManager.find(ProgLanguages.class, languageId);
                users = (List) progLanguage.getUserIdCollection();
            catch(IllegalStateException illegalStateException){
                throw new EJBException(illegalStateException.getMessage());
            catch(IllegalArgumentException illegalArgumentException) {
                throw new EJBException(illegalArgumentException.getMessage());
            }i got an IllegalArgumentException saying Unknown entity bean class: class vanguard.server.entity.ProgLanguages, please verify that this class has been marked with the @Entity annotation
    what confuses me is that sometimes it works and most of the time it does not work, have i made anything wrong?, or there is a problem with any of the tools netbeans, glassfish, or toplink?

    Is it always the same entity that is reported as 'unknown' ? You mention that it works sometimes but is it the same deployment and the same code that works? The first thing I would verify is that the ear is being created as expected by netbeans. Check the persistence.xml file and verify that all of the classes are listed that will be used as entities.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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

  • EJB 3.0 entity beans and WebDynpro models

    Hi all,
    first off all my setup:
    WebDynpro Development Component: dcA
    EJB Module Development Component: dcB
    i wan't to create Entity Beans in dcB an use it for my model in dcA.
    My questions:
    1. Why does the "New Wizard" only offer EJB 3.0 Session and Message Beans an no Entity Beans? What is the correct way for creating Entity Beans in DevStudio?
    2. Is ist right that i have to define a public Part containing the Entity Bean to make it visible to dcA?
    Regards,
       Christian

    Hi,
    I'm experiencing same problems, is this a bug or an feature?

  • Bean Managed Entity Beans(EJB) using Tangosol.

    I am trying to use Bean Managed Entity Beans using Tangosol Coherence.
    The entity bean is currently configured in the weblogic-ejb-jar.xml with:
    <max-beans-in-cache>200</max-beans-in-cache>
    In the public void ejbLoad() method, I am calling the Tangosol Cache to load the entity bean.
    If we have have more that 200 request coming at the same time, we get an OutOfMemoryError exception.
    Is there anyway to overcome this limitation by somehow having the ejb cache to use the tangosol cache?
    Thanks for any help in advance.
    Krishan

    So far, it's not immediately obvious to us what the exact problem is that you are seeing. It sounds like the VM would be using at least 200MB just for the application server's own internal cache, for example, and that you are also using Coherence within the application server to provide additional caching.
    If possible, we should set up a phone call with you and your team, and we could get an engineer from our end to walk through your specific use case with you, so that we could understand what the exact technical challenge(s) is(are) in this particular application.
    Peace.
    p.s. You can email [email protected] directly to schedule a call.

  • Can i user UserTransaction  in a Container-managed transaction Bean

    can i use UserTransaction to control transaction boundaries in a container-managed transaction bean method?
    below is the method:
    there is one-to-many between Employees and SalaryItem
    @TransactionAttribute(value = TransactionAttributeType.REQUIRED)
    private void initEmployeesSalary(Long salarySumId) {
    for(Employees employees: liEmployees){
    for (int i = 0; i < 20; i++) {                                                           
    SalaryItem item = new SalaryDetailItem();
    employees.addSalaryItem(item);
    when there are about 1000 employees,the method run very slow.
    What do you think I should do?
    null

    Hi again,
    The EJB specs say that a stateful Session Bean with CMT is NOT allowed to use the UserTransaction; see page 361 of the EJB2.0 specification. So combining them will not (or should not) work.
    I suggest CMT+SessionSynchronization combined with using a flag to indicate whether notify should be called or not. Otherwise, you could try splitting up the bean into two beans: one with CMT and another one without. The one without CMT could use the UserTransaction and notify.
    Also, you might want to check http://www.onjava.com/pub/a/onjava/2001/10/02/ejb.html
    Hope that helps a bit,
    Guy
    http://www.atomikos.com

  • Entity Beans and Session beans to represet Business lOgic

    How cam we implement Entity Beans and Session beans to represent Business Logic.
    Can anyone explain how can we do this.
    Regards...

    I have session beans calling method in entity beans and any client
    doesn't have access to entity beans, only via session beans.
    If i define security policy and method permissions for session beans
    only, do entity beans use that permissions when calling their methods
    from sessions beans OR should i define the security policy for entity
    beans separately?If you want to set the permission on individual
    methods of entity bean ( with different roles)
    you have to do it separately.
    If you want to delegate the Authenticated user along with
    the method call to the Entity Bean you can use
    run-as-identity-principal.
    For more detail please check out the EJB2.0 Spec.
    -utpal

  • How to use same transaction when calling CMP entity beans and  DAO (JDBC)

    We are currently using Weblogic 8.1 SP2 with an Oracle 10g database (using XA thin and non-XA drivers).
    We have a session bean that invokes an entity bean and a DAO (data access object pattern) in order to add data in 2 separate tables (account and history). Rows are added to the first (account) table using a CMP Entity bean while inserts are done in the 2nd (history) table using a DAO. Here is some pseudo code:
    addHistorySessionBean (trans-attribute="Required")
    begin
    Step #1 - call addAccountEntityBean (trans- attribute="Required")
    Step #2 - call addHistoryDAO (get datasource, connection)
    end
    The 2nd table (history) has a foreign key constraint to ensure that the corresponding key exists in the first (account) table. Unfortunately, DAO inserts on the 2nd (history) table fail with a foreign key constraint violation (INTEGRITY CONSTRAINT VIOLATION - PARENT KEY NOT FOUND!) since they cannot see the row added to the 1st (account) table in step #1 by the CMP entity bean.
    How does one ensure that all this is done in a single transaction ? It appears that the app server creates two seperate transactions (one for the session bean facade and the entity bean and a 2nd transaction (when we retrieve a connection using the same data source JNDI name) for the DAO.
    A post on server side suggested using a "<resource-ref>" in the session bean to tie the two potentially separate transactions together, but that does not work for us. However, I am not sure if we are doing that correctly. After we define the resource ref in the session facade bean, do we use the resource ref "name" attribute to lookup the datasource or do we still lookup the datasource by JNDI name ? Do we need to define the resource-ref tag in the entity bean also ?
    Does Weblogic allow using a single transaction for this type of a scenario ? How does one specify within Weblogic that the same transaction should be utilized by the entity bean and any subsequent DAOs?
    People have also suggested that we defer constraint checking until the transaction(s) are committed but that sounds like a work acount without addressing this issue. Would postponing the constraint checking in Oracle cause any additional overhead ?
    Any suggestions with specific examples or documentation on how to address this issue will be gratefully appreciated.

    Thanks for your suggestion. Unfortunately, this does not work since it appears that there are 2 separate transactions going on here. One, the original one initiated by the session bean and used by the entity bean and the other initiated by the DAO. Any other ideas appreciated.
    Hi,
    Try setting the delay-database-inserts tag to
    ejbCreate in RDBMS descriptor file.
    http://bernal/stage/wls/docs81/ejb/DDreference-cmp-jar
    .html#1113981
    vasanthi ramesh

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

  • Entity Beans and Caching

    Hi,
    My environment is:
    - Weblogic 5.1 running on Solaris
    - Oracle 8i database server
    - Two physical servers clustered together to form one logical server
    I can possibly upgrade to Weblogic 6 or later if it'll help solve my
    problem.
    Here's what I'm trying to accomplish:
    I want to write entity beans using bean-managed persistence. The BMP
    part of it is strongly preferred because our DBAs like to see and tune
    all of the queries we send from the application.
    In many cases, the data I'm querying is largely static. I want to
    write EJBs that will cache the data in memory and avoid reading it
    from the database server every time the EJB is invoked, unless it
    knows that the data has changed.
    I've done this successfully with single-server installations, but I'm
    not sure how it'll work with a clustered server. Assuming nothing
    outside of my two Weblogic servers is updating my database, can I
    configure the EJB to have exclusive access to the database and count
    on Weblogic to manage the state between the two servers? Or do I have
    to implement some kind of custom signalling scheme so that an EJB in
    one container can notify any EJBs in the other container with the same
    primary key when it has updated the underlying data?
    I know from experience that the container will call the ejbStore()
    method whenever a transaction ends. My usual BMP pattern in the past
    has been to keep track of whether any data has changed during the
    transaction and update only those database columns, if any, that
    actually changed. But I don't think the store method has any way of
    notifying the container as to whether or not it actually stored
    anything; hence, I can't see how the container would know when to
    order the entity bean on the opposite server to reload itself.
    Thanks.

    The 6.1 implements functionality you want:
    http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1121105
    if you use 5.1 you can use this approach:
    http://dima.dhs.org/misc/readOnlyUpdates.html
    Frank LaRosa <[email protected]> wrote:
    Hi,
    My environment is:
    - Weblogic 5.1 running on Solaris
    - Oracle 8i database server
    - Two physical servers clustered together to form one logical server
    I can possibly upgrade to Weblogic 6 or later if it'll help solve my
    problem.
    Here's what I'm trying to accomplish:
    I want to write entity beans using bean-managed persistence. The BMP
    part of it is strongly preferred because our DBAs like to see and tune
    all of the queries we send from the application.
    In many cases, the data I'm querying is largely static. I want to
    write EJBs that will cache the data in memory and avoid reading it
    from the database server every time the EJB is invoked, unless it
    knows that the data has changed.
    I've done this successfully with single-server installations, but I'm
    not sure how it'll work with a clustered server. Assuming nothing
    outside of my two Weblogic servers is updating my database, can I
    configure the EJB to have exclusive access to the database and count
    on Weblogic to manage the state between the two servers? Or do I have
    to implement some kind of custom signalling scheme so that an EJB in
    one container can notify any EJBs in the other container with the same
    primary key when it has updated the underlying data?
    I know from experience that the container will call the ejbStore()
    method whenever a transaction ends. My usual BMP pattern in the past
    has been to keep track of whether any data has changed during the
    transaction and update only those database columns, if any, that
    actually changed. But I don't think the store method has any way of
    notifying the container as to whether or not it actually stored
    anything; hence, I can't see how the container would know when to
    order the entity bean on the opposite server to reload itself.
    Thanks.--
    Dimitri

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

Maybe you are looking for

  • Error in installing Adobe AIR runtime (Windows)

    I've been trying to install TeeBoard to be used with OBS, however, AIR will not install no matter what i do. I've followed all the help on the support page and none of it worked. It keeps saying i need administrator access even though i'm running it

  • Package has multiple "SMS Distribution Manager" entries on DP it is not published to.

    I have an issue with packages seeming to deploy to DPs they are not being published to. We have an aging SCCM 2007 system, which is currently being wound down, so we can migrate to Config Manager 2012. The 2007 system currently has 3 servers acting a

  • What is in the Audition 3.0.1 bugfix?

    Changes in Adobe Audition 3.0.1: • Spectral tools no longer crash machines with more than four CPU  cores. • The Graphic Phase Shifter effect has been re-enabled. • Performance while recording MIDI data has been improved.  • The Sequencer will now re

  • How can i stop upgrade in progress

    upgrading to IOS 6 on Iphone, is there a way to stop the upgrade? seems to be stuck, over an hour and half so far.....

  • Cannot flag email in shared mailbox

    We have recently moved our mail services from an old Exchange server to the cloud (office365) and one of our shared mailboxes is causing troubles. The users cannot flag the mails anymore (so no-one knows who is doing the follow-up). When flagging a m