Sven Templin wrote:
> 
> Hello *,
> 
> I have the following problem:
> 
> System environment:
> - Server: JOnAS 2.2.7 on Win NT 4.0 WS, SUN JDK 1.3
> - Database: PostgreSQL on Linux
> - Client: Running on the same server over RMI
> 
> I have a simple entity bean TestCounter with a primary key and an attribute
> long count and one methode:
> 
> public long getNewCount() {
>    count++;
>    System.out.println("Counter " + new Long(count).toString())
>    return count;
> }
> 
> The entity beans should generate a unique counter, which can be used as
> object id.
> 
You must make sure that either:
- Your bean is marked as Rentrant=False in the deployment descriptor
- You have set transaction attribute=Required for that method.
But may be you will have to try with the last jonas version (in CVS) because
a bug has been fixed recently about transaction isolations.
> On the client is a TestThreadClass:
> 
> public class TestThread extends Thread{
> ...
>    public void run() {
> 
>     try {
>      javax.naming.InitialContext initialContext =
>                                  new javax.naming.InitialContext();
>      TestCounterPK counterPK = new TestCounterPK("1");
>      TestCounterHome counterHome = (TestCounterHome)
>                      javax.rmi.PortableRemoteObject.narrow(
>                      initialContext.lookup("TestCounterHome"),
>                      TestCounterHome.class);
>      TestCounter testCounter = counterHome.findByPrimaryKey(counterPK);
>      long j = 0;
>      for(int i= 0; i<400; i++){
>        j = testCounter.getNewCount();
>      }
>      System.out.println("Last Counter " + new Long(j).toString());
>     }
>     catch(Exception eEx) {
>       eEx.printStackTrace();
>     }
>    }
> ...
> }
> 
> On the client I'm starting four TestThreads:
> 
> ...
>    TestThread thread1 = new TestThread();
>    TestThread thread2 = new TestThread();
>    TestThread thread3 = new TestThread();
>    TestThread thread4 = new TestThread();
>    thread1.start();
>    thread2.start();
>    thread3.start();
>    thread4.start();
> ...
> 
> This simple programm should generate 1600 numbers, but the result is:
> 
>   Output on server:
>   ...
>   Counter 100
>   Counter 100
>   Counter 100
>   Counter 101
>   Counter 102
>   Counter 102
>   Counter 102
>   ...
> 
>   Output on client:
>   ...
>   Last Counter 823
>   Last Counter 825
>   Last Counter 827
>   Last Counter 828
>   ...
> 
> With different threads on the same entity bean are returning the same
> counter, but should returning unique, different counters.
> 
> Where is the problem? Using a transaction is not a solution, it brings the
> same result.
> 
> One (good?) information: Running same application on Borland Application
> Server 4.5 produces same result.
> 
> Thank's for a tip!
> 
> Sven
> 
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
> 
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".

-- 
Philippe Durieux  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bull - 1 rue de Provence - 38432 Echirolles Cedex France
[EMAIL PROTECTED]
-> Download our EJBServer at http://www.evidian.com/ejb <-
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to