Hot questions for Using Enterprise JavaBeans in jta

Question:

If I have nested bean methods which just fetching data from the database. (i.e GET API). So will it be beneficial to mark all bean methods as TransactionAttributeType.NOT_SUPPORTED? Will it help in increase in performance as JTA is not managing any transaction for this?


Answer:

This is exactly the purpose of using NOT_SUPPORTED, to increase performance. Infact as stated by Oracle:

NotSupported Attribute

If the client is running within a transaction and invokes the enterprise bean’s method, the container suspends the client’s transaction before invoking the method. After the method has completed, the container resumes the client’s transaction.

If the client is not associated with a transaction, the container does not start a new transaction before running the method.

Use the NotSupported attribute for methods that don’t need transactions. Because transactions involve overhead, this attribute may improve performance.

So, it is a perfect fit for all the select or find business methods, which purpose is maybe to fill a data table on screen.

Question:

I want to do an asynchronous transactional action in a ejb method by calling a stored procedure. When I call the methot I give below error:

java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

Bean

@Stateless
public class FileSearchDAO {
    private static Logger logger = LoggerFactory.getLogger(FileSearchDAO.class);

    @PersistenceContext(unitName = "FileSearchPU")
    private EntityManager entityManager;

    @Asynchronous
    public Future<String> saveFile(String fileNo, List<String> runningFiles) {
        try {
            entityManager.getTransaction().begin();
            entityManager.createNativeQuery(
                    " BEGIN prc_save_file (:fileNo); END;")
                    .setParameter("fileNo", fileNo).executeUpdate();
            entityManager.getTransaction().commit();
            runningFiles.remove(fileNo);
            return new AsyncResult<>(fileNo);
        } catch (Exception ex) {
            ex.printStackTrace();
            return new AsyncResult<>(ex.getMessage());
        }
    }

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name="FileSearchPU" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>jdbc/FileSearchDS</jta-data-source>
        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.transaction.jta.platform"
                      value="${hibernate.transaction.jta.platform}"/>
        </properties>
    </persistence-unit>
</persistence>

I haven't any Entity class. I just want to call the stored procedure which updates some table.


Answer:

In a JTA managed datasource container handles transactions in a distributed way so also handling concurrency outside your application for example.

EntityManagers transaction can not be used because it is local transaction so something that is then not handled outside your application. Read also this post for more information.

If you need transaction you should use UserTransaction

@Resource
UserTransaction utx;

To use it your annotate your bean

@TransactionManagement(TransactionManagementType.BEAN)

and use transaction like

utx.begin();
   ...
utx.commit(); // utx.rollback();

Question:

I have a problem. I am working on java application server(sap netweaver) with I am using ejb 3.0

So I want to database insert one by one. Because I have too much data and i have to divide data. So I made try test code and it did work but it did not work as I want.

I want to create a new transaction for each part and of course at the end method(transaction) should be commit.

Sample code is below;

package com.transaction.jobs;

import javax.ejb.Local;

/**
 *
 * @author muratdemir
 */
@Local
public interface TestTransactionLocal {

    public void onStart();

    public void insertObject(int i);
}

and

package com.transaction.jobs;

import com.transaction.service.DatabaseServiceLocal;
import com.transaction.entity.Item;
import com.transaction.entity.Logger;
import java.util.Date;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.EJBContext;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;

/**
 *
 * @author muratdemir
 */
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class TestTransactionService implements TestTransactionLocal {

    @EJB
    DatabaseServiceLocal databaseService;

    @Resource
    EJBContext context;

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onStart() {
        try {
            System.out.println("START");

            Logger log1 = new Logger(new Date(), ">>>T1 commiting");
            databaseService.create(log1);

            System.out.println(">>>T1 committing");

            Thread.sleep(5000);

            for (int i = 1; i < 10; i++) {
                System.out.println("Call new Transaction");

                insertObject(i);

                Thread.sleep(2000);
            }

            Thread.sleep(5000);

            Logger log2 = new Logger(new Date(), "<<<T1 commiting");

            databaseService.create(log2);

            System.out.println("<<<T1 committing");

            Thread.sleep(5000);
            System.out.println("END");
        } catch (Exception e) {
            e.printStackTrace();
            context.setRollbackOnly();
        }

    }

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void insertObject(int i) {
        try {
            System.out.println("New Transaction Start i:" + i);

            Item item = new Item(new Date(), "Name_" + i);

            databaseService.create(item);

            System.out.println("commit transaction: " + i);
        } catch (Exception e) {
            e.printStackTrace();
            context.setRollbackOnly();
        }
    }

}

The insertObject(Requires_New) function is work but it did not commit. It waiting for commit other onStart(REQUIRED) function. If mytimer function is end, the insert function makes all commit.

Why new transaction is did not committed?

Note: If I change transaction attribute of the onStart function REQUIRED to NOT_SUPPORTED it works as I want. Why it works this way?


Answer:

You have to initialize another TestTransactionLocal with a use of SessionContext#getBusinessObject method. This way your TestTransactionLocal instance will respect @TransactionAttribute annotation.

@Resource
private SessionContext sessionContext;

private TestTransactionLocal local;

@PostConstruct
void init() {
    local = sessionContext.getBusinessObject(TestTransactionLocal.class);
}

Then invoke insertObject() through this new reference:

local.insertObject(i);

See this blog post: http://www.adam-bien.com/roller/abien/entry/how_to_self_invoke_ejb

Question:

Trying to persist an entity is not working but retrieving a list is.

Below is my Bean: (a)

@Stateless
public class UsersClass {
    @PersistenceContext(unitName = "unit")
    private EntityManager em;

