This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!

San Gupta

+ Follow
since Jun 15, 2006
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by San Gupta

Thanks Dave for staying with me on this. This issue is resolved now but i am not able to understand the logic behind it. In my application i have two transaction managers. If @Transactional is not not having transaction manager mentioned , spring is taking the first one declared in the application context.

<tx:annotation-driven transaction-manager="transactionManager" />
<tx:annotation-driven transaction-manager="txManager" />

In the above case , spring is taking "transactionManager" if @Transactional is not having any mention.

Case : 1 (Job i.e java based project)

Transactional(readOnly = false, value = "txManager")
public Entity m1(Entity e)  

@Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
public Entity m2(Entity e)  

Here m1 calls m2 which is in different service (with interface).
In this case when i put debugger in TransactionSynchronizationManager, i have found that m2 is in "transactionManager". This worked fine without any issue. Entity passed from m1, was persisted correctly by m2.

Case : 2 (Webapplication)

In this case my application context was having transaction manager in different order. So m2 was also in "txManager" and it was failing with "detached entity passed to persist" issue. When i changed the order, it worked fine.

Before entering m2, TransactionSynchronizationManager.getResource(Object key) does not return any value in case 1. But in case 2, it returns. That was the difference. Any explanation will be helpful.

I have Rest Controller which is getting invoked through junit through a client application(Spring's RestTemplate). The rest controller then calling the service methods.
Yes, i am hitting the tomcat server from outside (java project).
As i mention in the first case its running as part of java application. In second case its deployed as web application in tomcat server.
I have a job(java based application  and not spring batch) which process a list of members.For each member it perform some operations through service1 and service2. Now Service1 has method m1() having @Transactional(readOnly = false, value = "txManager", propagation = Propagation.REQUIRES_NEW). This method gets the entity and calls some of the setter method to update the entity and passes to Service2.m2(entity e) which is also having @Transactional(readOnly = false, value = "txManager", propagation = Propagation.REQUIRES_NEW). This is working fine as i am not getting detached issue in method m2.

Now the same services are part of web application which is exposing rest services. While i call those rest service through junit (POST), detached issue is coming in method m2. Flow is same in both the cases as m1 is calling m2. I found that it could be because of PersistenceContextType.EXTENDED , which is solving the issue in second case but i am not sure why its working in the first case when it is not PersistenceContextType.EXTENDED. I also tried opensessioninview filter but its also not working.Below is the junit test.

SomeMemberObject memberObject=new SomeMemberObject ("name","age");
String response = LocalRestClientInvoker.invoke("http://localhost:8080/someRestService","/saveInfo",memberObject,MethodType.POST);

LoaclRestClientInvoker is using RestTemplate to call POST method.
Yes, the parameter is getting detached.
Hi ,
I have a method public int method2(Entity e) which is annotated with @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW).
While calling this method from a method1 which is already in transaction , its working fine (java project which invokes these methods). But if i call it from junit then entity is not longer attached with entity manager as a new entity manager is created .So i am getting de-attached entity error. Although its a new transaction, i want to use current entity manager only as its working from the java project.
While debugging i reached AbstractPlatformTransactionManager.getTransaction method. (I am using JPATransactionManager).
Below are the logs. Any help will be highly appreciated.

public final TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
Object transaction = doGetTransaction();

// Cache debug flag to avoid repeated checks.
boolean debugEnabled = logger.isDebugEnabled();

if (definition == null) {
// Use defaults if no transaction definition given.
definition = new DefaultTransactionDefinition();
Going from below block if its not working fine

if (isExistingTransaction(transaction)) {
// Existing transaction found -> check propagation behavior to find out how to behave.
return handleExistingTransaction(definition, transaction, debugEnabled);

// Check definition settings for new transaction.
if (definition.getTimeout() < TransactionDefinition.TIMEOUT_DEFAULT) {
throw new InvalidTimeoutException("Invalid transaction timeout", definition.getTimeout());

// No existing transaction found -> check propagation behavior to find out how to proceed.
if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_MANDATORY) {
throw new IllegalTransactionStateException(
"No existing transaction found for transaction marked with propagation 'mandatory'");
Going from below block when its working fine

else if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRED ||
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRES_NEW ||
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) {
SuspendedResourcesHolder suspendedResources = suspend(null);
if (debugEnabled) {
logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);

I have a rest controller with class level request mapping and each method has individual request mapping. As i need to add few more methods, i have decided to have another controller (Class B). I still want to keep request mapping "/base" from old controller (Class A). Is there a better way to do this as i don't like appending  "base/" in each method in class B.

Class A {


Class B {


1 year ago
Hi all,

I want to know if one person has worked with two companies and now if he gets an offer from third company then the new company will call to both the companies for background checks or it will only call to the previous company?Pls help me as I am in real trouble.

I will be helpful if anyone has any idea about the following:
Is it mandatory for a software compamy to be registered somewhere.Means there can be a public record of a software company(any govt record)?

with ragards,
12 years ago