Help coderanch get a
new server
by contributing to the fundraiser

Patrio Jensen

Greenhorn
+ Follow
since Feb 20, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
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
Hi,

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(ConcurrentSkipListMap.java:621)
at java.util.concurrent.ConcurrentSkipListMap.doPut(ConcurrentSkipListMap.java:862)
at java.util.concurrent.ConcurrentSkipListMap.putIfAbsent(ConcurrentSkipListMap.java:1893)
at java.util.concurrent.ConcurrentSkipListSet.add(ConcurrentSkipListSet.java:202)
at test3.ThreadRunner.run(ThreadRunner.java:15)
at java.lang.Thread.run(Thread.java:619)


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

Regards,
Patrio
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
Hi,

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.

Thanks.
14 years ago

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


Understood.

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.
Hi,

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?

Thanks.
Hi,

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.
and

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.

Thanks.