[
https://issues.apache.org/jira/browse/GERONIMO-5904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13063763#comment-13063763
]
Ivan commented on GERONIMO-5904:
--------------------------------
Hi, David, here is some background info for this issue. Geronimo maintains a
jndi tree of namepsace ger, and a listener for gbeans implement ResourceSource
is added. So, once a gbean of this type is started, its value from invoking
$getResource() is bind on the tree. With this tree, users could bind some other
instances on the jndi tree, and use the jndi lookup to get value from their
applications. I know that we have a URLResourceSource sample, which could be
used to bind a URL on the tree.
Move to this jira, once a data source is created, a
GenericConnectionManagerGBean is created, and the return value of
$getResource() will be bind on the jndi tree. The problems is that the return
value is a tranql datasource instance, it implements the Referenceable
interface, so while binding it on our jndi tree, its reference value will be
used as the real value on the tree. The question is, while looking up this
value from the tree, no ObjectFactory could be found by aries jndi
implementation, then bang !
The workaround solution for this is that, a ResourceReference instance is used
to bind on the jndi tree, not the actual instance. With this, the lookup
function could work as usual.
Is it clear for you ? I would go ahead to commit this patch, as some other
JIRAs are depending on this. we could turn to other better solutions if
possible.
> Reference bound in JNDI is not dereferenced properly when lookup
> ----------------------------------------------------------------
>
> Key: GERONIMO-5904
> URL: https://issues.apache.org/jira/browse/GERONIMO-5904
> Project: Geronimo
> Issue Type: Bug
> Security Level: public(Regular issues)
> Components: naming
> Affects Versions: 3.0
> Reporter: Shenghao Fang
> Assignee: Ivan
> Attachments: GERONIMO-5904.patch
>
>
> Get java.lang.ClassCastException:
> org.tranql.connector.jdbc.TranqlDataSource$SelfReference cannot be cast to
> javax.sql.DataSource on the following code snippet.
> {code}
> InitialContext ic = new InitialContext();
> activeDS =
> (DataSource)ic.lookup("jca:/org.apache.geronimo.plugins.monitoring/agent-ds/JCAConnectionManager/jdbc/ActiveDS");
> {code}
> An instance of org.tranql.connector.jdbc.TranqlDataSource is expected to be
> returned, but get an instance of
> org.tranql.connector.jdbc.TranqlDataSource$SelfReference.
> TranqlDataSource implements javax.naming.Referenceable, so an instance of
> javax.naming.Reference is bound on to JNDI, but it is expected to be
> dereferenced when lookup.
>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira