EJB - MDB Transaction
Hi,
I am trying to configure a transaction to span between one Stateless EJB and MANY
JMS Messages sent to a topic consumed via a MDB.
I have a Stateless EJB Services called copyOffers(List offerIds). For each offerId
in OfferIds it sends a JMS Message to the CopyOffer Topic. I have one MDB subscribed
to the Topic that does the work of copying the ONE offer it was provided. I also,
have configured the JMSReplyTo with a temp. Topic so that all the CopyOfferMDBs
can notify the Stateless EJB when they are done.
I want all the EJB and MDB calls to act within ONE transaction. The Stateless
Session Bean is marked as REQUIRED and the MDB is marked as CONTAINER and also
REQUIRED.
Here is what I have done...
If I mark my JMS Connection Factory as User Transaction Enabled = true... ALL
the MDB messages are only delivered once the Stateless EJB is commited. Then each
MDB is in its own transaction.
I can not get all the MDBs and the EJB to be in ONE transaction whereby if ONE
MDB failed ALL failed.
Any ideas?
Thanks,
Mike Porter
Cool!
There is no standard J2EE API or WebLogic J2EE extension
for handling multiple asynchronous workers
in the same transaction, but there is a supported non-J2EE
"back-door". Use the (free) Tuxedo java client's "tpacall()"
methods, and program your EJBs to be Tuxedo aware. (Tuxedo
is BEA's "C" based app server, but no Tuxedo server is needed.)
http://edocs.bea.com/wls/docs81/wtc.html
I do not know of any customers without a Tuxedo background that
are doing this. But, if you are interested, the "wtc" newsgroup
should be able to get you started.
Tom
P.S. The alternative is to use multiple transactions, which
inform some stateful central location when they are done. This
stateful thing could be an entity bean. This requires extra
code for failure cases - as it requires code for detecting the
failures in the first place, code for fixing up the failed
transaction(s), and for undoing the committed transactions(s).
This kind of code is generally referred to as
"compensating transactions", and, as you can imagine, sometimes
gets pretty hairy pretty fast...
Mike Porter wrote:
> I was afraid of that.
>
> Any ideas how I can asynchronously handle multiple workers(IE:my offer copiers)
> in one transaction. I thought JMS would help but I guess not.
>
> Thanks,
>
> Mike
>
> Tom Barnes <[email protected]> wrote:
>
>>Hi Mike,
>>
>>As with any messaging system, the production of a message can
>>not participate in the same transaction as the consumption of
>>a message. The producer's commit call is what makes
>>the message available for consumption.
>>
>>You may want to read the "transactions" chapter of the
>>JMS Programmer's guide.
>>
>>Tom
>>
>>
>>Mike Porter wrote:
>>
>>>Hi,
>>>
>>>I am trying to configure a transaction to span between one Stateless
>>
>>EJB and MANY
>>
>>>JMS Messages sent to a topic consumed via a MDB.
>>>
>>>I have a Stateless EJB Services called copyOffers(List offerIds). For
>>
>>each offerId
>>
>>>in OfferIds it sends a JMS Message to the CopyOffer Topic. I have one
>>
>>MDB subscribed
>>
>>>to the Topic that does the work of copying the ONE offer it was provided.
>>
>>I also,
>>
>>>have configured the JMSReplyTo with a temp. Topic so that all the CopyOfferMDBs
>>>can notify the Stateless EJB when they are done.
>>>
>>>
>>>I want all the EJB and MDB calls to act within ONE transaction. The
>>
>>Stateless
>>
>>>Session Bean is marked as REQUIRED and the MDB is marked as CONTAINER
>>
>>and also
>>
>>>REQUIRED.
>>>
>>>Here is what I have done...
>>>If I mark my JMS Connection Factory as User Transaction Enabled = true...
>>
>>ALL
>>
>>>the MDB messages are only delivered once the Stateless EJB is commited.
>>
>>Then each
>>
>>>MDB is in its own transaction.
>>>
>>>I can not get all the MDBs and the EJB to be in ONE transaction whereby
>>
>>if ONE
>>
>>>MDB failed ALL failed.
>>>
>>>Any ideas?
>>>
>>>Thanks,
>>>
>>>Mike Porter
>>>
>>
>
Similar Messages
-
Hi,
I'm having some issues in same cases with MDB transactions on WL. I have an MDB deployed on a 9.2 WL defined as a CMP with auto-acknowledge in the EJB descriptor (using EJB 2.1 standards) which listens on a queue which is defined in the local WL JMS module and mapped to an external Tibco EMS queue.
Used descriptor configuration :
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
</activation-config>
The MDB processes the message, accesses a DB and sends it of the an external system. When no exception happened the MDB method finishes and normally the container acknowledges
This all works great untill we put some load on the queue. Sometimes we note that a JMS message gets stuck in the input queue when lots of messages are being put on the input queue. We can trace that such messages actually were picked up by the MDB and processed to a certain extend.
Sometimes the processing log trace just stops in the middle of processing. Sometimes the entire processing log trace is present. However the JMS messages are kept in the input queue and seem to locked (they can't be flushed out as long as the component is still running).
It looks like the messages are awaiting acknowledgement from the WL container manager but somehow the transaction got lost and never got back to the external EMS to acknowledge the message in the input queue.
I was wondering if there is a way to monitor CMP transactions or the status of the container manager? As far as I know the container manager always tries to contact the remote EMS server to acknowledge the message in this setup. What would happen if the remote EMS server would be overloaded and could not respond back to the WL container manager to confirm message acknowledgment?Thanks for the reply. There are no errors what so ever regarding MDB issues. Not in the weblogic / console logging, nor in the logging of the component itself.
The MDB itself is setup to have 16 concurrent beans per component deployment. The component is clustered over 4 server instances. So there are quite some concurrent MDBs running. However since the messages get stuck for weeks eventhough the component only has bursts of messages to process, one would think that the the stuck messages would be processed whenever the component has some spare time (which it has a lot between the bursts).
Therefor i doubt it has anything to do with too little MDBs running. But frankly I have no idea what's wrong. -
Is there a special reason why NotSupported and Required are the only two supported transaction attributes? I understand that MDBs cannot have a client-initiated transaction, but there are other transaction attributes that indicate the same thing.
If an MDB wants to indicate that it should not execute in a transaction, why can't it indicate Never or Supports in addition to NotSupported? In the case of no client-initiated transaction, all three result in the annotated method occuring under no transaction.
If an MDB wants to indicate that it should execute in a transaction, why can't it indicate RequiresNew in addition to Required? Again, in the case of no client-initiated transaction, both result in the annotated method occuring under a transaction.
The Mandatory attribute throws an exception if there is no client-initiated transaction, so clearly that is never appropriate for MDBs. But I am confused as to why the other transaction attributes cannot be used as indicated above.
Please clarify why the specification indicates this about MDB transaction attributes...
Thanks.When ejb webservice endpoints were introduced in J2EE 1.4 there was no support for
propagation of transaction context over a webservice invocation. Both the JSR 109
spec and the EJB 2.1 spec prohibited the use of MANDATORY on an ejb web
service endpoint since using it was likely a developer error.
In Java EE 5 the restriction against MANDATORY for ejb web service endpoints was removed in the
EJB 3.0 spec. There's still no requirement that transactions be able to flow with web service
invocations but there are some products that support it so the ejb container is no longer
required to throw an exception in that case.
--ken -
i have an MDB deployed on weblogic 8.1 sp6 server. My confusion here is how the MDB handles transaction rollbacks. E.g suppose if the MDB is designed to do the below action.
1) read an xml message from a jms queue
2) insert some database records
3) generate some xml message, post it to some other jms queue
suppose if step 1 and 2 is completed, and its on step 3, at this point weblogic server shutdowns suddenly, once i restart the server, it reads the xml message again from the jms queue, but this time it errors out, because it finds the data already entered in step 2.
My question is when the weblogic server shut down while the mdb was at step 3, why didnt it removed all the db entries it made in step 2. This behaviour apears to me as partial rollback. I have given the mdb descriptor below.
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>CSS_Response</ejb-name>
<ejb-class>com.bt.neo.core.utility.appcontroller.transport.mdb.JmsMessageReceiver</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>core-css-response-inbound.xml</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>ProcessorBeanName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>transportAdaptor</env-entry-value>
</env-entry>
<resource-ref>
<res-ref-name>jms/faultTo</res-ref-name>
<res-type>javax.jms.Destination</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CSS_Response</ejb-name>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>Please clear my doubt.
Edited by: Deepak Dev on 19-Dec-2011 11:01General information on message-driven beans can be found here: http://docs.oracle.com/cd/E12840_01/wls/docs103/ejb/message_beans.html
To transaction configuration is discussed here: http://docs.oracle.com/cd/E12840_01/wls/docs103/ejb/message_beans.html#wp1162058
Looks like you have to set the transaction-type to Container and the trans-attribute to required. Also see the note:
- However, if you make this configuration error, the MDB will not run transactionally—if a failure occurs mid-transaction, updates that occurred prior to the failure will not be rolled back. -
Ejb MDB Pool Settings ignored?
Hi.
I have a series of MDBs, and have tried to increase performance by setting the InitialSize and MaxSize values of the bean in the ejb-j2ee-engine.xml (not version 3!).
However, it doesnt seem to make any difference and messages seem to be getting processed sequentially, as if there was only one instance of the bean.
Here is the layout of my xml.
<ejb-j2ee-engine
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ejb-j2ee-engine.xsd">
<description/>
<enterprise-beans>
<enterprise-bean>
<ejb-name>mySimpleMDB</ejb-name>
<jndi-name>jms/myTestQueue</jndi-name>
<message-props>
<destination-name>jms/myTestQueue</destination-name>
<connection-factory-name>jms/queueConnectionFactory</connection-factory-name>
<property>
<property-name>InitialSize</property-name>
<property-value>1</property-value>
</property>
<property>
<property-name>MaxSize</property-name>
<property-value>1</property-value>
</property>
<property>
<property-name>ResizeStep</property-name>
<property-value>1</property-value>
</property>
</message-props>
</enterprise-bean>
</enterprise-beans>
</ejb-j2ee-engine>
Is this the correct location - i am pretty sure it is by looking at the documentation.
regards,
AndrewHi Vladimir - here are the relevant XML files:
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>TestApp</display-name>
<message-driven>
<description>Validates</description>
<display-name>Validation</display-name>
<ejb-name>FileValidationMDB</ejb-name>
<ejb-class>com.test.dts.ejb.FileValidationMDBBean</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<env-entry>
<description/>
<env-entry-name>ejb/beanRefContext</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>classpath:beanRefContext.xml</env-entry-value>
</env-entry>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>FileValidationMDB</ejb-name>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
ejb-j2ee-engine.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ejb-j2ee-engine
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ejb-j2ee-engine.xsd">
<description/>
<enterprise-beans>
<enterprise-bean>
<ejb-name>FileValidationMDB</ejb-name>
<jndi-name>jms/dts/registeredFiles</jndi-name>
<message-props>
<destination-name>jms/dts/registeredFiles</destination-name>
<connection-factory-name>jms/dts/queueConnectionFactory</connection-factory-name>
<property>
<property-name>parallel-consumers</property-name>
<property-value>10</property-value>
</property>
<property>
<property-name>InitialSize</property-name>
<property-value>10</property-value>
</property>
<property>
<property-name>MaxSize</property-name>
<property-value>10</property-value>
</property>
<property>
<property-name>ResizeStep</property-name>
<property-value>1</property-value>
</property>
</message-props>
</enterprise-bean>
</enterprise-beans>
</ejb-j2ee-engine>
jms-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<jms-resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="jms-resources.xsd">
<connection-factory>
<name>jms/dts/XAConnectionFactory</name>
<sap-local-factory-type>
<type>javax.jms.XAConnectionFactory</type>
<virtual-provider>default</virtual-provider>
</sap-local-factory-type>
</connection-factory>
<connection-factory>
<name>jms/dts/queueConnectionFactory</name>
<sap-local-factory-type>
<type>javax.jms.XAQueueConnectionFactory</type>
<virtual-provider>default</virtual-provider>
</sap-local-factory-type>
</connection-factory>
<connection-factory>
<name>jms/dts/topicConnectionFactory</name>
<sap-local-factory-type>
<type>javax.jms.XATopicConnectionFactory</type>
<virtual-provider>default</virtual-provider>
</sap-local-factory-type>
</connection-factory>
<destination>
<name>jms/dts/registeredFiles</name>
<type>javax.jms.Queue</type>
<sap-local-destination-type>
<virtual-provider>default</virtual-provider>
<!-- Properties for Message delivery -->
<property>
<description>
Message Delivery Attempts Limited - We dont limit...
</description>
<config-property-name>
deliveryAttemptsLimited
</config-property-name>
<config-property-value>false</config-property-value>
</property>
<property>
<description>Delay in Milliseconds</description>
<config-property-name>
deliveryDelayInterval
</config-property-name>
<config-property-value>60000</config-property-value>
</property>
</sap-local-destination-type>
</destination>
</jms-resources>
Hope this sheds some light on the subject...
Andrew -
Javax.ejb.EJBException: Transaction aborted
Hello everyone, I am new in javaEE6. When i try to develop and simple example i meet this error but i can't find which code line cause it. I use JSF EJB3.1 EclipseLink JPA 2.0 in Glassfish v3 and developed in Netbean6.8. Here is my Stack trace .
Caused by: javax.ejb.EJBException: Transaction aborted
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4997)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
at $Proxy158.createUsers(Unknown Source)
at home.tuan.bussiness.__EJB31_Generated__UsersEJB__Intf____Bean__.createUsers(Unknown Source)
at home.tuan.controller.UsersController.doCreateUser(UsersController.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 32 more
Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:450)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:837)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
... 48 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "." at line 1, column 29.
Error Code: -1
Call: INSERT INTO ChatDatabase.dbo.Users (UserName, Pass) VALUES (?, ?)
bind => [er, w]
Query: InsertObjectQuery(home.tuan.model.Users@825299)My Entity is:
package home.tuan.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
* @author minhtuan
@Entity
@Table(name = "Users", catalog = "ChatDatabase", schema = "dbo")
public class Users implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "UserName")
private String userName;
@Column(name = "Pass")
private String pass;
public Users() {
public Users(String userName, String pass) {
this.userName = userName;
this.pass = pass;
public String getUserName() {
return userName;
public void setUserName(String userName) {
this.userName = userName;
public String getPass() {
return pass;
public void setPass(String pass) {
this.pass = pass;
}My session bean is:
package home.tuan.bussiness;
import home.tuan.model.Users;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
* @author minhtuan
@Stateless
public class UsersEJB {
@PersistenceContext(unitName="MavenTestPU")
private EntityManager em ;
public Users createUsers(Users newUser){
em.persist(newUser);
return newUser;
}My controller class is:
package home.tuan.controller;
import home.tuan.bussiness.UsersEJB;
import home.tuan.model.Users;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.transaction.UserTransaction;
* @author minhtuan
@ManagedBean(name="UsersController")
@RequestScoped
public class UsersController {
/** Creates a new instance of UsersController */
@EJB
UsersEJB userEJB;
Users newUser = new Users();
List<Users> listUsers = new ArrayList<Users>();
public String doNewUser(){
return "index.jsp";
public String doCreateUser(){
System.out.println("Den day rui");
System.out.println(newUser.getUserName());
System.out.println(newUser.getPass());
newUser = userEJB.createUsers(newUser);
return "index.jsp";
public List<Users> getListUsers() {
return listUsers;
public void setListUsers(List<Users> listUsers) {
this.listUsers = listUsers;
public Users getNewUser() {
return newUser;
public void setNewUser(Users newUser) {
this.newUser = newUser;
}And my persistence.xml is:
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="MavenTestPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>home.tuan.model.Users</class>
<properties>
<!--
<property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
<property name="javax.persistence.jdbc.password" value="12345"/>
<property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
-->
<property name="eclipselink.target-database" value="SQLSERVER"/>
<property name="eclipselink.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="eclipselink.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
<!--<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>-->
<!--<property name="eclipselink.jdbc.url" value="jdbc:derby:chapter10DB;create=true"/>-->
<property name="eclipselink.jdbc.user" value="sa"/>
<property name="eclipselink.jdbc.password" value="12345"/>
<!--property name="eclipselink.ddl-generation" value="update"/-->
<!--property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>Thanks in advance
Edited by: ActiveDean on Dec 24, 2009 4:38 PMYou need to step through a debugger and find the source of your problem as something is clearly going wrong and causing the transaction to roll back. That is all that message tells us.
m -
EJB nested transaction handling.
My situation closely relates to the round-trip planning problem. I have a series of say 5 EJBs (session and entity both involved) doing a particular work. If an error occurs at the EJB 5 stage, I don't want to rollback the work done in EJB 1 and 2 but I want EJB 3 onwards to rollback. Is this kind of nested transaction model possible. Please note that I want to use container-managed-transactions. If not possible, please guide me how can I use bean-managed-transaction to solve it? Thanks in advance for any help.
Yes, it is possible, but you have to make sure that ANY call to EJB 3 through that method has the same requirements:
EJB 1 - Transaction = Required
EJB 2 - Transaction = Required
EJB 3 - Transaction = Requires New (starts a new transaction, "holds" the one from 1 & 2)
EJB 4 - Transaction = Requires
EJB 5 - Transaction = Requires -
Help-Problem in calling JMS inside an EJB having transaction attribute Required New
Hi,
Version wl 5.1 service pack 8
OS - unix
I am using a Container managed bean say Bean1(transaction attribute Required)
which in one of its method is trying to call another EJB say Bean2 which has the
transaction attribute set to "RequiredNew".Inside the method in Bean2 i have my
JMS funtions coded to persist to database.JMS uses Queue connection factory and
is an non transaction JMS session.The JMS server is running in a separate weblogic
server and not in the server where EJB is deployed.I use the url of the JMS server
and get the context of that server and connect my JMS.
The problem that i am facing is
I do the transaction in bean1 and the i make the call to bean2 to do the JMS work
and i can see the JMS doing the insert in the table and everthing works fine.But
after few seconds i can see the exception/message seen on the console of the weblogic
server where my JMS server is running as below
Tue Sep 04 15:57:09 CDT 2001:<I> <TX> Transaction (TxC (30486015, xid = 99963563
2756_5, timeout = 30, txState = Marked Rollback, root = 829817264280676325S10.51
.110.237:[7001,7001,7002,7002,7001,-1]/326) rolled back after 30 sec.
After this happen i dont see any roll back in either bean1 or bean2 or the JMS
insert is rolled back.
I don't know why this exception is thrown and no effects on the rollback and it
works the way i wanted.But the only thing that keeps bothering me is the rollback
and why does this happen.
Thanks
Krish.
The exception your seeing is troubling - if the tran is rolled
back than whatever work is associated should also roll back. I suggest
instrumenting your code to see if the tran rolling back is the same tran
that is being used for the transactional application work that appears to succeed.
Also, try forcing a rollback, you may see that the EJB work truly rolls back
while the JMS work does not.
I'm not really familiar with 5.1, but I know there is a fundamental limitation to one
phase commits, this means that the JDBC connection pool used by JMS as well
as that used by the EJB must be one and the same - I'm not exactly sure how
it works, but I'm pretty sure multiple servers can share the same connection pool.
This post seems unrelated to clustering, if you need further help, I
suggest posting in the ejb or transaction newsgroups.
Krish wrote:
> Hi,
>
> Version wl 5.1 service pack 8
> OS - unix
>
> I am using a Container managed bean say Bean1(transaction attribute Required)
> which in one of its method is trying to call another EJB say Bean2 which has the
> transaction attribute set to "RequiredNew".Inside the method in Bean2 i have my
> JMS funtions coded to persist to database.JMS uses Queue connection factory and
> is an non transaction JMS session.The JMS server is running in a separate weblogic
> server and not in the server where EJB is deployed.I use the url of the JMS server
> and get the context of that server and connect my JMS.
>
> The problem that i am facing is
>
> I do the transaction in bean1 and the i make the call to bean2 to do the JMS work
> and i can see the JMS doing the insert in the table and everthing works fine.But
> after few seconds i can see the exception/message seen on the console of the weblogic
> server where my JMS server is running as below
>
> Tue Sep 04 15:57:09 CDT 2001:<I> <TX> Transaction (TxC (30486015, xid = 99963563
> 2756_5, timeout = 30, txState = Marked Rollback, root = 829817264280676325S10.51
> 110.237:[7001,7001,7002,7002,7001,-1]/326) rolled back after 30 sec.
>
>
> After this happen i dont see any roll back in either bean1 or bean2 or the JMS
> insert is rolled back.
>
> I don't know why this exception is thrown and no effects on the rollback and it
> works the way i wanted.But the only thing that keeps bothering me is the rollback
> and why does this happen.
>
> Thanks
>
> Krish.
-
Hi ,
I have an MDB running on weblogic 8.2 and calling a remove ejb running on a different machine. After getting home interface when I tried to create the remote object Iam getting the following error.
java.lang.NullPointerException
at weblogic.transaction.internal.PropagationContext.useNewMethod(PropagationContext.java:866)
at weblogic.transaction.internal.PropagationContext.writeExternal(PropagationContext.java:169)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:100)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObjectWL(ChunkedObjectOutputStream.java:122)
at weblogic.rjvm.MsgAbbrevOutputStream.setTxContext(MsgAbbrevOutputStream.java:122)
at weblogic.rjvm.BasicOutboundRequest.setTxContext(BasicOutboundRequest.java:156)
at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:106)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:276)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
Can any body tell what could be the reason. The message sent from MDB to ejb is a transactional message.
Thanks in advance
ManikyalaI suggest posting to the EJB newsgroup.
(1) Transactions certainly are supported for remote services. This is a common use case.
(2) Your problem seemed to occur when getting the remote home - but likely would not occur when actually using it. Since I think (not 100% sure) that the action of obtaining the remote home need not be transactional, I previously suggested suspending the transactions, but only for the duration of the call to get the remote home.
Tom
> Hi Tom,
>
> Looks like what Iam doing is not correct.
>
> Iam calling a remote ejb which on a different server
> from my MDB. Iam using t3 to get the context. Also in
> the weblogic-ejb-jar.xml I put transaction value as
> Required.
>
> Now I replaced that with NotSupported and problem is
> solved.
>
> The conclusion is (if Iam not wrong) when creating a
> remote home we should not use transactions since the
> remote service is not participating in transaction.
>
> Thanks again Tom
>
>
> Manikyala -
Randomly occurring error while starting MDB transaction
We have been seeing a strange intermittent problem with MDBs in a clustered WLS 9.1 environment. Our cluster consists of two managed servers, each of which runs on a separate Windows machine, and our application is targeted to both. We use container managed transactions. From time to time, one of the MDBs on the second managed server runs into a problem where it is unable to start a transaction, and the message is automatically transferred to the appropriate JMS error destination before the logic within the onMessage method is even invoked. This results in a situation where our app logs have no record that the message was ever received, so we continually have to go out to the error destinations to see if there are any messages. This problem does not appear to follow any pattern, and occurs randomly with pretty much all of our MDBs on the second server. The stack trace from the log is below. Any help in tracking down the cause of this problem would be greatly appreciated.
Regards,
Sabrina
<Jun 12, 2006 2:02:47 PM EDT> <Error> <JMSClientExceptions> <BEA-055165> <The following exception has occurred:
java.lang.RuntimeException: [EJB:010166]Error occurred while starting transaction: weblogic.jms.common.JMSException: Unexpected remote responsenull.
java.lang.RuntimeException: [EJB:010166].
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:282)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
Truncated. see log file for complete stacktrace
weblogic.jms.common.JMSException: Unexpected remote responsenull
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:53)
at weblogic.jms.client.JMSSession.acknowledge(JMSSession.java:1775)
at weblogic.jms.client.JMSSession.associateTransaction(JMSSession.java:1854)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:269)
Truncated. see log file for complete stacktrace
weblogic.jms.common.JMSException: Unexpected remote responsenull
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:63)
at weblogic.jms.dispatcher.Request.getResult(Request.java:51)
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:803)
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncTran(DispatcherImpl.java:197)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:51)
Truncated. see log file for complete stacktrace
weblogic.jms.common.JMSException: Unexpected remote responsenull
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:758)
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncTran(DispatcherImpl.java:197)
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:51)
at weblogic.jms.client.JMSSession.acknowledge(JMSSession.java:1775)
at weblogic.jms.client.JMSSession.associateTransaction(JMSSession.java:1854)
Truncated. see log file for complete stacktrace
weblogic.jms.common.JMSException: Unexpected remote responsenull
at weblogic.jms.dispatcher.Request.getAppException(Request.java:42)
at weblogic.messaging.dispatcher.Request.handleResult(Request.java:529)
at weblogic.rmi.extensions.AsyncResultFactory$CallbackableResultImpl.setInboundResponse(AsyncResultFactory.java:75)
at weblogic.rjvm.BasicOutboundRequest$BasicResponseListener.response(BasicOutboundRequest.java:217)
at weblogic.rjvm.ResponseWithListener.notify(ResponseWithListener.java:25)
Truncated. see log file for complete stacktrace
java.lang.ClassCastException: weblogic.rjvm.ClassTableEntry
at weblogic.rjvm.MsgAbbrevInputStream.readExtendedContexts(MsgAbbrevInputStream.java:216)
at weblogic.rjvm.ResponseImpl.retrieveThreadLocalContext(ResponseImpl.java:126)
at weblogic.rjvm.ResponseWithListener.unmarshalReturn(ResponseWithListener.java:43)
at weblogic.rmi.internal.AsyncResultImpl.getResults(AsyncResultImpl.java:48)
at weblogic.rmi.internal.AsyncResultImpl.getObject(AsyncResultImpl.java:98)
Truncated. see log file for complete stacktrace
>Hi Sabrina,
Did you ever get a solution to this problem?
We are seeing the same thing on WebLogic 9.1. It started happening in the past week.
We have the same originating error ..
java.lang.ClassCastException: weblogic.rjvm.ClassTableEntry
Many thanks,
Shane -
MDB transaction getting silently rolled back?
I have an MDB that is doing a delete of a database record in the onMessage method.
It seems to work fine. I see no errors in the log, in fact I have some debug
statements that indicate everything was completed normally. I even do a count
sql using the same where clause and print the results and see a '0'.
However, when I check the database, the record is still there.
It seems as if the transaction is getting rolled back somehow. The MDB is transaction
required/container tx. I never setRollbackOnly anywhere.
The topic was originally published in a transaction that was rolled back, if that
makes any difference. In fact, the point of the MDB is to clean up a record that
was created during the transaction but not within the transaction.
Any help is appreciated!
ken
It turned out that the MDB was using a different connection pool than it should
have, which was pointed to an old copy of the database. So it wasn't really rolling
back, it really was deleting records as desired, just in the wrong database.
Thanks
ken
Tom Barnes <[email protected].bea.com>
wrote:
>Some random ideas:
>
>Is the app sending a delete request to the MDB, and
>the MDB acting on it, before the record is even inserted?
>
>Does the delete request have the correct row-id/PK?
>
>Is the MDB app failing without your knowledge? You
>can instrument the MDB onMessage() with a
>"try catch Throwable" to see.
>
>Is the MDB tx timing out trying to get a lock
>on the row? You can instrument the onMessage
>with timestamps to see if its taking longer than 30 seconds...
>
>Tom
>
>Ken Clark wrote:
>
>> I have an MDB that is doing a delete of a database record in the onMessage
>method.
>> It seems to work fine. I see no errors in the log, in fact I have
>some debug
>> statements that indicate everything was completed normally. I even
>do a count
>> sql using the same where clause and print the results and see a '0'.
>>
>> However, when I check the database, the record is still there.
>>
>> It seems as if the transaction is getting rolled back somehow. The
>MDB is transaction
>> required/container tx. I never setRollbackOnly anywhere.
>>
>> The topic was originally published in a transaction that was rolled
>back, if that
>> makes any difference. In fact, the point of the MDB is to clean up
>a record that
>> was created during the transaction but not within the transaction.
>>
>> Any help is appreciated!
>>
>> ken
>
-
MDB Transaction Management Problem
Hi,
I am implementing a container managed MDB. The process involves implementing the retry queue and a dead letter queue in case the message is not processed properly.
In one of the scenarios, an exception gets thrown during the message processing and the message is sent to the retry queue. But somehow it is not being delivered to this queue also and an exception gets thrown. I can see the stacktrace in the logs but somehow This exception is not causing my transaction to rollback in the original MDB and hence the message is getting lost.
I am using WSAD 5.1 with websphere app server.
Can someone help please.Hi,
Thanks for your reply.
Unfortunatelly, I didn't find any information about that issue in Release Notes of Service Pack 5.
Could you show me any source of information about this problem as it is known issue ? -
Can i call Bean managed EJB with transaction attribute Required New
I am calling a BeanManaged EJB which has a transaction attribute
set to Required New from a container managed bean. Does it create a new transaction
other than the Bean managed transaction. Do i really need a required new field
transaction attribute.All i need is user controlled transaction.Do i need to set
the transaction aatibute.
Thanks
Krish.
Hi Krish,
The question does not make much sense.
I would suggest that you set all your tx settings to "Required" unless you
have a specific reason to do otherwise, and in those few instances that you
have a specific reason to do otherwise, then change it in just those places.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"KRISH" <[email protected]> wrote in message
news:[email protected]..
>
> I am calling a BeanManaged EJB which has a transaction attribute
> set to Required New from a container managed bean. Does it create a new
transaction
> other than the Bean managed transaction. Do i really need a required new
field
> transaction attribute.All i need is user controlled transaction.Do i need
to set
> the transaction aatibute.
>
> Thanks
>
> Krish.
>
-
Configuring toplink with EJB to transactional control "CMT"
I try to use the EJB transaction CMT but I need to configure toplink to use a transactional control of my EJB container. some body knows how can i do this? and how can I configure the toplink to get JNDI datasource?
Best RegardsI dont think there is anything in Toplink you need to configure for CMT. All the transactional attributes are specified in the ejb-jar.xml file and I dont think you can edit this file using the Workbench or the Sessions Editor. With CMP the Workbench gives you an option to either overwrite this file or update but there is no way to "update" for transactional attributes. You can look at the examples for CMP (under folder advanced) that shows you how to use entity beans with Toplink in a CMP environment and you can look at the ejb-jar.xml file for more information.
Configuring Toplink to get JNDI data source is easy-thats defined in the sessions.xml. Just open the sessions.xml using the sessions editor and click on login tab and then enter in the data source information.
I try to use the EJB transaction CMT but I need to
configure toplink to use a transactional control of
my EJB container. some body knows how can i do this?
and how can I configure the toplink to get JNDI
datasource?
Best Regards -
EJB Entity transaction rollback problem
Hello,
I have created 2 beans one is a Stateless Session and the other a Bean Managed Entity Bean. The SS Bean has methods to retrieve an Oracle Connection from a DataSource defined connection pool, and to close a connection. The entity bean I have created is responsible for insterting a new record into one of the tables in my database.
I have a client app that calls the ejbCreate method on the entity bean at which point the Entity EJB takes control, gets a valid connection from the SS EJB, runs a simple working SQL SELECT statement (obtaining correct values), and then attempts to perform an insert into a table using a prepared statement. My problem is that the application runs fine without any errors and all calls are made and all calls seem to be working fine. I have checked to make sure that the Datasource I am using is AutoCommit= false and it is and there are no exceptions being thrown in my EJB's but yet it appears as though the SQL statements executeUpdate() command is not being committed as their is no rows created in the database. Does anyone know what I may be doing wrong. I have all ACL parameters set up correctly and as I stated before the entire app runs without errors and I do have a SELECT statment that is working properly within the same method as the INSERT statement which is not!!! Please send any suggestions!!
Justin
I am using CMT, it is activated by default on Entity Beans I believe. The bean itself is marked as TX_REQUIRED so I believe all the methods automatically are all TX_REQUIRED.
Here is my Bean ejbCreate Method, My PK class, and my ejb-jar.xml file-- I've pasted them below for convenience.
ejbCreate:
public CustomerPK ejbCreate(String aUserName, String aPassword, String aFirstName,
String aMiddleInit, String aLastName, String aEmailAddr)
throws javax.ejb.CreateException {
Connection conn=null;
long nextPrsnID;
long nextCustID;
if (verifyParams(aUserName, aPassword, aFirstName, aMiddleInit,
aLastName, aEmailAddr)) {
if (isUniqueUserName(aUserName)) {
try {
conn=getConnection();
conn.setAutoCommit(false);
nextPrsnID=addPerson(conn,aFirstName,aMiddleInit,aLastName); // adds a person to the person table consists of just simple SQL
nextCustID=addCustomer(conn,nextPrsnID, aUserName,aPassword, aEmailAddr); //adds a customer to the customer table
// SET THE BEAN MANAGED PUBLIC VARIABLES
this.userName=aUserName;
this.password=aPassword;
this.firstName=aFirstName;
this.middleInit=aMiddleInit;
this.lastName=aLastName;
this.emailAddr=aEmailAddr;
this.personID=nextPrsnID;
this.custID=nextCustID;
conn.commit(); // with this statement here the transaction goes through otherwise the DB will not be updated
catch (Exception e){
throw new javax.ejb.CreateException("Experiencing Database Problems-- Unrecoverable Error"); // rollback transaction
finally{
cleanup(conn,null); // close the connection
else { // UserName already exists
throw new javax.ejb.CreateException("Sorry username already exists please choose another one");
else { // Registration parameters were not verifiable
throw new javax.ejb.CreateException("Registration paramater rules were violated");
CustomerPK custPK=new CustomerPK(nextCustID);
return custPK;
EJB CUSTOMER PRIMARY KEY CLASS:
public class CustomerPK implements java.io.Serializable {
// PRIMARY KEY VARIABLES
public long CustomerID;
public CustomerPK(long aCustomerID) {
this.CustomerID=aCustomerID;
public CustomerPK() {
public String toString(){
return ((new Long(CustomerID)).toString());
public boolean equals(Object aComparePK){
if (this.CustomerID==((CustomerPK)aComparePK).CustomerID){
return true;
return false;
public int hashCode(){
return ((new Long(CustomerID).toString()).hashCode());
} // END-CLASS
CUSTOMER ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Customer</ejb-name>
<home>CustomerHome</home>
<remote>Customer</remote>
<ejb-class>CustomerBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>CustomerPK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/DeveloperPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Customer</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
"Cameron Purdy" <[email protected]> wrote:
>Are you using CMT? Have you marked the methods as REQUIRED?
>
>Peace,
>
>--
>Cameron Purdy
>Tangosol, Inc.
>http://www.tangosol.com
>+1.617.623.5782
>WebLogic Consulting Available
>
>
>"Justin Jose" <[email protected]> wrote in message
>news:[email protected]...
>>
>> Hello,
>>
>> I have created 2 beans one is a Stateless Session and the other a Bean
>Managed Entity Bean. The SS Bean has methods to retrieve an Oracle
>Connection from a DataSource defined connection pool, and to close a
>connection. The entity bean I have created is responsible for insterting a
>new record into one of the tables in my database.
>> I have a client app that calls the ejbCreate method on the entity bean at
>which point the Entity EJB takes control, gets a valid connection from the
>SS EJB, runs a simple working SQL SELECT statement (obtaining correct
>values), and then attempts to perform an insert into a table using a
>prepared statement. My problem is that the application runs fine without
>any errors and all calls are made and all calls seem to be working fine. I
>have checked to make sure that the Datasource I am using is AutoCommit=
>false and it is and there are no exceptions being thrown in my EJB's but yet
>it appears as though the SQL statements executeUpdate() command is not being
>committed as their is no rows created in the database. Does anyone know
>what I may be doing wrong. I have all ACL parameters set up correctly and
>as I stated before the entire app runs without errors and I do have a SELECT
>statment that is working properly within the same method as the INSERT
>statement which is not!!! Please send any suggestions!!
>>
>> Justin
>
>
Maybe you are looking for
-
Having a problem with Flash Builder and Extension Builder - images not apearing on Mac system
Have a panel created in Flash Builder 4.5 with Extension Builder 2.1. Everything is fine when installed on a PC but when installed on a Mac the images in the panel do not show. Mac and PC both using Adobe Photoshop CC . Both installed from same .ZXP
-
<blockquote>Locking duplicate thread.<br> Please continue here: [[/questions/858001]]</blockquote> If I try to send an email from a website by clicking on an email link my mail client (MacMail) does not pop up! This is not a problem with any other Br
-
The other day iTunes 6 would not open and gave me the error message "iTunes has encountered a problem and needs to close. We are sorry for the inconvenience." The offset number is 001006bd. After reinstalling, I still get the same message. Quicktime
-
Hi, I have had no problem whatsoever for a year now until 2 days ago when I was asked to upgrade my skype which I did. Since than my microphone is not fonctioning properly. It keeps cutting off when I talk with someone. I have check my setting on sky
-
Hi guys, I would like to know if one can hide for default the menu bar at the right hand side of the start screen (BBPSTART) in SRM 5.0. I do not need the menubar to disappear! Just hide it when oen opens SRM Thanks for any reply, Aart