Making AQ usage transactional across session beans, using mosly JMS syntax

I need to determine what I need to have in place in order for JMS/AQ messages to be "fully transactional".
I have a J2EE server application that will send JMS/AQ messages to a queue. I have a standalone application that reads messages from the queue, does some work, and then makes calls on multiple session beans (hosted in the original J2EE server application). Actually, it would likely be multiple calls to the same session bean method.
Once the standalone application reads a message from the queue, I need to ensure that if any action performed as a result of that message fails, that all the operations performed, including the removal of the message from the queue, are rolled back.
First of all, if I use an Oracle XA-compliant datasource, if one of the session bean calls fail, I can rollback the current transaction, but will this properly roll back any work that earlier session bean calls (made on the same transaction) did, even if they were successful (at the time)? Note that I have two JVMs, one running the J2EE application, and the other a standalone application reading from the queue.
Second, on committing or rolling back the message retrieval itself, I noticed from examples in the Oracle AQ Application Developer's Guide that if I create my QueueSessions with "AQDriverManager.createAQSession()", that I can pass a Connection object, and then later "commit" or "rollback", manually, perhaps if I got an EJBException from a session bean call.
However, I am trying to write my JMS/AQ code so that it uses as little of the direct AQ api as possible, staying with the standard JMS api. As a result, I'm using the JMS version of this, which is "QueueConnection.createQueueSession()". When I do this, however, it seems as if I lose control over the transaction.

Ok, I think I've answered some of this for myself, but I still have some concerns.
I see that the QueueSession object that I get back from "queueConnection.createQueueSession()" is likely going to actually be an instance of the "AQjmsSession" class, so I can cast to that, and then I can call "commit" or "rollback".
What is unclear from the javadoc description is what happens when "close()" is called on the session object. Does this do an implicit "commit()", perhaps unless "rollback()" has already been called?
I'm still a little uncertain about whether the scope of my transaction will be wide enough to protect everything that needs to be protected.
For instance, I assume that my transaction starts when my consumer (not in an application server) reads the message from the queue. At that point, my consumer does some "screen-scraping" work. When it's done, it will call a session bean on the application in the application server (separate JVM, in other words), which will create some EJB entity objects and also insert raw database rows. The session bean will then return, and then the original method which read a message from the queue will be completed.
What I need to know is what will happen if ANYTHING in that process fails, either in the external consumer, or in the session bean, or creating EJB entities? That is, will the entire transaction be rolled back, undoing the EJB entity creations AND the removal of the message from the message queue?
If this can possibly work, I'm assuming this would be utilizing an XA datasource, or a non-emulated data source (which I think means the same thing).

Similar Messages

  • How to run a client program in Session bean using weblogic 8.1

    Hi
    I am new to weblogic server 8.1. I sucessfully deployed session ejb Session Bean. I created sessionbean jar file and put it it classpath also.
    and also i created sessiobeanclient jar file, it included in class path.
    While running client program it throws exception like noclass def found exception
    plz tell me the right way to run the session ejb program.
    bye

    Hi,
    You have to follow the given steps before you are going to run the client program that invokes the session bean .
    1)set the Weblogic Environment using the tool setWLSEnv
    2)place the Session bean jar file in classpath
    3)run the client program
    Note:If the client has to execute on remote machine we need to copy client class,remote interface, home interface and other classes which are used as
    parameters and return types.
    Regards
    Anilkumar kari

  • Probleme with transaction in session beans

    Hello.
    i create an session bean which call enties beans.
    When i execute un example first time, its correct.
    when i execute for second time, the methode don't stop.
    i think it is problem of transaction.
    thank you

    Hi,
    It is impossible to answer your with the given information. When ever you are asking a question please put the relavent informatin like code and deployment descriptors. So please do post the required information.
    Ashok

  • Connection Failure for JDBC system in Session Bean using JCA

    Hi,
    I am trying to write a session bean that runs a query
    against a JDBC system, but I keep seeing the following
    error in the default trace file in the J2EE log folder:
    14##0#0#Path##Java###Throwing
    #1#java.sql.SQLException: Invalid connection string
    attribute: Database name is required but not supplied#
    #1.5#
    This is the code, with the line marked (*) being the point where the exception is thrown:
    public void getConnection(String sURL, String sUser, String sPassword) {
    ManagedConnectionFactory mcf = null;
    IConnectionFactory cf = null;
    IConnectionSpec cs = null;
    try {
    mcf = new JDBCManagedConnectionFactory();
    cf = (IConnectionFactory) mcf.createConnectionFactory();
    cs = cf.getConnectionSpec();
    cs.setPropertyValue("UserName", "sa");
    cs.setPropertyValue("Password", "admin");
    cs.setPropertyValue"driver",
    "com.sap.portals.jdbc.sqlserver.SQLServerDriver");
    cs.setPropertyValue("url",
    "jdbc:sap:sqlserver://localhost:1433;DatabaseName=pubs");
    conn = cf.getConnectionEx(cs);  (*)
    I have tried adding another property value, like so:
    cs.setPropertyValue( "DatabaseName", "pubs");
    (or)  cs.setPropertyValue( "Database", "pubs" );
    but I still get the same exception. What does this
    exception really mean, what is missing from the
    configuration information ?
    Also, in the default trace file of the J2EE engine, the
    configuration information is printed out, but in an
    encrypted format, (see below), is it possible to have it
    print out this information in a readable format ?
    #1.5#005056A41E66006200000092000009AC000406E03C94F3D9#1133460065906#com.sap.portal.connectors.JDBC#sap.com/CFV3#com.sap.portal.connectors.JDBC#Guest#0####71758520629411daacf7005056a41e66#SAPEngine_Application_Thread[impl:3]_14##0#0#Info##Plain###UserName: ????n????????????????????d?????????????????????????????????????????????s???????????????????????????????????????????????0??????????????????????????????????????????????????h?????0??????R???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????s?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????c???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????u??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????c???????????????????????????????????????????c????????????????3?????????3????e??????????????????????????????????????????????????l???????0????????1????1?????????????????????????????????????????????????????????s?????p?????????????????????????????????????????????????????????????????6?????????????3??????????????s????????????????????t???????????s????????????????????????????????????????????????????????????????????????s????????????????????????????????????????????????????????s?????????????????????????????????g????????????????????????????????????????????????????????????????????????? Password: ******** URL: ???????????????n??????????????????????????????????????????????????????????????????????????0?????e??????????????????????????r?????????????s?????????????O??????????????2???????????7????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????:????5???T?????????????????????????l?????????1????????????????????????????????????????????????????????????????????????????2??????????????????????????????????????????????????????????????????????????????????????????????????h???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????a??????????????????????????????????????????????????????????????????????????????????????????????????S??????????????????????????????????????????????????????????????????????????????????2???????????????????????????u???????????????????????????????????????????????????????????????????????s???????????????????????????????????????????????????????????????????????????????????????????????s?????????????????????????????????????????.?????????????????????????????????????????????????????????????????1????????????????????????????????????l????5??????????? Driver: com.sap.portals.jdbc.sqlserver.SQLServerDriver#
    #1.5#0

    Hi Vladimir,
    thanks for your response. The reason I am accessing a
    JDBC source via JCA is to get a feel for how JCA works.
    What I ultimately want to do is construct a bean that can
    give queries to different kinds of sources; JDBC, and SAP
    (R3, CRM), and possibly sources like Siebel. For this, I
    believe I should use the Connector Gateway Service, as
    described in the "Using the JDBC Connector" and "Using
    the SAP Backend System Connector" sections of the SAP
    Portal Developer's Guide. But for now, my first approach
    was to use the approach described in "Connecting via
    J2EE" subsection of "Using the JDBC Connector" (see
    http://help.sap.com/saphelp_nw04/helpdata/en/30/a0f17aacb34b108b39a96acc33da3f/content.htm)
    Thanks,
    Colm.

  • Create session bean using interfaces, not implementation classes

    Hi,
    I'm using interfaces and session beans for my persistence/data layer in my adf application.
    I've created a data control for my session bean and during creation of this data control, javabean.xml files are created for the different interfaces that are used in my session bean.
    If I create bindings on these methods, interfaces in jspx-documents I will get errors because he can't find the impl-classes that implement these interfaces.
    When using interfaces in your session bean (as return values or parameters) instead of classes you need to manually create javabean.xml files for the implementation classes.
    It's required by the databindings/datacontrol that the implementation-classes are described in a javabean-format as well? Is this a spec we need to adhere to?
    Could someone verify that you need to create javabean.xml-files for as well the interfaces as the classes when you're working with interfaces in your session beans?
    regards,
    Nathalie

    A patch was released by Oracle to be able to work with Interfaces and so it's not required to work with implementation-classes.
    Patch for 5726754(Base bug 5657179)

  • Could not access Local Session Bean using JNDI lookup

    Hi EJB Guru,
    I am quite new to EJB 3.0 but have had a good deal of success including using JNDI to lookup Remote Stateless Session Bean in EJB 3.0. However, looking up local Stateless Session Bean prove more challenging with I had anticipated.
    Here is my code
    as follows:
    public interface Calculator {
        public int add(int x, int y);
        public int subtract(int x, int y);
    import javax.ejb.Remote;
    @Remote
    public interface CalculatorRemote extends Calculator {
    import javax.ejb.Local;
    @Local
    public interface CalculatorLocal extends Calculator {
    import javax.ejb.Local;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import bean.CalculatorLocal;
    import bean.CalculatorRemote;
    @Stateless
    public class CalculatorBean implements CalculatorRemote, CalculatorLocal {
        public int add(int x, int y) {
            return x + y;
        public int subtract(int x, int y) {
            return x - y;
    import bean.*;
    import bean.Calculator;
    import bean.CalculatorLocal;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessLocalCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorLocal calculator = (CalculatorLocal) ctx.lookup("CalculatorBean/local");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    import bean.Calculator;
    import bean.CalculatorRemote;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessRemoteCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    }Output when running ClientAccessRemoteCalculator gives
    1 + 1 = 2
    1 - 1 = 0
    Output when running ClientAccessLocalCalculator on JBoss AS 4.0.5 gives:
    Exception in thread "main" javax.ejb.EJBException: Invalid invocation of local interface (null container)
    at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:75)
    at $Proxy0.add(Unknown Source) at ClientAccessLocalCalculator.main(ClientAccessLocalCalculator.java:14)
    JNDIView in JMX-Console in JBoss:
    +- CalculatorBean (class: org.jnp.interfaces.NamingContext)
    | +- local (proxy: $Proxy84 implements interface bean.CalculatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
    | +- remote (proxy: $Proxy83 implements interface bean.CalculatorRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
    Output when running ClientAccessLocalCalculator on SJSAS 9.0 gives:
    Exception in thread "main" javax.naming.NameNotFoundException: bean.CalculatorLocal not found
    C:\>asadmin
    Use "exit" to exit and "help" for online help.
    asadmin> list-jndi-entries
    Jndi Entries for server within root context:
    bean.CalculatorRemote: javax.naming.Reference
    jbi: com.sun.enterprise.naming.TransientContext
    jdbc: com.sun.enterprise.naming.TransientContext
    UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
    bean.CalculatorRemote__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
    bean.CalculatorRemote#bean.CalculatorRemote: javax.naming.Reference
    ejb: com.sun.enterprise.naming.TransientContext
    Command list-jndi-entries executed successfully.
    asadmin>I am using Application Client to lookup these Session Beans on Netbeans 5.5, JBoss AS 4.0.5 (EJB3 installer)/SJSAS
    9.0, SDK 1.5.0_11 on Windows XP platform.
    Any assistance would be much appreciated.
    Many thanks,
    Henry

    Hi Henry,
    Any direct global JNDI lookup is not portable. It works in some cases but not in others, which
    is why we recommend using the portable Java EE approach of declaring an ejb dependency
    and looking up that dependency via the bean's component environment (java:comp/env).
    This is true whether you're dealing with Remote or Local ejb dependencies.
    Local ejbs are not supported in the Application Client tier at all. In the server tier, there is no
    guarantee that a Local EJB even is assigned a global JNDI name since there's no requirement
    that it be available outside of the application in which the ejb is defined.
    You can find more information on these ejb access topics in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • Problem calling entity bean from session bean using sun one app server

    Hi,
    I am getting the following exception while calling entity bean(bmp) from stateless session(cmp)bean.
    SEVERE: IOP5012: Some runtime exception ocurred in IIOP: [javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: Unable to create reference org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 1015 completed: No]
    SEVERE: IOP5013: Unable to create reference: [org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 1015 completed: No]
    SEVERE: EJB5029: Exception getting ejb context : [CustomerEJB]
    SEVERE:
    WARNING: CORE3283: stderr: javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 9998 Maybe; nested exception is:
    WARNING: CORE3283: stderr: org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
    WARNING: CORE3283: stderr: at com.sun.corba.ee.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDelegate.java:114)
    WARNING: CORE3283: stderr: at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:358)
    WARNING: CORE3283: stderr: at javax.rmi.CORBA.Util.wrapException(Util.java:277)
    WARNING: CORE3283: stderr:
    My primary key implementation is
    public class CustomerEJBKey implements java.io.Serializable {
    static final long serialVersionUID = 3206093459760846163L;
    public String customerId;
    public DBConfigBean dbConfigBean;
    * Creates an empty key for Entity Bean: CustomerEJB
    /*public CustomerEJBKey() {
    public CustomerEJBKey(String customerId,DBConfigBean dbConfigBean){
    this.customerId = customerId;
    this.dbConfigBean = dbConfigBean;
    public String getCustomer(){
    return customerId;
    public DBConfigBean getDBConfigBean(){
    return dbConfigBean;
    * Returns true if both keys are equal.
    public boolean equals(Object key) {
    if(key instanceof CustomerEJBKey)
    return this.customerId.equals(((CustomerEJBKey)key).customerId) &&
    this.dbConfigBean.equals(((CustomerEJBKey)key).dbConfigBean);
    else
    return false;
    * Returns the hash code for the key.
    public int hashCode() {
    return customerId.hashCode() + dbConfigBean.hashCode();
    and entity bean method invocation is,
    homeFactory = EJBHomeFactory.getInstance();
    home = (CustomerEJBHome) homeFactory.lookup(CustomerEJBHome.class);
    remote = (CustomerEJB) PortableRemoteObject.narrow( home.findByPrimaryKey(new CustomerEJBKey(customerId,dbBean)), CustomerEJB.class);
    This works fine in Websphere and JBoss. Do you have any idea why I am getting this exception?
    Appreciate your response.
    Regards,
    Sankar.

    My suggestion is to put some System.out.println() statements and see if the output helps in any way in debugging. I can't think of anything on the top of my head although I have been working lightly on SunONE.
    By the way, you referred the stateless bean as CMP. Just wanted to tell you that you are wrong. The terms CMP and BMP refer to persistence, which is applied to Database tables and not to stateless/stateful session beans which are written for some specific purpose independent of underlying database.

  • Combining single transaction between session bean & application client

    Hi All,
    The following transaction exception was encountered when trying to combine a EmployeeSessionBean.create(Employee) method in an application client:
    Application Client output
    SEVERE: null
    javax.transaction.SystemException: org.omg.CORBA.UNKNOWN: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.UNKNOWN: WARNING: IOP00010002: Unknown user exception thrown by the server - exception: org.eclipse.persistence.exceptions.DatabaseException; message:
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    Error Code: 0
    Call: INSERT INTO EmployeeDB.Project (ID, NAME) VALUES (?, ?)
    bind => [2 parameters bound]
    Query: InsertObjectQuery(domain.Project@19d2d53) vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:117)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126)
    ----------END server-side stack trace---------- vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:332)
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:184)
    at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:873)
    at com.sun.enterprise.transaction.UserTransactionImpl.commit(UserTransactionImpl.java:208)
    at applicationClient(*applicationClient.java:229*)
    GF 3.1 Server log
    WARNING: A system exception occurred during an invocation on EJB EmployeeSessionBean method public void ejb.EmployeeSessionBean.create(Employee) javax.ejb.EJBException
    Caused by: javax.persistence.TransactionRequiredException
    at ejb.EmployeeSessionBean.create(*EmployeeSessionBean.java:27*)
    SEVERE: RAR5027:Unexpected exception in resource pooling
    java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    WARNING: RAR7132: Unable to enlist the resource in transaction. Returned resource to pool. Pool name: [ mysqlPool ]
    WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ mysqlPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.]
    WARNING: Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    Below is the code snippet of EmployeeSessionBean & client.applicationClient:
    @Stateless
    //@TransactionManagement(TransactionManagementType.BEAN)
    public class EmployeeSessionBean implements EmployeeService {   
        @PersistenceContext(unitName="EmployeeDB-PU")
        private EntityManager manager;
        public void create(Employee employee) {
            manager.persist(employee);  // line 27
    import javax.transaction.UserTransaction;
    public class applicationClient {
    @Resource UserTransaction tx;
    @EJB private static EmployeeService bean;
    try {
        tx.begin();
        Employee employee = new Employee()
            bean.create(employee);
    } finally {
           try {
                 tx.commit();  // line 229
    }How to relinguish transaction on EmployeeSessionBean so that all transaction could take place in applicationClient side only?
    I am trying to apply examples in Pro JPA 2 to a Java EE 6 ManyToMany application.
    Your assistance would be much appreciated.
    Thanks,
    Jack

    Hi r035198x,
    Thank you for some solid advice and would rather JPA take care of all the special cases such as keeping the records unique.
    Below are the changes made as suggested in ( 1 ), ( 2 ), ( 3 ):
    @Entity
    @IdClass(EmployeePK.class)
    @Table(name="EMPLOYEE", catalog="EmployeeDB", schema="")
    public class Employee implements Serializable {
        @Id
        @Column(name="FIRSTNAME")
        private String firstName;
        @Id
        @Column(name="SURNAME")
        private String surName;
        @Id
        @Column(name="DOB")
        @Temporal(TemporalType.DATE)
        private Date dob;
        @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
        @JoinTable(name="EMPLOYEE_PROJECT", catalog="EmployeeDB", schema="",
               joinColumns={@JoinColumn(name="FIRSTNAME_ID", referencedColumnName="FIRSTNAME"),
                            @JoinColumn(name="SURNAME_ID", referencedColumnName="SURNAME"),
                            @JoinColumn(name="DOB", referencedColumnName="DOB")},
               inverseJoinColumns={@JoinColumn(name="PROJECT_ID")})
            private Set<Project> projects = new HashSet<Project>();
    @Entity
    @Table(name="PROJECT", catalog="EmployeeDB", schema="")
    public class Project implements Serializable {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name="ID")
        private int id;
        @ManyToMany(mappedBy="projects", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
            @JoinTable(name="EMPLOYEE_PROJECT", catalog="EmployeeDB", schema="",
               joinColumns={@JoinColumn(name="PROJECT_ID", referencedColumnName="PROJECT_ID")},
               inverseJoinColumns={@JoinColumn(name="FIRSTNAME_ID", referencedColumnName="FIRSTNAME"),
                            @JoinColumn(name="SURNAME_ID", referencedColumnName="SURNAME"),
                            @JoinColumn(name="DOB_ID", referencedColumnName="DOB")})
        private Set<Employee> employees = new HashSet<Employee>();
    @Stateless
    public class EmployeeSessionBean implements EmployeeService {
        @PersistenceContext(unitName="EmployeeDB-PU") private EntityManager manager;
        public void create(Employee employee)
            manager.persist(employee);
    public class applicationClient {
        @EJB
        private static EmployeeService bean;
        public static void main(String[] args) {
        Employee employee = new Employee()
        bean.create(employee);   // line 209
    } I have diverged slightly from using simple primary key (EMPLOYEE_ID) to composite key class (FIRSTNAME, SURNAME, DOB) to resemble the actual application.
    Also gone back to using non - XADatasources since I am depending on JTA to do all the hardwork on the server side.
    Unfortunately, we have hit a snag once again with the following exception still:
    Application Client Output
    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 org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:432)
    at org.glassfish.appclient.client.AppClientFacade.launch(AppClientFacade.java:182)
    at org.glassfish.appclient.client.AppClientGroupFacade.main(AppClientGroupFacade.java:65)
    Caused by: javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
    org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
    Caused by: java.io.StreamCorruptedException: WARNING: ORBIO00013: Stream corrupted
    ----------END server-side stack trace---------- vmcid: OMG minor code: 11 completed: Maybe
    at ejb._EmployeeService_Wrapper.create(ejb/_EmployeeService_Wrapper.java)
    at applicationClient(applicationClient.java:209)
    GF 3.1 Server log
    WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
    org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
    Caused by: java.lang.NullPointerException
    WARNING: ORBIO00013: Stream corrupted
    java.io.StreamCorruptedException: WARNING: ORBIO00013: Stream corrupted
    Your valuable input would be very appreciated.
    Thanks,
    Jack

  • HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean

    HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
    by Steve Muench
    Overview
    BC4J provides automatic facilities for deploying any application module as a stateful EJB session bean. If you want to leverage the features of your BC4J application module from a stateless EJB session bean, it's not automatic but it is straightforward to implement. This howto article explains the details.
    For our example, we will create a stateless EJB session bean that uses a container-managed transaction. To keep things simple, let's assume the session bean has a single public method on its remote interface named createDepartment() with the following signature:
    public void createDepartment(int id, String name, String loc) throws AppException
    AppException is an example of an application-specific exception that our method will throw if any problems arise during its execution.The goal of this article is to illustrate how to use the BC4J application module named com.example.hr.HRApp as part of the implementation of this createDepartment method on our stateless enterprise bean. Let's assume that the HRApp application module has a view object member named Departments, based on the com.example.hr.DeptView view object, based on the familiar DEPT table and related to the com.example.hr.Dept entity object so our view can be updateable.
    Creating the Stateless Session Bean
    We can start by using the JDeveloper Enterprise Bean wizard to create a new stateless session bean called StatelessSampleEJB implemented by:[list][*]com.example.StatelessSampleEJBBean (Bean class)[*]com.example.StatelessSampleEJBHome (Home interface)[*]com.example.StatelessSampleEJB (Remote interface)[list]
    We then use the EJB Class Editor to add the createDepartment method to the remote interface of StatelessSampleEJB with the signature above. We edit the remote interface to make sure that it also reflects that the createDepartment method thows the AppException like this:
    package com.example;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface StatelessSampleEJB extends EJBObject {
      void createDepartment(int id, String name, String loc)
      throws RemoteException,AppException;
    }Before we start adding BC4J into the picture for our implementation, our StatelessSampleEJBBean class looks like this:
    package com.example;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class StatelessSampleEJBBean implements SessionBean {
      public void ejbCreate(){}
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){
      public void createDepartment(int id, String name, String loc) 
      throws AppException {
        // TODO: Implement method here
    }We can double-click on the ejb-jar.xml file in our project to see the XML deployment descriptor for the bean we just created:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
    </ejb-jar>We need to add the extra <assembly-descriptor> section in this file to indicate that the createDepartment method will require a transaction. After this edit, the ejb-jar.xml file looks like this:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
       <assembly-descriptor>
          <container-transaction>
             <method>
                <ejb-name>StatelessSampleEJB</ejb-name>
                <method-name>createDepartment</method-name>
                <method-params>
                   <method-param>int</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                </method-params>
             </method>
             <trans-attribute>Required</trans-attribute>
          </container-transaction>
       </assembly-descriptor>
    </ejb-jar>
    Aggregating a BC4J Application Module
    With the EJB aspects of our bean setup, we can proceed to implementing the BC4J application module aggregation.
    The first thing we do is add private variables to hold the EJB SessionContext and the instance of the aggregated BC4J ApplicationModule, like this:
    // Place to hold onto the aggregated appmodule instance
    transient private ApplicationModule _am  = null;
    // Remember the SessionContext that the EJB container provides us
    private           SessionContext    _ctx = null;and we modify the default, empty implementation of the setSessionContext() method to remember the session context like this:
    public void setSessionContext(SessionContext ctx){ _ctx = ctx; }We add additional constants that hold the names of the J2EE datasource that we want BC4J to use, as well as the fully-qualified name of the BC4J application module that we'll be aggregating:
    // JNDI resource name for the J2EE datasource to use
    private static final String DATASOURCE = "jdbc/OracleCoreDS";
    // Fully-qualified BC4J application module name to aggregate
    private static final String APPMODNAME = "com.example.hr.HRApp";We expand the now-empty ejbCreate() and ejbRemove() methods to create and destory the aggregated instance of the BC4J application module that we'll use for the lifetime of the stateless session bean. When we're done, ejbCreate() it looks like this:
    public void ejbCreate() throws CreateException {
      try {
        // Setup a hashtable of environment parameters for JNDI initial context
        Hashtable env = new Hashtable();
        env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
        // NOTE: we want to use the BC4J app module in local mode as a simple Java class!
        env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
        env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
        // Create an initial context, using this hashtable of environment params
        InitialContext ic = new InitialContext(env);
        // Lookup a home interface for the application module
        ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
        // Using the home, create the instance of the appmodule we'll use
        _am = home.create();
        // Register the BC4J factory to handle EJB container-managed transactions
        registerContainerManagedTransactionHandlerFactory();
      catch(Exception ex) {
         ex.printStackTrace();
        throw new CreateException(ex.getMessage());
    }and ejbRemove() looks like this:
    public void ejbRemove() {
      try {
        // Cleanup any appmodule resources before getting shutdown
        _am.remove();
      catch(JboException ex) { /* Ignore */ }
    }The helper method named reigsterContainerManagedTransactionHandlerFactory() looks like this:
    private void registerContainerManagedTransactionHandlerFactory() {
      SessionImpl session = (SessionImpl)_am.getSession();
      session.setTransactionHandlerFactory(
        new TransactionHandlerFactory() {
          public TransactionHandler  createTransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
          public JTATransactionHandler createJTATransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
    }The last detail is to use the BC4J appmodule to implement the createDepartment() method. It ends up looking like this:
    public void createDepartment(int id, String name, String loc)
    throws AppException {
      try {
        // Connect the AM to the datasource we want to use for the duration
        // of this single method call.
        _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
        // Use the "Departments" view object member of this AM
        ViewObject departments = _am.findViewObject("Departments");
        // Create a new row in this view object.
        Row newDept = departments.createRow();
        // Populate the attributes from the parameter arguments.
        newDept.setAttribute("Deptno", new Number(id));
        newDept.setAttribute("Dname", name);
        newDept.setAttribute("Loc", loc);
        // Add the new row to the view object's default rowset
        departments.insertRow(newDept);
        // Post all changes in the AM, but we don't commit them. The EJB
        // container managed transaction handles the commit.
        _am.getTransaction().postChanges();
      catch(JboException ex) {
        // To be good EJB Container-Managed Transaction "citizens" we have
        // to mark the transaction as needing a rollback if there are problems
        _ctx.setRollbackOnly();
        throw new AppException("Error creating dept "+ id +"\n"+ex.getMessage());
      finally {
        try {
          // Disconnect the AM from the datasource we're using
          _am.getTransaction().disconnect();
        catch(Exception ex) { /* Ignore */ }
    Building a Test Client
    With the EJB-Tier work done, we can build a sample client program to test this new stateless EJB Session Bean by selecting the bean in the Oracle9i JDeveloper IDE and choosing "Create Sample Java Client" from the right-mouse menu.
    When the "Sample EJB Client Details" dialog appears, we take the defaults of connecting to embedded OC4J container. Clicking the (OK) button generates the following test class:
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.example.StatelessSampleEJB;
    import com.example.StatelessSampleEJBHome;
    public class SampleStatelessSampleEJBClient {
      public static void main(String [] args) {
        SampleStatelessSampleEJBClient sampleStatelessSampleEJBClient =
           new SampleStatelessSampleEJBClient();
        try {
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY,
                  "com.evermind.server.rmi.RMIInitialContextFactory");
          env.put(Context.SECURITY_PRINCIPAL, "admin");
          env.put(Context.SECURITY_CREDENTIALS, "welcome");
          env.put(Context.PROVIDER_URL,
                  "ormi://localhost:23891/current-workspace-app");
          Context ctx = new InitialContext(env);
          StatelessSampleEJBHome statelessSampleEJBHome =
               (StatelessSampleEJBHome)ctx.lookup("StatelessSampleEJB");
          StatelessSampleEJB statelessSampleEJB;
          // Use one of the create() methods below to create a new instance
          // statelessSampleEJB = statelessSampleEJBHome.create();
          // Call any of the Remote methods below to access the EJB
          // statelessSampleEJB.createDepartment( int id, java.lang.String name, java.lang.String loc );
        catch(Throwable ex) {
          ex.printStackTrace();
    }We uncomment the call to the create() method and add a few calls to the createDepartment() method so that the body of the test program now looks like this:
    // Use one of the create() methods below to create a new instance
    statelessSampleEJB = statelessSampleEJBHome.create();
    // Call any of the Remote methods below to access the EJB
    statelessSampleEJB.createDepartment( 13, "Test1","Loc1");
    System.out.println("Created department 13");
    statelessSampleEJB.createDepartment( 14, "Test2","Loc2");
    System.out.println("Created department 14");
    try {
      // Try setting a department id that is too large!
      statelessSampleEJB.createDepartment( 23456, "Test3","Loc3");
    catch (AppException ax) {
      System.err.println("AppException: "+ax.getMessage());
    }Before we can successfully run our SampleStatelessSampleEJBClient we need to first run the EJB bean that the client will try to connect to. Since Oracle9i JDeveloper supports local running and debugging of the EJB-Tier without doing through a full J2EE deployment step, to accomplish this prerequisite step we just need to right-mouse on the StatelessSampleEJB node in the System Navigator and select "Run". This starts up the embedded OC4J instance and runs the EJB right out of the current out path.Finally, we can run the SampleStatelessSampleEJBClient, and see the output of the test program in the JDeveloper log window:
    Created department 13
    Created department 14
    AppException: Error creating dept 23456
    JBO-27010: Attribute set with value 23456 for Deptno in Dept has invalid precision/scale
    Troubleshooting
    One error that might arise while running the example is that the database connection information in your data-sources.xml for the jdbc/OracleCoreDS datasource does not correspond to the database you are trying to test against. If this happens, then double-check the file .\jdev\system\oc4j-config\data-sources.xml under the JDeveloper installation home directory to make sure that the url value provided is what you expect. For example, to work against a local Oracle database running on your current machine, listening on port 1521, with SID of ORCL, you would edit this file to have an entry like this for jdbc/OracleCoreDS :
    <data-source
        class="com.evermind.sql.DriverManagerDataSource"
        name="OracleDS"
        location="jdbc/OracleCoreDS"
        xa-location="jdbc/xa/OracleXADS"
        ejb-location="jdbc/OracleDS"
        connection-driver="oracle.jdbc.driver.OracleDriver"
        username="scott"
        password="tiger"
        url="jdbc:oracle:thin:@localhost:1521:ORCL"
        inactivity-timeout="30"
    />This is the data-sources.xml file that gets used by the embedded OC4J instance running in JDeveloper.
    Conclusion
    Hopefully this article has illustrated that it is straightforward to utilize the full power of BC4J in local mode as part of your EJB Stateless Session Beans using container-managed transaction. This example illustrated a single createDepartment method in the enterprise bean, but by replicating the application module interaction code that we've illustrated in createDepartment, any number of methods in your stateless session bean can use the aggregated application module instance created in the ejbCreate() method.
    Code Listing
    The full code listing for the SampleStatelessEJB bean implementation class looks like this:
    * StatelessSampleEJB
    * Illustrates how to use an aggregated BC4J application module
    * in local mode as part of the implementation of a stateless
    * EJB session bean using container-managed transaction.
    * HISTORY
    * smuench/dmutreja 14-FEB-2002 Created
    package com.example;
    import oracle.jbo.*;
    import oracle.jbo.server.*;
    import javax.ejb.*;
    import oracle.jbo.domain.Number;
    import oracle.jbo.common.PropertyConstants;
    import java.util.Hashtable;
    import javax.naming.InitialContext;
    import oracle.jbo.server.ejb.ContainerManagedTxnHandlerImpl;
    public class StatelessSampleEJBBean implements SessionBean {
      // JNDI resource name for the J2EE datasource to use
      private static final String DATASOURCE = "jdbc/OracleCoreDS";
      // Fully-qualified BC4J application module name to aggregate
      private static final String APPMODNAME = "com.example.hr.HRApp";
      // Place to hold onto the aggregated appmodule instance
      transient private ApplicationModule _am  = null;
      // Remember the SessionContext that the EJB container provides us
      private           SessionContext    _ctx = null;
      public void ejbCreate() throws CreateException {
        try {
          // Setup a hashtable of environment parameters for JNDI initial context
          Hashtable env = new Hashtable();
          env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
          env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
          env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
          // Create an initial context, using this hashtable of environment params
          InitialContext ic = new InitialContext(env);
          // Lookup a home interface for the application module
          ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
          // Using the home, create the instance of the appmodule we'll use
          _am = home.create();
          // Register the BC4J factory to handle EJB container-managed transactions
          registerContainerManagedTransactionHandlerFactory();
        catch(Exception ex) {
           ex.printStackTrace();
          throw new CreateException(ex.getMessage());
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){ _ctx = ctx; }
      public void createDepartment(int id, String name, String loc)
      throws AppException {
        try {
          // Connect the AM to the datasource we want to use for the duration
          // of this single method call.
          _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
          // Use the "Departments" view object member of this AM
          ViewObject departments = _am.findViewObject("Departments");
          // Create a new row in this view object.
          Row newDept = departments.createRow();
          // Populate the attributes from the parameter arguments.
          newDept.setAttribute("Deptno", new Number(id));
          newDept.setAttribute("Dname", name);
          newDept.setAttribute("Loc", loc);
          // Add the new row to the view object's default rowset
          departments.insertRow(newDept);
          // Post all changes in the AM, but we don't commit them. The EJB
          // container managed transaction handles the commit.
          _am.getTransaction().postChanges();
        catch(JboException ex) {
          // To be good EJB Container-Managed Transaction "citizens" we have
          // to mark the transaction as needing a rollback if there are problems
          _ctx.setRollbackOnly();
          throw new AppException("Error creating dept "+ id +\n"+ex.getMessage());
        finally {
          try {
            // Disconnect the AM from the datasource we're using
            _am.getTransaction().disconnect();
          catch(Exception ex) { /* Ignore */ }
      private void registerContainerManagedTransactionHandlerFactory() {
        SessionImpl session = (SessionImpl)_am.getSession();
        session.setTransactionHandlerFactory(
          new TransactionHandlerFactory() {
            public TransactionHandler createTransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();
            public JTATransactionHandler createJTATransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();

    Hi Steve, It4s me again;
    About the question I made, I tried with a single assembly-descriptor tag and a single container-transaction tag in the deployment descriptor of the session bean and these were the results.
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Then I tried with multiple assembly-descriptor tags each with a single container-transaction tag and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Finally I tried with a single assembly-descriptor and multiple container tags and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    How can I make my Stateless Session bean work out?

  • Session Bean Transaction Rollback not working for RuntimeException

    Hi,
    I am calling a number of JDBC create/update statements within a method in a container managed transaction stateless session bean with transaction attribute set to required. I am running the bean within the embedded OC4J supplied with JDeveloper 10g (10.1.2). For each JDBC call, i connect to a datasource via JNDI containg a pool of connections pointing to an Oracle 10g database (standard J2EE)
    If i throw a runtime exception within the method the transaction is NOT rolled back as it should be according to the EJB spec. However, if i setRollbackOnly() on the session bean SessionContext the transaction does roll back.
    Has anybody experienced this before?
    Is this an OC4J bug?
    Thanks
    Dave

    Generally, for urgent issues it's best to open a SR with Oracle Support rather than posting to the forums.
    enlist=dynamic didnt exist in 10.2.0.2.20, but does now. I can't recall what specific version it was introduced though.
    enlist=false prevents enlistment in MSDTC transactions, so thats why it's not rolling back in that case.
    "transaction branch length 90 is illegal" was a known issue on Vista, is that the OS you're using? It takes a two part fix, and It is resolved by
    1) getting up to 10204 ODP (apply the 10204 rdbms patch to your client install)
    2) applying SP1 for Vista
    Hope it helps,
    Greg

  • Cannot remove stateful session bean when transaction timed out

    The transaction timeout is set to 5 minutes. After several operations on the transactional
    stateful session bean(implements SessionSynchronization), the transaction timed out
    after 5 minutes and I got the IllegalStateException when calling another business
    method. After the transaction rolled back, weblogic.ejb20.locks.LockTimedOutException
    was thrown when attempting to remove the bean. It seems the lock on the bean was
    not released even though the transaction had been rolled back. Does anyone know how
    to remove the bean in this kind of situation?
    Here is the stacktrace:
    ####<Jun 11, 2002 2:39:35 PM PDT> <Notice> <EJB> <app1x.zaplet.cc> <server25044server>
    <ExecuteThread: '11' for queue: 'default'> <> <23168:7b09681c532dc7e3> <010015> <Error
    marking transaction for rollback: java.lang.IllegalStateException: Cannot mark the
    transaction for rollback. xid=23168:7b09681c532dc7e3, status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 299 seconds
    Xid=23168:7b09681c532dc7e3(3203140),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
    since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '11' for queue:
    'default',5,Thread Group for Queue: 'default'],ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=ended,assigned=none),SCInfo[server25044+server25044server]=(state=active),properties=({weblogic.jdbc=t3://10.0.100.93:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=server25044server+10.0.100.93:7001+server25044+,
    Resources={})],CoordinatorURL=server25044server+10.0.100.93:7001+server25044+)]>
    java.lang.IllegalStateException: Cannot mark the transaction for rollback. xid=23168:7b09681c532dc7e3,
    status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException: Transaction
    timed out after 299 seconds
    Xid=23168:7b09681c532dc7e3(3203140),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
    since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '11' for queue:
    'default',5,Thread Group for Queue: 'default'],ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=ended,assigned=none),SCInfo[server25044+server25044server]=(state=active),properties=({weblogic.jdbc=t3://10.0.100.93:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=server25044server+10.0.100.93:7001+server25044+,
    Resources={})],CoordinatorURL=server25044server+10.0.100.93:7001+server25044+)]
         at weblogic.transaction.internal.TransactionImpl.throwIllegalStateException(TransactionImpl.java:1486)
         at weblogic.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.java:466)
         at weblogic.ejb20.manager.BaseEJBManager.handleSystemException(BaseEJBManager.java:255)
         at weblogic.ejb20.manager.BaseEJBManager.setupTxListener(BaseEJBManager.java:215)
         at weblogic.ejb20.manager.StatefulSessionManager.preInvoke(StatefulSessionManager.java:371)
         at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:117)
         at weblogic.ejb20.internal.StatefulEJBObject.preInvoke(StatefulEJBObject.java:169)
         at mypackage.MyBean_wbr3eg_EOImpl.addRecipients(MyBean_wbr3eg_EOImpl.java:450)
    ####<Jun 11, 2002 2:39:37 PM PDT> <Info> <EJB> <app1x.zaplet.cc> <server25044server>
    <ExecuteThread: '11' for queue: 'default'> <> <> <010049> <EJB Exception in method:
    remove: weblogic.ejb20.locks.LockTimedOutException: The lock request from EJB:AppmailBean
    with primary key:21,775,960,933,010,237 timed-out after waiting 0 ms. The transaction
    or thread requesting the lock was:Thread[ExecuteThread: '11' for queue: 'default',5,Thread
    Group for Queue: 'default'].>
    weblogic.ejb20.locks.LockTimedOutException: The lock request from EJB:AppmailBean
    with primary key:21,775,960,933,010,237 timed-out after waiting 0 ms. The transaction
    or thread requesting the lock was:Thread[ExecuteThread: '11' for queue: 'default',5,Thread
    Group for Queue: 'default'].
         at weblogic.ejb20.locks.ExclusiveLockManager$LockBucket.lock(ExclusiveLockManager.java:448)
         at weblogic.ejb20.locks.ExclusiveLockManager.lock(ExclusiveLockManager.java:258)
         at weblogic.ejb20.manager.StatefulSessionManager.acquireLock(StatefulSessionManager.java:226)
         at weblogic.ejb20.manager.StatefulSessionManager.acquireLock(StatefulSessionManager.java:216)
         at weblogic.ejb20.manager.StatefulSessionManager.preInvoke(StatefulSessionManager.java:310)
         at weblogic.ejb20.manager.StatefulSessionManager.remove(StatefulSessionManager.java:754)
         at weblogic.ejb20.internal.StatefulEJBObject.remove(StatefulEJBObject.java:86)
         at mypackage.MyBean_wbr3eg_EOImpl.remove(MyBean_wbr3eg_EOImpl.java:7308)

    If a stateful session throws a RuntimeException (your rollback) the container destroys the instance of the bean and all
    associated state information is lost, as required by the EJB specification.
    If you want to maintain client state it is generally best to use HttpSession objects (if you have a web application)
    for short-lived, client-specific data and JPA entities or other database backed storage for long-lived data.

  • Transaction management in BMP through Session bean(worked in J2EE RI)

    This thing worked in the J2EE RI implementation, but not in OC4J.
    Problem is:
    In a BMP, if we throw an EJBException all the changes would be rolled back by the container, right? Or do we have to write code to do that?
    I was reading through your reply in the list and I have a doubt regarding something regarding transaction handling in BMP entity beans. I am using the entity bean in a session bean and have two sql statements and one entity update. If one of the sql statements fails and the entity is updated , the changes are all rolled back, but in the case of the entity failure to update, the sql statement changes are not rolled back and I get an error saying
    System/communication error: Transaction was rolled back: Error preparing bean in
    stance: com.evermind.transaction.MarshallingXAException; nested exception is:
    com.evermind.transaction.MarshallingXAException
    The entity bean is throwing an EJBException back to the Session bean, but the session bean does not catch
    it and continues forward as if nothing happened.
    The funny thing is that the queries are placed like this
    sqlinsert 1.......
    entitybean update....
    sqlinsert 2.....
    So the flow becomes
    sqlinsert 1 happens then sqlinsert 2 and only in the end does the entity bean throw the exception
    any idea why this happens?
    Can anyone help me on this. The BMP entity has persistence
    <persistence-type>Bean</persistence-type>
    Thanks
    Kind Regards
    Aby Philip

    Hi,
    In general, whenever you manage your own transactions (such as in DAOs or in stored procedures) then you are limiting the ways that your code can be reused: your code will never be able to run in a client's transaction. This could mean trouble if you want to combine you software inside other beans that use it: when these other beans lead to a rollback then your DAO might still commit.
    I would try to make the session bean use CMT, that is the most flexible if you are staying within the appserver.
    Hope that helps,
    Guy
    http://www.atomikos.com

  • How to create bdc for fbs1 using both call transaction and session

    Hi Friends,
    i have one problem with tcode FBS1, i need to create a bdc program for both call transaction and session method using subroutine.
    first call transaction needs to execute if there is an error sesion has to execute. if u have code please forward.
    thanks in advance.
    chandramouli pothugunta

    where as in call transaction we can do error handling explictly.those errors  are stored in one file .this file will send to the error log(session method),i.e session log.
    in the above case we use both call transaction n session method at time in one program.sample code is below ,go through it .
    data : begin of itxk01 occurs 0,
    end of itxk01.
    data : bdcdata like itbdcdata occurs 0 with header line.
    data : itbdcmsgcoll like itbdcmsgcoll occurs 0 with header line,
             itxk01 like itxk01-dup occurs 0 with header line.
    call gui-upload.
    loop at itxk01.
    refresh itxk01.
    perform bdc-dynpr0 using 'prg' 'scr'
    perform bdc-dynfld using fnam fval
    call transaction 'xk01' using bdcdata mode 'a' update 's' messages into itbdcmsgcoll.
    if sy-subrc ne 0.
    append itxk01 into  itxk01-dup.
    endif.
    endloop.
    if not itxk01-dup[] is initial.
    refresh itck01.
    call bdc_open_group
    itxk01 = itxk01-dup.
    loop at itxk01.
    refresh itxk01.
    perform bdc-dynpr0 using 'prg' 'scr'
    perform bdc-dynfld using fnam fval
    call bdc-insert.
    endloop.
    call bdc-close-group.
    form bdc-dynpr0 using pr sc
    endform .
    form bdc-field  using fnam faval
    endform.
    this will help u.
    reward points for me
    kiran

  • HttpSession vs. Stateful Session Bean ---- when State Session is large

    I hope most of the people come across with this issue where to put the state
    for the internet/intranet based applications when they are using
    servlet/jsps calling session beans. Weblogic 4.5.1 does support httpsession
    in-memory replication for the servlets but the stateful session beans are
    not replicated in clustered environment. Plus with stateful bean u get
    activation/passivation overhead too. So one tempts to use stateless session
    beans and store state in httpsession?
    Then what is the upper limit for the session state one can put in
    HttpSession with the weblogic? Is there any way to configure it?
    One way to overcome the httpsession size limitation is to use database for
    storing state and just store some unique Ids for the session info in
    httpSession. But then there will be overhead for database connection?(jdbc
    connection pool can provide some help here). So what is the recommended way
    for doing this provided few thousand concurrent clients with session size
    say exceeding 4kb per client?
    Thanks
    Usmani

    There are no special setting in sun-ejb-jar.xml regarding cache settings. The default settings from server.xml are used:
        <jdbc-connection-pool steady-pool-size="8" max-pool-size="32" max-wait-time-in-millis="60000" pool-resize-quantity="2" idle-timeout-in-seconds="300" is-isolation-level-guaranteed="false" is-connection-validation-required="false" connection-validation-method="auto-commit" fail-all-connections="false" datasource-classname="oracle.jdbc.pool.OracleDataSource" name="ebs">
          <property value="jdbc:oracle:thin:@myebsdbsserver:1521:ebsdevdb" name="url"/>
          <property value="ebs" name="user"/>
          <property value="ebs" name="password"/>
        </jdbc-connection-pool>
      <ejb-container steady-pool-size="32" pool-resize-quantity="16" max-pool-size="64" cache-resize-quantity="32" max-cache-size="512" pool-idle-timeout-in-seconds="600" cache-idle-timeout-in-seconds="600" removal-timeout-in-seconds="5400" victim-selection-policy="nru" commit-option="B" monitoring-enabled="true">
         </ejb-container>The Session Bean uses Container Managed Transaction. Is it possible in this case, that the bean isn't 'idle enough' in order to set into passivated?

  • What role can ejb Session Beans  play  jsp session tracking

     

              I am also looking for a way to use JSP as ejb client with WLS5.1. i would appreciate any help.
              -Girish
              Prasad Peddada <[email protected]> wrote:
              >David,
              >     The beans which are refered in jsp specs are java beans and not EJB.
              >
              >Prasad
              >
              >David Levy wrote:
              >>
              >> Hello,
              >>
              >> We are using Jsp/Servlets which will hold session state and subsequently
              >> call ejb Session Beans for transaction/persistence coordination . We are
              >> not sure if we are using the correct techniques to control object memory.
              >>
              >> Summary of what we have:
              >>
              >> A jsp with the "useBean" directive:
              >> <jsp:useBean id="MySession" class="com....MySession"
              >> scope="session"></jsp:useBean>
              >>
              >> The class MySession holds other classes ( all serializable).
              >> The class MySession is NOT an ejb Session Bean
              >>
              >> Questions:
              >> We are considering making class MySession an ejb Session Bean so (via it's
              >> passivate/activate feature) we can control instances in memory as more web
              >> clients start the session from the jsp page. I.E. all web clients will have
              >> their own HttpSession instance which holds on to an ejb Session Bean object
              >> "MySession"( or a passivated representation of it)
              >>
              >> 1) Is this a sufficient approach or will there be other memory concerns?
              >> I.E. What about all the HttpSession objects out there? Do they need to be
              >> passivated as well?
              >>
              >> 2) If its a good idea to passivate the HttpSessions as well, then what
              >> mechanism should be used ( servlet session persistence)? Also, if we are
              >> passivating the HttpSession (which holds on to the MySession object graph)
              >> , then why bother with the SessionBean for passivation
              >>
              >> 3) Currently, we only have a single instance of a servlet handling all
              >> requests. Will multiple instances buy us anything?
              >>
              >> 4) How does clustering relate to this topic?
              >>
              >> 5) Can we change the "jsp:useBean" directive so MySession is an ejb Session
              >> Bean or do we have to do the "home.create()" within a jsp script?
              >>
              >> thanks,
              >> dave
              

Maybe you are looking for