RE: JBoss have to close connection in managed environment and nes ted EJB calls

2004-09-09 Thread Clute, Andrew
I don't know if this was every acknowledged on the list, my Jboss recognizes that they 
do it this way, and it is how they want to do it.

You can turn off the Connection checking.

http://www.jboss.org/wiki/Wiki.jsp?page=WhatDoesTheMessageDoYourOwnHousekeepingMean

See Thread Local Pattern

-Andrew

 

-Original Message-
From: André Markwalder [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 05, 2004 5:09 AM
To: OJB Users List
Subject: RE: JBoss have to close connection in managed environment and nes ted EJB 
calls

Hi Armin,

Thanks for spending hours of investigation.

I think it is absolutely correct, that OJB uses only one PersistenceBroker and as you 
described it seems that it is a problem of JBoss.

Again thanks a lot for your detailed description.

regards,
André



-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Samstag, 3. Juli 2004 17:45
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and nes ted EJB 
calls


Hi Andre,

after spending hours of investigation, I think I found the reason for the warning.

Seems JBoss doesn't recognize a connection.close() call when:
- bean 1 create a PB instance and do some work
- in bean 1 another bean (bean 2) was used
- bean 2 create a PB instance. Internal OJB use the same PB instance, thus both use 
the same internal PB instance wrapped by different handle. 
The use PB was already associated with a connection in bean 1, thus bean
2 use the same connection handle.
- now bean 2 close the used PB handle, internal the PB instance only release/close the 
used connection
- now bean 1 perform additional work, thus the PB instance create a new connection 
(because bean 2 close it) and close it after use (PB close call in bean 1)
- bean 1 method ends and the container commit the transaction

Now the problem occur, because JBoss does not recognize that the first connection 
created in bean 1 was closed in bean 2 and log a warning about unclosed connection.

If you comment out line 110 in PersistenceBrokerFactorySyncImpl or use version 1.5 of 
PersistenceBrokerFactorySyncImpl the warning does not occur.

In version 1.6 I introduce that different beans in the same tx use internal the same 
PB instance (think this is similar to DataSource
handling) to avoid massive PB instance creation for bean in bean calls.

See
http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]m
sgId=1693533

The question now is are OJB wrong in handling connections or should JBoss allow this? 
I'm don't know the answer.


**
Here is my test:

Have a look how OJB handles connection '[EMAIL PROTECTED]'
(the bean source code can be found below)

--- test start an lookup first PB in first bean
...
16:53:17,625 INFO  [CacheDistributor] Create new 
ObjectCacheImplementation for 'default'
16:53:17,625 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,625 INFO  [STDOUT] ## broker1: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter.
[EMAIL PROTECTED]

--- query in first bean, connection was created, now we call the nested 
bean

16:53:17,625 INFO  [STDOUT] ### DO nested bean call
16:53:17,625 INFO  [PersonArticleManagerPBBean] ** Found bean: 
org.apache.ojb.ejb.pb.ArticleManagerPBBeanLocal:Stateless
16:53:17,640 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,640 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
...

16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,656 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 ERROR [STDERR]  release connection: 
[EMAIL PROTECTED] 
connection=org.jboss.resource
[EMAIL PROTECTED] thread: Thread[RMI TCP 
Connection(2)-217.224.94.148,5,RMI Runtime]
16:53:17,671 INFO  [STDOUT]  close con: 
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  is closed: true
16:53:17,671 INFO  [STDOUT] ### END nested bean call

--- nested bean call is finished and '[EMAIL PROTECTED]' is 
closed!! But the second bean close the connection created by the first bean.
bean1 now start to insert objects and create a new connection, because 
the first one was closed by the nested bean


16:53:17,671 INFO  [STDOUT] ## broker1: now store objects
16:53:17,671 INFO  [STDOUT]  create con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 

RE: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-05 Thread André Markwalder
Hi Armin,

Thanks for spending hours of investigation.

I think it is absolutely correct, that OJB uses only 
one PersistenceBroker and as you described it seems 
that it is a problem of JBoss.

Again thanks a lot for your detailed description.

regards,
André



-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Samstag, 3. Juli 2004 17:45
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nes ted EJB calls


Hi Andre,

after spending hours of investigation, I think I found the reason for 
the warning.