    public UsersClass () {}

    public void create(Users entity) {
        em.persist(entity);
    }
}

persistence.xml as below:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence   http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

<persistence-unit name="unit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

<jta-data-source>jdbc/ds</jta-data-source> 
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>
</persistence>

Beans have to be @Stateless. Above, setup executes fine - no exception or anything but nothing gets saved in DB also.

Tried whats mentioned here. Not sure if I did it correctly or not but was getting exception.

I also tried whats mentioned here and modified as below:(b)

@Stateless
public class UsersClass {
    @PersistenceContext(unitName = "unit")
    private EntityManager em;

    @Resource
    private SessionContext sessionContext;

    public UsersClass () {}

    public void create(Users entity) {
        UserTransaction userTxn = sessionContext.getUserTransaction();
        try {
             userTxn.begin();
             getEntityManager().persist(entity);
             userTxn.commit();
        } catch(Throwable e){
            e.printStackTrace();
            try {
              userTxn.rollback();
            } catch (IllegalStateException | SecurityException | SystemException e1) {
                e1.printStackTrace();
            } 
        }
    }
}

but got the below stack trace -

Caused by: java.lang.IllegalStateException: Only session beans with bean-managed transactions can obtain UserTransaction
at com.sun.ejb.containers.EJBContainerTransactionManager.getUserTransaction(EJBContainerTransactionManager.java:566)
at com.sun.ejb.containers.BaseContainer.getUserTransaction(BaseContainer.java:995)
at com.sun.ejb.containers.AbstractSessionContextImpl.getUserTransaction(AbstractSessionContextImpl.java:120)

So as per my readings, I thought adding @TransactionManagement(TransactionManagementType.BEAN) to my class should help. Indeed, the exception is gone but nothing get persisted in the db.

Have also tried - entitymanager.getTransaction().begin() and commit() but there I get the below stack-trace

Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
at org.hibernate.internal.AbstractSharedSessionContract.getTransaction(AbstractSharedSessionContract.java:360)
at org.hibernate.internal.AbstractSessionImpl.getTransaction(AbstractSessionImpl.java:23)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.getTransaction(EntityManagerWrapper.java:806)

It would really help me if someone can point out the missing piece of code.

Update 1 -

I have tried the below set of changes also with (b)

 userTxn.begin();
 getEntityManager().joinTransaction();
 getEntityManager().persist(entity);
 userTxn.commit();

Am getting below stack-trace -

org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException: Unable to access TransactionManager or UserTransaction to make physical transaction delegate
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.makePhysicalTransactionDelegate(JtaTransactionCoordinatorImpl.java:229)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.getTransactionDriverControl(JtaTransactionCoordinatorImpl.java:203)
at org.hibernate.engine.transaction.internal.TransactionImpl.<init>(TransactionImpl.java:37)
at org.hibernate.internal.AbstractSharedSessionContract.accessTransaction(AbstractSharedSessionContract.java:372)
at org.hibernate.internal.AbstractSharedSessionContract.markForRollbackOnly(AbstractSharedSessionContract.java:342)
at org.hibernate.internal.ExceptionConverterImpl.handlePersistenceException(ExceptionConverterImpl.java:271)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:148)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.internal.SessionImpl.joinTransaction(SessionImpl.java:3736)
at org.hibernate.internal.SessionImpl.joinTransaction(SessionImpl.java:3718)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.joinTransaction(EntityManagerWrapper.java:990)

Answer:

  1. Container Managed Transaction

This seems to be OK, your create method in your Users stateless bean starts the transaction automatically. You entityManager takes part in the transaction and the changes should be persisted to the Database. What was the exception in this case?

  1. Container Managed Transaction and try to start a JTA transaction

Your create method starts a transaction automatically, you tried to start another JTA transaction in the code and you got a 'IllegalStateException'. If you want to take control of the transaction in the code, change the configuration to Bean Managed Transaction.

  1. Bean Managed Transaction

You are controlling the Transaction in the code. The code doesn't throw any exception but the changes are not being persisted. This is because the EntityManager is not joining the transaction. If you have an EntityManager created before the start of the JTA transaction, you need to call the method joinTransaction() to make the EntityManager to join the transaction:

userTxn.begin();
EntityManager em = getEntityManager();
em.joinTransaction();
em.persist(entity);
userTxn.commit();

Question:

I'm looking for a way to call multiple DAO functions in a transaction but I am NOT using spring or any such framework. What we actually have is a Database api type .jar which gets initialized with the used datasource. What I want to achieve is have my business logic level code do something like:

Connection conn = datasource.getConnection();
conn.setAutoCommit(false);
DAOObject1.query1(params, conn);
DAOObject2.query4(params, conn);
conn.commit();
conn.setAutoCommit(false);

however I want to avoid passing the connection object in every single function since this is not the correct way to do it. Right now in the few transactions we have we use this but we are looking for a way to stop passing the connection object to the database layer or even create it outside of it. I'm looking for something along the lines of:

//Pseudocode
try{
  Datasource.startTransactionLogic();
  DAO1.query(params);
  DAO2.query(params);
  Datasource.endAndCommitTransactionLogic();
}
catch(SQLException e){
  Datasource.rollbackTransaction();
}

Could I achieve this through EJBs? Right now we're not using DAOs through injection, we're creating them by hand but we're about to migrate to EJBs and start using them via the container. I've heard that all queries executed by EJBs are transactional but how does it know what to rollback to? Through savepoints?

EDIT:

Let me point out that each DAO object's method, right now, obtains its own connection object. Here is an example of how our DAO classes will be:

public class DAO {
public DTO exampleQueryMethod(Integer id) {
    DTO object = null;
    String sql = "SELECT * FROM TABLE_1 WHERE ID = ?";
    try (
        Connection connection = datasourceObject.getConnection();
        PreparedStatement statement = connection.prepareStatement(sql)
    ) {
        statement.setInt(1,  id);
        try (ResultSet resultSet = statement.executeQuery()) {
            if (resultSet.next()) {
                object = DAO.map(resultSet);
            }
        }
    }
    return object;
}
}

Right now what we're doing for methods that need to be in a transaction is to have a second copy of them that receive a Connection object:

public void exampleUpdateMethod(DTO object, Connection connection) {
    //table update logic
}

What we want is to avoid having such methods in our 'database api' .jar but instead be able to define the beginning and commit of a transaction in our business logic layer, like mentioned in the pseudocode above.


Answer:

What i have done in the past is to create a Repository Object that takes the Database API and generates a connection and saves the connection as a member variable to it. (along with the database reference as well)

I then hang all the Business Layer calls as methods from this Repository Object for convenience to the caller.

This way.. you can call, mix, match any calls and use the underlying connection, perform rollback, commits.. etc.

Repository myr = new Repository(datasource);  // let constructor create connection
myr.setAutoCommit(false); 
myr.DAOObject1(parms);   // method wrapper
myr.DAOObject2(parms);   // method wrapper

myr.commitwork();   // method in Repository that calles endAndCommitTransactionLogic 

We then took this new object, and created a pool of them primed, and managed in a new thread, and the Application just requested a new "Repository" from the pool.. and off we went.

Question:

I am working with JBoss EAP 6.4 (Java EE 6) and I have a question related to the way the application server is dealing with XA Datasources (through EJB / JTA) and if the 2 phase commit (2PC) is always used or if an "optimization" is applied.

Let's say I have this:

