Help coderanch get a
new server
by contributing to the fundraiser

Patrio Jensen

+ Follow
since Feb 20, 2009
Merit badge: grant badges
For More
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 Patrio Jensen

Changing from ConcurrentSkipListSet to CopyOnWriteArraySet did the trick. Need to see why it's failing for ConcurrentSkipListSet.
14 years ago

I am trying to see why declaring static final variable is NOT enough for singleton pattern.

For that I have created following 3 classes:

Running this code results in following exception.
Exception in thread "Thread-620" java.lang.ClassCastException: SingletonCheck cannot be cast to java.lang.Comparable
at java.util.concurrent.ConcurrentSkipListMap.comparable(
at java.util.concurrent.ConcurrentSkipListMap.doPut(
at java.util.concurrent.ConcurrentSkipListMap.putIfAbsent(
at java.util.concurrent.ConcurrentSkipListSet.add(

Could someone help me in solving this error please?
Do I need to implement equals() method?

14 years ago
Got it now.

Thanks Lorand, Rob.
14 years ago
Thanks Rob for quick reply.

I tried printing value from Entry[] table of HashMap using reflection and can see that it's storing data.

And also I don't see any data structure (other than Entry[] ) inside HashMap to store key/value pair.
14 years ago

Inside java.util.HashMap class, I see a field transient Entry[] table which is used to store data(key/value pair in this case).

Can someone help me to understand why table is declared as transient?

I tried serializing the HashMap object as mentioned here and could successfully serialize and deserialize.

For that matter even HashTable.elementData, ArrayList.elementData are also declared transient.

14 years ago

That driver has to take all his personal stuff with him when he returns the car


but he can leave the steering wheel for the next driver.

This caused some confusion. I am under impression that SessionContext of one SFSB is of no use to another SFSB. Is it correct?
My mistake: I was getting UserTransaction using jndi lookup and not using EJBContext.getUserTransaction() call hence getting different values.

But now when I used getUserTransaction() method, I am getting error: Only instances of beans with bean-managed transaction demarcation can use getUserTransaction()

I realized that calling getUserTransaction() is not allowed for CMT beans as mentioned here

But still my question remains open.

I have created 2 SLSB say ParentBean and ChildBean. I am calling ChildBean from within ParentBean.

I am using CMT for both beans and have specified Required transaction attribute for both the beans.

My question is: How can I know whether container has created new transaction for the ChildBean or it's using that of ParentBean?

I tried printing hashcode for UserTransaction inside both beans but I am getting different values.

Thanks in advance.

"Mastering EJB" mentions that container retains container-implemented objects (e.g. EJBContext) across passivation/activation call. In other words, container does not passivate SessionContext object while passivating SFSB.

Is there any specific reason behind not passivating EJBContext?


I am new to JTA. I was going through JTA examples and I could see 2 ways to use JTA in my application client code for distributed transactions.

1. By getting UserTransaction from EJB container.

2. By retrieving XAResource.
I am not sure when to use which code.
Is it that in case of EJBs I need to use first approach and for rest I should use second one.