Seems JBoss doesn't recognize a connection.close() call when:
- bean 1 create a PB instance and do some work
- in bean 1 another bean (bean 2) was used
- bean 2 create a PB instance. Internal OJB use the same PB instance, 
thus both use the same internal PB instance wrapped by different handle. 
The use PB was already associated with a connection in bean 1, thus bean 
2 use the same connection handle.
- now bean 2 close the used PB handle, internal the PB instance only 
release/close the used connection
- now bean 1 perform additional work, thus the PB instance create a new 
connection (because bean 2 close it) and close it after use (PB close 
call in bean 1)
- bean 1 method ends and the container commit the transaction

Now the problem occur, because JBoss does not recognize that the first 
connection created in bean 1 was closed in bean 2 and log a warning 
about unclosed connection.

If you comment out line 110 in PersistenceBrokerFactorySyncImpl or use 
version 1.5 of PersistenceBrokerFactorySyncImpl the warning does not occur.

In version 1.6 I introduce that different beans in the same tx use 
internal the same PB instance (think this is similar to DataSource 
handling) to avoid massive PB instance creation for bean in bean calls.

See
http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]m
sgId=1693533

The question now is are OJB wrong in handling connections or should 
JBoss allow this? I'm don't know the answer.


**
Here is my test:

Have a look how OJB handles connection '[EMAIL PROTECTED]'
(the bean source code can be found below)

--- test start an lookup first PB in first bean
...
16:53:17,625 INFO  [CacheDistributor] Create new 
ObjectCacheImplementation for 'default'
16:53:17,625 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,625 INFO  [STDOUT] ## broker1: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter.
[EMAIL PROTECTED]

--- query in first bean, connection was created, now we call the nested 
bean

16:53:17,625 INFO  [STDOUT] ### DO nested bean call
16:53:17,625 INFO  [PersonArticleManagerPBBean] ** Found bean: 
org.apache.ojb.ejb.pb.ArticleManagerPBBeanLocal:Stateless
16:53:17,640 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,640 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
...

16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,656 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 ERROR [STDERR]  release connection: 
[EMAIL PROTECTED] 
connection=org.jboss.resource
[EMAIL PROTECTED] thread: Thread[RMI TCP 
Connection(2)-217.224.94.148,5,RMI Runtime]
16:53:17,671 INFO  [STDOUT]  close con: 
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  is closed: true
16:53:17,671 INFO  [STDOUT] ### END nested bean call

--- nested bean call is finished and '[EMAIL PROTECTED]' is 
closed!! But the second bean close the connection created by the first bean.
bean1 now start to insert objects and create a new connection, because 
the first one was closed by the nested bean


16:53:17,671 INFO  [STDOUT] ## broker1: now store objects
16:53:17,671 INFO  [STDOUT]  create con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
...

16:53:18,015 INFO  [STDOUT] ## broker1: end store, 
[EMAIL PROTECTED] 
connection=org.jboss.resour
[EMAIL PROTECTED]
16:53:18,031 INFO  [STDOUT] ## close broker1 now
16:53:18,031 ERROR [STDERR]  release connection: 
[EMAIL PROTECTED] 
connection=org.jboss.resource
[EMAIL PROTECTED] thread: Thread[RMI TCP 
Connection(2)-217.224.94.148,5,RMI Runtime]
16:53:18,046 INFO  [STDOUT]  close con: 
[EMAIL PROTECTED]
16:53:18,046 INFO  [STDOUT]  is closed: true

--- first bean close 

Re: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-03 Thread Armin Waibel
Hi Andre,
after spending hours of investigation, I think I found the reason for 
the warning.

Seems JBoss doesn't recognize a connection.close() call when:
- bean 1 create a PB instance and do some work
- in bean 1 another bean (bean 2) was used
- bean 2 create a PB instance. Internal OJB use the same PB instance, 
thus both use the same internal PB instance wrapped by different handle. 
The use PB was already associated with a connection in bean 1, thus bean 
2 use the same connection handle.
- now bean 2 close the used PB handle, internal the PB instance only 
release/close the used connection
- now bean 1 perform additional work, thus the PB instance create a new 
connection (because bean 2 close it) and close it after use (PB close 
call in bean 1)
- bean 1 method ends and the container commit the transaction