@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MyEjb {
   @EJB
   private MyFirstEjb first;

   @EJB
   private MySecondEjb second;

   // Transactional processing
   public void process() {
      first.processJpaStuff();
      second.processJpaStuff();
   }
}

Let's say that :

  • MyFirstEjb do JPA queries using XA Datasource 1.
  • MySecondEjb do JPA queries using XA Datasource 2.

I am using XA datasource because these EJBs can be used in other cases where 2PC is required (along with another datasource or a JMS provider).

I now would like to distinguish several cases:

  1. MyFirstEjb and MySecondEjb are deployed in the same application (EAR)
  2. MyFirstEjb and MySecondEjb are deployed in separate applications (EARs) within the same application server
  3. MyFirstEjb and MySecondEjb are deployed within different applications servers

and sub-cases:

a) XA Datasource 1 = XA Datasource 2

b) XA Datasource 1 != XA Datasource 2 (same database)

c) XA Datasource 1 != XA Datasource 2 (different database)

I guess b) and c) are managed the same way. There is a global transaction and each datasource collaborate with the XA transaction manager. A 2PC is applied.

What about cases 1.a) and 2.a) ? Since both are eventually using the same datasource, I guess there is some kind of optimization that does not require a global 2PC transaction to be processed? If yes, is there any official (JTA / JBoss / ...) link that explains this? Is it the same thing with all application servers / implementations?

Thanks


Answer:

It depends.

The JTA (transaction coordinator) knows nothing about EJBs or applications. It's concerned only with XAResources and the associated transaction branches. The normal case is that the JCA managing the connection pool used by the JPA for the entity beans, will provide the JTA with one XAResource per datasource used. The JTA assigns each a different branch qualifier under the same global tx id.

During transaction termination the JTA prepares each XAResource and it's at this point that the optimization kicks in. If the db engine detects that it has multiple branches (connections/XAResources) for the same global tx, it may return PREPARED from the first XAResource, but READ_ONLY from the remaining resource(s). Assuming the tx has as a result only one PREPARED resource and the rest are all read-only, it can then optimize the remaining part of the termination accordingly. see e.g.

http://narayana.io/docs/product/#two-phase-variants

https://docs.oracle.com/cd/B10501_01/java.920/a96654/xadistra.htm#1061004

Note that depending on the vendor, 'db engine' and 'database' are not exactly the same thing. Some systems will host multiple dbs on the same server and allow the optimization to work across them, whereas others may treat each as a separate transaction engine scope and not optimize such cases. Datasources may also differ only in userid/schema used for the connection, relying on the permissions/schema namespacing to isolate applications without requiring a distinct database for the purpose. The optimization almost always works in such cases.

In some cases where the apps use the same XADatasource, the JCA registers just one XAResource with the JTA, potentially allowing it to use the more aggressive 1PC optimization instead.

Whilst it's true that connections may switch between local and XA transaction context, it's currently not possible for the JTA to take advantage of this. Since resources are enlisted only on demand, the system doesn't know how many are going to participate in the transaction until it reaches the termination stage. The JTA spec group has previously discussed allowing configuration, similar to the way tx timeouts are set, which would allow the application to indicate at begin that a tx is expected to be single resource, or more generally to list what XAResources it's expected to contain. That information would allow the JTA to drive the resource in local tx mode rather than XA mode where appropriate, eliding the start/end/prepare protocol calls. It would also remove the need to manually optimize such cases by deploying both XA and non-XA datasources for the same database in an application. It's not currently on the roadmap though.

Question:

I create CDI Event handler

    @Singleton
    @Startup
    @ConcurrencyManagement(ConcurrencyManagementType.BEAN)
    @Slf4j
    public class IndicatorEventHandler {
    @Inject
    private Event<TransactionEvent> baeEvent;

    public void onBusinessAccessEntityChangedEvent(@Observes(during = TransactionPhase.BEFORE_COMPLETION) TransactionEvent event) {
            log.info("On business access changed event: {}", event.getEventName());
            calculateIndicators(event);
            try {
                updatePeIndicators(event);
            } catch (ApplicationException e) {
                log.error("Error in ipdate indicators", e);
            }
        }
//some code
    }

And I have this error

000001ae Transactional E TransactionalEventNotifier notifyObserver В наблюдателе транзакций возникла исключительная ситуация.
                                 org.apache.webbeans.exception.WebBeansException: java.lang.reflect.InvocationTargetException
    at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:291)
    at org.apache.webbeans.ee.event.TransactionalEventNotifier$AbstractSynchronization.notifyObserver(TransactionalEventNotifier.java:103)
    at org.apache.webbeans.ee.event.TransactionalEventNotifier$BeforeCompletion.beforeCompletion(TransactionalEventNotifier.java:122)
-------------
Caused by: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalStateException: Preparing
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSIException(BusinessExceptionMappingStrategy.java:167)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSITransactionRolledBackException(BusinessExceptionMappingStrategy.java:618)
    at com.ibm.ejs.container.EJSDeployedSupport.mapCSITransactionRolledBackException(EJSDeployedSupport.java:700)
    at com.ibm.ejs.container.EJSContainer.postInvokeRolledbackException(EJSContainer.java:4886)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4572)`

If I change TransactionPhase.BEFORE_COMPLETION to TransactionPhase.AFTER_COMPLETION method works correctly.

Full stacktrace

CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "onBusinessAccessEntityChangedEvent". Exception data: java.lang.IllegalStateException: Preparing
at com.ibm.ejs.container.ContainerTx.ensureActive(ContainerTx.java:486)
at com.ibm.ejs.container.ContainerTx.preInvoke(ContainerTx.java:1543)
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3687)
at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3047)
at com.mycompany.services.list.indicator.EJSLocalNSGIndicatorEventHandler_5549712c.onBusinessAccessEntityChangedEvent(EJSLocalNSGIndicatorEventHandler_5549712c.java)
at sun.reflect.GeneratedMethodAccessor1260.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.apache.webbeans.ejb.common.proxy.EjbBeanProxyHandler.invoke(EjbBeanProxyHandler.java:204)
at com.mycompany.services.list.indicator.IndicatorEventHandler_$$_javassist_195.onBusinessAccessEntityChangedEvent(IndicatorEventHandler_$$_javassist_195.java)
at sun.reflect.GeneratedMethodAccessor1260.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:285)
at org.apache.webbeans.ee.event.TransactionalEventNotifier$AbstractSynchronization.notifyObserver(TransactionalEventNotifier.java:103)
at org.apache.webbeans.ee.event.TransactionalEventNotifier$BeforeCompletion.beforeCompletion(TransactionalEventNotifier.java:122)
at com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:153)
at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2384)
at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:588)
at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1029)
at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:963)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)
at com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:191)
at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:949)
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:262)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:567)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4486)
at com.mycompany.api.EJSRemote0SLFormServiceImpl_208941b0.unbindForm(EJSRemote0SLFormServiceImpl_208941b0.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.CORBA.iiop.ClientDelegate$5.run(ClientDelegate.java:1268)
at java.security.AccessController.doPrivileged(AccessController.java:488)
at com.ibm.CORBA.iiop.ClientDelegate.invoke0(ClientDelegate.java:1265)
at com.ibm.CORBA.iiop.ClientDelegate$ClientDelegate0.invoke(ClientDelegate.java:1502)
at com.sun.proxy.$Proxy541.unbindForm(Unknown Source)
at com.mycompany.api._FormService_Stub.unbindForm(_FormService_Stub.java:1)
at com.mycompany.plugin.utils.FormPluginService.updateModel(FormPluginService.java:380)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.mycompany.plugin.base.ResponseCreator.create(ResponseCreator.java:369)
at com.mycompany.plugin.base.BasePluginService.invokeOperation(BasePluginService.java:299)
at com.mycompany.plugin.base.BasePluginService.execute(BasePluginService.java:263)
at com.mycompany.plugin.utils.FormPluginService.execute(FormPluginService.java:83)
at com.ibm.ecm.util.PluginUtil.invokeService(PluginUtil.java:808)
at com.ibm.ecm.struts.actions.PluginAction.executeBaseAction(PluginAction.java:115)
at com.ibm.ecm.struts.actions.BaseAction.execute(BaseAction.java:227)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at com.ibm.ecm.struts.controller.ControllerServlet.process(ControllerServlet.java:246)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at com.ibm.ecm.filters.RequestParamFilter.doFilter(RequestParamFilter.java:79)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:949)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)

And this

 Transactional E TransactionalEventNotifier notifyObserver В наблюдателе транзакций возникла исключительная ситуация.
                                 org.apache.webbeans.exception.WebBeansException: java.lang.reflect.InvocationTargetException
    at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:291)
    at org.apache.webbeans.ee.event.TransactionalEventNotifier$AbstractSynchronization.notifyObserver(TransactionalEventNotifier.java:103)
    at org.apache.webbeans.ee.event.TransactionalEventNotifier$BeforeCompletion.beforeCompletion(TransactionalEventNotifier.java:122)
    at com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)
    at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:153)
    at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2384)
    at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:588)
    at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1029)
    at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:963)
    at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)
    at com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:191)
    at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:949)
    at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:262)
    at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:567)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4486)
    at com.mycompany.api.EJSRemote0SLFormServiceImpl_208941b0.unbindForm(EJSRemote0SLFormServiceImpl_208941b0.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.ibm.CORBA.iiop.ClientDelegate$5.run(ClientDelegate.java:1268)
    at java.security.AccessController.doPrivileged(AccessController.java:488)
    at com.ibm.CORBA.iiop.ClientDelegate.invoke0(ClientDelegate.java:1265)
    at com.ibm.CORBA.iiop.ClientDelegate$ClientDelegate0.invoke(ClientDelegate.java:1502)
    at com.sun.proxy.$Proxy541.unbindForm(Unknown Source)
    at com.mycompany.api._FormService_Stub.unbindForm(_FormService_Stub.java:1)
    at com.mycompany.plugin.utils.FormPluginService.updateModel(FormPluginService.java:380)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.mycompany.plugin.base.ResponseCreator.create(ResponseCreator.java:369)
    at com.mycompany.plugin.base.BasePluginService.invokeOperation(BasePluginService.java:299)
    at com.mycompany.plugin.base.BasePluginService.execute(BasePluginService.java:263)
    at com.mycompany.plugin.utils.FormPluginService.execute(FormPluginService.java:83)
    at com.ibm.ecm.util.PluginUtil.invokeService(PluginUtil.java:808)
    at com.ibm.ecm.struts.actions.PluginAction.executeBaseAction(PluginAction.java:115)
    at com.ibm.ecm.struts.actions.BaseAction.execute(BaseAction.java:227)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at com.ibm.ecm.struts.controller.ControllerServlet.process(ControllerServlet.java:246)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
    at com.ibm.ecm.filters.RequestParamFilter.doFilter(RequestParamFilter.java:79)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:949)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor1260.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:285)
    ... 71 more
Caused by: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalStateException: Preparing
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSIException(BusinessExceptionMappingStrategy.java:167)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSITransactionRolledBackException(BusinessExceptionMappingStrategy.java:618)
    at com.ibm.ejs.container.EJSDeployedSupport.mapCSITransactionRolledBackException(EJSDeployedSupport.java:700)
    at com.ibm.ejs.container.EJSContainer.postInvokeRolledbackException(EJSContainer.java:4886)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4572)
    at com.mycompany.services.list.indicator.EJSLocalNSGIndicatorEventHandler_5549712c.onBusinessAccessEntityChangedEvent(EJSLocalNSGIndicatorEventHandler_5549712c.java)
    at sun.reflect.GeneratedMethodAccessor1260.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.webbeans.ejb.common.proxy.EjbBeanProxyHandler.invoke(EjbBeanProxyHandler.java:204)
    at com.mycompany.services.list.indicator.IndicatorEventHandler_$$_javassist_195.onBusinessAccessEntityChangedEvent(IndicatorEventHandler_$$_javassist_195.java)
    ... 75 more
Caused by: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalStateException: Preparing
    at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:475)
    at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:365)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapException(BusinessExceptionMappingStrategy.java:392)
    at com.ibm.ejs.container.BusinessExceptionMappingStrategy.setUncheckedException(BusinessExceptionMappingStrategy.java:554)
    at com.ibm.ejs.container.EJSDeployedSupport.setUncheckedException(EJSDeployedSupport.java:520)
    at com.ibm.ejs.container.EJSContainer.preinvokeHandleException(EJSContainer.java:3353)
    at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3098)
    ... 81 more
Caused by: java.lang.IllegalStateException: Preparing
    at com.ibm.ejs.container.ContainerTx.ensureActive(ContainerTx.java:486)
    at com.ibm.ejs.container.ContainerTx.preInvoke(ContainerTx.java:1543)
    at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3687)
    at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3047)
    ... 81 more

Answer:

Unfortunately this is a legitimate bug that was fixed in the WebSphere 9.0 release.