This content has been marked as final.
Show 6 replies
-
2. Re: Problem of accessing Oracle DS in JBOSS from a stand-alo
scottlong Apr 10, 2007 10:09 AM (in response to guha_gourab)There are a few entries on the wiki that describe accessing JBoss datasource remotely via JNDI from external JVMs. They all describe this capability, experimental, not recommended, etc.
e.g. this one: http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanIAccessADataSourceFromAClient says:Note: Exposing a Datasource remotely is NOT recommended.
and this one: http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources says:JBoss does not recommend using this feature on a production environment.
The one specific risk listed is that if the client dies (or fails to close connections), it will cause a connection leak. JBoss is not going to try and detect the client's death and proactively clean up for the client.
This makes sense, but are there other risks of using this remote datasource capability?
I am talking in terms of JBoss 4.0.5.
thanks!
- scott -
3. Re: Problem of accessing Oracle DS in JBOSS from a stand-alo
adrian.brock Apr 11, 2007 7:37 AM (in response to guha_gourab)"scottlong" wrote:
This makes sense, but are there other risks of using this remote datasource capability?
Some risks, but mostly just anti-patterns (even if you ignore the crappy implementation
in JBoss4 - e.g. no leasing of connections so faulty clients can leak connections)
* Security - this is essentially a JDBC tunnel (remote client --> . --> database)
* DOS - Client gets a connection and never returns it (deliberately) eventually leading to
connection pool exhaustion
* Inefficiency - using a pooled connection remotely is not efficient, co-locate the business logic with the pool (or establish the pool on the remote client)
* No transaction enlistment - the remote connection does not take part in any transaction context established on the client - even a UserTransaction
* etc. -
4. Re: Problem of accessing Oracle DS in JBOSS from a stand-alo
scottlong Apr 11, 2007 10:37 AM (in response to guha_gourab)Thanks very much Adrian.
If i might ask one more question... regarding:the remote connection does not take part in any transaction context established on the client
... does this mean that even direct calls to Connection.commit() and Connection.rollback(), or possibly Connection.setAutoCommit() might not be propagated to the "real" JDBC connection held in JBoss? Or is the transaction context that the client cannot take part in limited to true "JTA" type transactions, UserTransaction, etc.? -
5. Re: Problem of accessing Oracle DS in JBOSS from a stand-alo
adrian.brock Apr 11, 2007 12:42 PM (in response to guha_gourab)"scottlong" wrote:
Thanks very much Adrian.
If i might ask one more question... regarding:the remote connection does not take part in any transaction context established on the client
... does this mean that even direct calls to Connection.commit() and Connection.rollback(), or possibly Connection.setAutoCommit() might not be propagated to the "real" JDBC connection held in JBoss? Or is the transaction context that the client cannot take part in limited to true "JTA" type transactions, UserTransaction, etc.?
Those work. That's a JDBC local transaction, not an "implicit"/contextual JTA transaction like the UserTransaction. -
6. Re: Problem of accessing Oracle DS in JBOSS from a stand-alo
weston.price Apr 18, 2007 8:56 AM (in response to guha_gourab)One more 'anti-pattern', actually, it's a bug IMO. When using the Remote data source code like the following can lead to a leak pretty quickly:
try { Connection conn = DataSource.getConnection() PreparedStatement ps = conn.prepareCall("SomeSQL"); ps.close(); }catch(Exception e) { } finally { if(ps != null) ps.close(); if(conn != null) conn.close(); }
What ends up happening in this particular instance is that the first ps.close() actually removes the Statement from the internal map on the server side. At the second close attempt a SQLException is thrown (who knows why). As a result, the connection itself would never get closed in this case. This actually crept up on the TCK for Oracle10g and was causing all sorts of issues.
Yes, I know that to be 'truly' safe both the ps.close() and the conn.close() should be contained within their own try/catch/finally block but this is never a guarantee.