Now the problem occur, because JBoss does not recognize that the first 
connection created in bean 1 was closed in bean 2 and log a warning 
about unclosed connection.

If you comment out line 110 in PersistenceBrokerFactorySyncImpl or use 
version 1.5 of PersistenceBrokerFactorySyncImpl the warning does not occur.

In version 1.6 I introduce that different beans in the same tx use 
internal the same PB instance (think this is similar to DataSource 
handling) to avoid massive PB instance creation for bean in bean calls.

See
http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]msgId=1693533
The question now is are OJB wrong in handling connections or should 
JBoss allow this? I'm don't know the answer.

**
Here is my test:
Have a look how OJB handles connection '[EMAIL PROTECTED]'
(the bean source code can be found below)
--- test start an lookup first PB in first bean
...
16:53:17,625 INFO  [CacheDistributor] Create new 
ObjectCacheImplementation for 'default'
16:53:17,625 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,625 INFO  [STDOUT] ## broker1: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter.
[EMAIL PROTECTED]

--- query in first bean, connection was created, now we call the nested 
bean

16:53:17,625 INFO  [STDOUT] ### DO nested bean call
16:53:17,625 INFO  [PersonArticleManagerPBBean] ** Found bean: 
org.apache.ojb.ejb.pb.ArticleManagerPBBeanLocal:Stateless
16:53:17,640 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,640 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
...

16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,656 INFO  [PersistenceBrokerImpl] Cascade store for this 
reference-descriptor (category) was set to false.
16:53:17,656 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 ERROR [STDERR]  release connection: 
[EMAIL PROTECTED] 
connection=org.jboss.resource
[EMAIL PROTECTED] thread: Thread[RMI TCP 
Connection(2)-217.224.94.148,5,RMI Runtime]
16:53:17,671 INFO  [STDOUT]  close con: 
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  is closed: true
16:53:17,671 INFO  [STDOUT] ### END nested bean call

--- nested bean call is finished and '[EMAIL PROTECTED]' is 
closed!! But the second bean close the connection created by the first bean.
bean1 now start to insert objects and create a new connection, because 
the first one was closed by the nested bean

16:53:17,671 INFO  [STDOUT] ## broker1: now store objects
16:53:17,671 INFO  [STDOUT]  create con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
16:53:17,671 INFO  [STDOUT]  lookup con: 
[EMAIL PROTECTED] 
connection=org.jboss.resource.adapter
[EMAIL PROTECTED]: false
...

16:53:18,015 INFO  [STDOUT] ## broker1: end store, 
[EMAIL PROTECTED] 
connection=org.jboss.resour
[EMAIL PROTECTED]
16:53:18,031 INFO  [STDOUT] ## close broker1 now
16:53:18,031 ERROR [STDERR]  release connection: 
[EMAIL PROTECTED] 
connection=org.jboss.resource
[EMAIL PROTECTED] thread: Thread[RMI TCP 
Connection(2)-217.224.94.148,5,RMI Runtime]
16:53:18,046 INFO  [STDOUT]  close con: 
[EMAIL PROTECTED]
16:53:18,046 INFO  [STDOUT]  is closed: true

--- first bean close the second used connection
16:53:18,062 INFO  [CachedConnectionManager] Closing a connection for 
you.  Please close them yourself: 
org.jboss.resource.adapter.jdbc.WrappedConnect
[EMAIL PROTECTED]

--- !!! This connection was closed by the nested bean!!!
java.lang.Exception: STACKTRACE
at 
org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:282)
at 

RE: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-02 Thread André Markwalder
Hi Armin,

Yes I did.

regards,
André

-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 14:25
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nested EJB calls


Hi Andre,

do you set
PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFa
ctorySyncImpl
in OJB.properties?

regards,
Armin

André Markwalder wrote:

 Hi,
 
 I've got the following problem with OJB and JBoss in a managed
environment. 
 
 I do an EJB call to ejbA. Within that EJB I request a PersistenceBroker.
 After 
 that request I call a second EJB. Let's call it ejbB. Within ejbB I
request 
 the same PersistenceBroker. After processing ejbB I release (close) the 
 PersistenceBroker. In ejbA I release (close) also the  PersistenceBroker.
 
 The problem is that JBoss informs me, that it has to close a connection
for 
 me and I should do it myself.
 
 If I close the PersistenceBroker before I call ejbB and reobtain the 
 PersistenceBroker afterwards everything works fine.
 
 It seems if I do a nested EJB call (nested retrieval of
PersistenceBroker),
 OJB 
 doesn't close all the connections.
 
 Did I something wrong or did I have misconfigured something within JBoss
or
 OJB?
 
 I configured OJB as described in the documentation (deployment section).
 
 Below you will find the sample source code, JBoss log and OJB.properties
 file.
 
 I use JBoss 3.2.2 (tried also with 3.2.5 same effects) and OJB 1.0.0.
 
 
 
 Thanks in advance for any help.
 
 André
 
 
 
 
 Sample source code from EJB:
 
   /**
* @ejb.interface-method 
* @ejb.permission  role-name=admin,user
   **/
   public void test1() {
 
   System.out.println(GETBROKER 1);
   PersistenceBroker broker =
 PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();
 
   try {
   System.out.println(TEST1);
 
   InitialContext ctx = new InitialContext();
   AesUserLocalHome home =
 (AesUserLocalHome)ctx.lookup(AesUserLocalHome.JNDI_NAME);
   AesUserLocal tmp = home.create();
   tmp.test2();
 
   } catch (NamingException e) {
   e.printStackTrace();
   } catch (CreateException e) {
   e.printStackTrace();
   }
   finally {
   System.out.println(BROKER CLOSED 1);
   if (broker != null) {
   broker.close();
   }
   }
   }
 
   /**
* @ejb.interface-method 
* @ejb.permission  role-name=admin,user
   **/
   public void test2() {
   System.out.println(GETBROKER 2);
   PersistenceBroker broker =
 PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();
 
   try {
   System.out.println(TEST2);
   }
   finally {
   System.out.println(BROKER CLOSED 2);
   if (broker != null) {
   broker.close();
   }
   }
   }
 
 
 
 
 JBOSS log:
 
 13:58:16,232 DEBUG [PersistenceBrokerFactoryDefaultImpl] PersistenceBroker
 pool will be setup with the following configuration
 org.apache.commons.pool.impl.Gene
 [EMAIL PROTECTED]
   maxIdle=-1
   maxActive=100
   maxTotal=-1
   maxWait=2000
   whenExhaustedAction=0
   testOnBorrow=false
   testOnReturn=false
   testWhileIdle=false
   timeBetweenEvictionRunsMillis=-1
   numTestsPerEvictionRun=10
   minEvictableIdleTimeMillis=100
 ]
 13:58:16,242 INFO  [PersistenceBrokerFactoryDefaultImpl] Create
 PersistenceBroker instance pool, pool configuration was
 {whenExhaustedAction=0, maxIdle=-1, maxA
 ctive=100, maxWait=2000, removeAbandoned=false, numTestsPerEvictionRun=10,
 testWhileIdle=false, minEvictableIdleTimeMillis=100,
testOnReturn=false,
 logAband
 oned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1,
 testOnBorrow=false}
 
 
 
 13:58:16,262 INFO  [STDOUT] GETBROKER 1
 13:58:17,114 DEBUG [PersistenceBrokerFactoryDefaultImpl] Obtain broker
from
 pool, used PBKey is org.apache.ojb.broker.PBKey: jcdAlias=APPSERVER_AES,
 user=null,password=null
 13:58:17,235 INFO  [STDOUT] TEST1
 13:58:17,235 INFO  [STDOUT] GETBROKER 2
 13:58:17,235 INFO  [STDOUT] TEST2
 13:58:17,235 INFO  [STDOUT] BROKER CLOSED 2
 13:58:17,235 DEBUG
 [PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl] PB close was
 called, only close the PB handle when in JTA-tx
 13:58:17,235 INFO  [STDOUT] BROKER CLOSED 1
 13:58:17,235 DEBUG
 [PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl] PB close was
 called, only close the PB handle when in JTA-tx
 13:58:17,235 DEBUG
 [PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl]
 beforeCompletion was called, nothing to do
 

Re: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-02 Thread Armin Waibel
doh! Sorry I don't read your first post till end.
Seems we don't have a test case for your scenario. There is a session 
bean using two beans in another bean (PersonArticleManagerPBBean), but 
they never made nested PB calls.
It is not allowed to use nested PB instances in OJB standalone mode, so 
I'm not sure about handling in managed environments. Is it possible to 
use nested connections in beans? E.g. instead create a PB instance, use 
a JNDI connection, do some work, obtain another bean, call bean method, 
close obtained JNDI connection. Is this allowed?

regards,
Armin
André Markwalder wrote:
Hi Armin,
Yes I did.
regards,
André
-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 14:25
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nested EJB calls
Hi Andre,
do you set
PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFa
ctorySyncImpl
in OJB.properties?
regards,
Armin
André Markwalder wrote:

Hi,
I've got the following problem with OJB and JBoss in a managed
environment. 

I do an EJB call to ejbA. Within that EJB I request a PersistenceBroker.
After 
that request I call a second EJB. Let's call it ejbB. Within ejbB I
request 

the same PersistenceBroker. After processing ejbB I release (close) the 
PersistenceBroker. In ejbA I release (close) also the  PersistenceBroker.

The problem is that JBoss informs me, that it has to close a connection
for 

me and I should do it myself.
If I close the PersistenceBroker before I call ejbB and reobtain the 
PersistenceBroker afterwards everything works fine.

It seems if I do a nested EJB call (nested retrieval of
PersistenceBroker),
OJB 
doesn't close all the connections.

Did I something wrong or did I have misconfigured something within JBoss
or
OJB?
I configured OJB as described in the documentation (deployment section).
Below you will find the sample source code, JBoss log and OJB.properties
file.
I use JBoss 3.2.2 (tried also with 3.2.5 same effects) and OJB 1.0.0.

Thanks in advance for any help.
André

Sample source code from EJB:
	/**
	 * @ejb.interface-method 
	 * @ejb.permission  role-name=admin,user
	**/
	public void test1() {

System.out.println(GETBROKER 1);
PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();
try {
System.out.println(TEST1);
InitialContext ctx = new InitialContext();
AesUserLocalHome home =
(AesUserLocalHome)ctx.lookup(AesUserLocalHome.JNDI_NAME);
AesUserLocal tmp = home.create();
tmp.test2();
} catch (NamingException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
}
finally {
System.out.println(BROKER CLOSED 1);
if (broker != null) {
broker.close();
}
}
}
	/**
	 * @ejb.interface-method 
	 * @ejb.permission  role-name=admin,user
	**/
	public void test2() {
		System.out.println(GETBROKER 2);
		PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();

try {
System.out.println(TEST2);
}
finally {
System.out.println(BROKER CLOSED 2);
if (broker != null) {
broker.close();
}
}
}

JBOSS log:
13:58:16,232 DEBUG [PersistenceBrokerFactoryDefaultImpl] PersistenceBroker
pool will be setup with the following configuration
org.apache.commons.pool.impl.Gene
[EMAIL PROTECTED]
 maxIdle=-1
 maxActive=100
 maxTotal=-1
 maxWait=2000
 whenExhaustedAction=0
 testOnBorrow=false
 testOnReturn=false
 testWhileIdle=false
 timeBetweenEvictionRunsMillis=-1
 numTestsPerEvictionRun=10
 minEvictableIdleTimeMillis=100
]
13:58:16,242 INFO  [PersistenceBrokerFactoryDefaultImpl] Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxA
ctive=100, maxWait=2000, removeAbandoned=false, numTestsPerEvictionRun=10,
testWhileIdle=false, minEvictableIdleTimeMillis=100,
testOnReturn=false,
logAband
oned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1,
testOnBorrow=false}

13:58:16,262 INFO  [STDOUT] GETBROKER 1
13:58:17,114 DEBUG [PersistenceBrokerFactoryDefaultImpl] Obtain broker
from
pool, used PBKey is org.apache.ojb.broker.PBKey: jcdAlias=APPSERVER_AES,
user=null,password=null
13:58:17,235 INFO  [STDOUT] TEST1
13:58:17,235 INFO  [STDOUT] GETBROKER 2
13:58:17,235 INFO  [STDOUT] TEST2
13:58:17,235 INFO  [STDOUT] BROKER CLOSED 2
13:58:17,235 DEBUG

Re: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-02 Thread Guido Beutler
Hi,
I had the same problem with jboss 3.2.2 and different OJB versions.
The problem was solved at jboss 3.2.3. Armin may remember or long mail
threads. :-)
I haven't updated to 3.2.5 yet but for me it sounds as if the same problem
occurs there again. Could you make a quick check with 3.2.3 ?
best regards,
Guido
André Markwalder wrote:
Hi Armin,
Yes I did.
regards,
André
-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 14:25
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nested EJB calls
Hi Andre,
do you set
PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFa
ctorySyncImpl
in OJB.properties?
regards,
Armin
André Markwalder wrote:
 

Hi,
I've got the following problem with OJB and JBoss in a managed
   

environment. 
 

I do an EJB call to ejbA. Within that EJB I request a PersistenceBroker.
After 
that request I call a second EJB. Let's call it ejbB. Within ejbB I
   

request 
 

the same PersistenceBroker. After processing ejbB I release (close) the 
PersistenceBroker. In ejbA I release (close) also the  PersistenceBroker.

The problem is that JBoss informs me, that it has to close a connection
   

for 
 

me and I should do it myself.
If I close the PersistenceBroker before I call ejbB and reobtain the 
PersistenceBroker afterwards everything works fine.

It seems if I do a nested EJB call (nested retrieval of
   

PersistenceBroker),
 

OJB 
doesn't close all the connections.

Did I something wrong or did I have misconfigured something within JBoss
   

or
 

OJB?
I configured OJB as described in the documentation (deployment section).
Below you will find the sample source code, JBoss log and OJB.properties
file.
I use JBoss 3.2.2 (tried also with 3.2.5 same effects) and OJB 1.0.0.

Thanks in advance for any help.
André

Sample source code from EJB:
	/**
	 * @ejb.interface-method 
	 * @ejb.permission  role-name=admin,user
	**/
	public void test1() {

System.out.println(GETBROKER 1);
PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();
try {
System.out.println(TEST1);
InitialContext ctx = new InitialContext();
AesUserLocalHome home =
(AesUserLocalHome)ctx.lookup(AesUserLocalHome.JNDI_NAME);
AesUserLocal tmp = home.create();
tmp.test2();
} catch (NamingException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
}
finally {
System.out.println(BROKER CLOSED 1);
if (broker != null) {
broker.close();
}
}
}
	/**
	 * @ejb.interface-method 
	 * @ejb.permission  role-name=admin,user
	**/
	public void test2() {
		System.out.println(GETBROKER 2);
		PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();

try {
System.out.println(TEST2);
}
finally {
System.out.println(BROKER CLOSED 2);
if (broker != null) {
broker.close();
}
}
}

JBOSS log:
13:58:16,232 DEBUG [PersistenceBrokerFactoryDefaultImpl] PersistenceBroker
pool will be setup with the following configuration
org.apache.commons.pool.impl.Gene
[EMAIL PROTECTED]
 maxIdle=-1
 maxActive=100
 maxTotal=-1
 maxWait=2000
 whenExhaustedAction=0
 testOnBorrow=false
 testOnReturn=false
 testWhileIdle=false
 timeBetweenEvictionRunsMillis=-1
 numTestsPerEvictionRun=10
 minEvictableIdleTimeMillis=100
]
13:58:16,242 INFO  [PersistenceBrokerFactoryDefaultImpl] Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxA
ctive=100, maxWait=2000, removeAbandoned=false, numTestsPerEvictionRun=10,
testWhileIdle=false, minEvictableIdleTimeMillis=100,
   

testOnReturn=false,
 

logAband
oned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1,
testOnBorrow=false}

13:58:16,262 INFO  [STDOUT] GETBROKER 1
13:58:17,114 DEBUG [PersistenceBrokerFactoryDefaultImpl] Obtain broker
   

from
 

pool, used PBKey is org.apache.ojb.broker.PBKey: jcdAlias=APPSERVER_AES,
user=null,password=null
13:58:17,235 INFO  [STDOUT] TEST1
13:58:17,235 INFO  [STDOUT] GETBROKER 2
13:58:17,235 INFO  [STDOUT] TEST2
13:58:17,235 INFO  [STDOUT] BROKER CLOSED 2
13:58:17,235 DEBUG
[PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl] PB close was
called, only close the PB handle when in JTA-tx
13:58:17,235 INFO  [STDOUT] BROKER CLOSED 1
13:58:17,235 DEBUG

RE: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-02 Thread André Markwalder
Hi Guido

Same effects on JBoss 3.2.3. JBoss closes the open connection.

regards
André

-Original Message-
From: Guido Beutler [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 15:08
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nes ted EJB calls


Hi,

I had the same problem with jboss 3.2.2 and different OJB versions.
The problem was solved at jboss 3.2.3. Armin may remember or long mail
threads. :-)
I haven't updated to 3.2.5 yet but for me it sounds as if the same problem
occurs there again. Could you make a quick check with 3.2.3 ?

best regards,

Guido

André Markwalder wrote:

Hi Armin,

Yes I did.

regards,
André

-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 14:25
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nested EJB calls


Hi Andre,

do you set
PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerF
a
ctorySyncImpl
in OJB.properties?

regards,
Armin

André Markwalder wrote:

  

Hi,

I've got the following problem with OJB and JBoss in a managed


environment. 
  

I do an EJB call to ejbA. Within that EJB I request a PersistenceBroker.
After 
that request I call a second EJB. Let's call it ejbB. Within ejbB I


request 
  

the same PersistenceBroker. After processing ejbB I release (close) the 
PersistenceBroker. In ejbA I release (close) also the  PersistenceBroker.

The problem is that JBoss informs me, that it has to close a connection


for 
  

me and I should do it myself.

If I close the PersistenceBroker before I call ejbB and reobtain the 
PersistenceBroker afterwards everything works fine.

It seems if I do a nested EJB call (nested retrieval of


PersistenceBroker),
  

OJB 
doesn't close all the connections.

Did I something wrong or did I have misconfigured something within JBoss


or
  

OJB?

I configured OJB as described in the documentation (deployment section).

Below you will find the sample source code, JBoss log and OJB.properties
file.

I use JBoss 3.2.2 (tried also with 3.2.5 same effects) and OJB 1.0.0.



Thanks in advance for any help.

André




Sample source code from EJB:

  /**
   * @ejb.interface-method 
   * @ejb.permission  role-name=admin,user
  **/
  public void test1() {

  System.out.println(GETBROKER 1);
  PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();

  try {
  System.out.println(TEST1);

  InitialContext ctx = new InitialContext();
  AesUserLocalHome home =
(AesUserLocalHome)ctx.lookup(AesUserLocalHome.JNDI_NAME);
  AesUserLocal tmp = home.create();
  tmp.test2();

  } catch (NamingException e) {
  e.printStackTrace();
  } catch (CreateException e) {
  e.printStackTrace();
  }
  finally {
  System.out.println(BROKER CLOSED 1);
  if (broker != null) {
  broker.close();
  }
  }
  }

  /**
   * @ejb.interface-method 
   * @ejb.permission  role-name=admin,user
  **/
  public void test2() {
  System.out.println(GETBROKER 2);
  PersistenceBroker broker =
PersistenceBrokerFactoryFactory.instance().defaultPersistenceBroker();

  try {
  System.out.println(TEST2);
  }
  finally {
  System.out.println(BROKER CLOSED 2);
  if (broker != null) {
  broker.close();
  }
  }
  }




JBOSS log:

13:58:16,232 DEBUG [PersistenceBrokerFactoryDefaultImpl] PersistenceBroker
pool will be setup with the following configuration
org.apache.commons.pool.impl.Gene
[EMAIL PROTECTED]
  maxIdle=-1
  maxActive=100
  maxTotal=-1
  maxWait=2000
  whenExhaustedAction=0
  testOnBorrow=false
  testOnReturn=false
  testWhileIdle=false
  timeBetweenEvictionRunsMillis=-1
  numTestsPerEvictionRun=10
  minEvictableIdleTimeMillis=100
]
13:58:16,242 INFO  [PersistenceBrokerFactoryDefaultImpl] Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxA
ctive=100, maxWait=2000, removeAbandoned=false, numTestsPerEvictionRun=10,
testWhileIdle=false, minEvictableIdleTimeMillis=100,


testOnReturn=false,
  

logAband
oned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1,
testOnBorrow=false}



13:58:16,262 INFO  [STDOUT] GETBROKER 1
13:58:17,114 DEBUG [PersistenceBrokerFactoryDefaultImpl] Obtain broker


from
  

pool, used PBKey is org.apache.ojb.broker.PBKey: jcdAlias=APPSERVER_AES,
user=null,password=null
13:58:17,235 INFO  [STDOUT] 

RE: JBoss have to close connection in managed environment and nes ted EJB calls

2004-07-02 Thread André Markwalder
Hi Armin

I tried the JNDI lookup with the following code and it worked perfectly. 
JBoss didn't complained about anything.


regards
André


/**
 * @ejb.interface-method 
 * @ejb.permission  role-name=admin,user
**/
public void test1() {
Connection conn = null;
try {

InitialContext ctx = new InitialContext();
DataSource ds =
(DataSource)ctx.lookup(java:comp/env/jdbc/AESDS_MAXDB_SALUSA_AES);
conn = ds.getConnection();

ResultSet rs =
conn.createStatement().executeQuery(SELECT COUNT(*) FROM AES_USER);
rs.first();
System.out.println(TEST1:  + rs.getInt(1));

AesUserLocalHome home =
(AesUserLocalHome)ctx.lookup(AesUserLocalHome.JNDI_NAME);
AesUserLocal tmp = home.create();
tmp.test2();

} catch (NamingException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
finally {
try {
if (conn != null) {
System.out.println(CLOSE CONNECTION
1);
conn.close();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}

/**
 * @ejb.interface-method 
 * @ejb.permission  role-name=admin,user
**/
public void test2() {
Connection conn = null;
try {

InitialContext ctx = new InitialContext();
DataSource ds =
(DataSource)ctx.lookup(java:comp/env/jdbc/AESDS_MAXDB_SALUSA_AES);
conn = ds.getConnection();

ResultSet rs =
conn.createStatement().executeQuery(SELECT COUNT(*) FROM AES_USER);
rs.first();
System.out.println(TEST2:  + rs.getInt(1));

} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
finally {
try {
if (conn != null) {
System.out.println(CLOSE CONNECTION
2);
conn.close();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}




-Original Message-
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Freitag, 2. Juli 2004 15:03
To: OJB Users List
Subject: Re: JBoss have to close connection in managed environment and
nes ted EJB calls


doh! Sorry I don't read your first post till end.
Seems we don't have a test case for your scenario. There is a session 
bean using two beans in another bean (PersonArticleManagerPBBean), but 
they never made nested PB calls.
It is not allowed to use nested PB instances in OJB standalone mode, so 
I'm not sure about handling in managed environments. Is it possible to 
use nested connections in beans? E.g. instead create a PB instance, use 
a JNDI connection, do some work, obtain another bean, call bean method, 
close obtained JNDI connection. Is this allowed?

regards,
Armin

André Markwalder wrote:

 Hi Armin,
 
 Yes I did.
 
 regards,
 André
 
 -Original Message-
 From: Armin Waibel [mailto:[EMAIL PROTECTED]
 Sent: Freitag, 2. Juli 2004 14:25
 To: OJB Users List
 Subject: Re: JBoss have to close connection in managed environment and
 nested EJB calls
 
 
 Hi Andre,
 
 do you set

PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFa
 ctorySyncImpl
 in OJB.properties?
 
 regards,
 Armin
 
 André Markwalder wrote:
 
 
Hi,

I've got the following problem with OJB and JBoss in a managed
 
 environment. 
 
I do an EJB call to ejbA. Within that EJB I request a PersistenceBroker.
After 
that request I call a second EJB. Let's call it ejbB. Within ejbB I
 
 request 
 
the same PersistenceBroker. After processing ejbB I release (close) the 
PersistenceBroker. In ejbA I release (close) also the  PersistenceBroker.

The problem is that JBoss informs me, that it has to close a connection
 
 for 
 
me and I should do it myself.

If I close the PersistenceBroker before I call ejbB and reobtain the 
PersistenceBroker afterwards everything works fine.

It seems if I do a nested EJB call (nested retrieval of