Topic
1 reply Latest Post - ‏2011-11-07T11:22:23Z by FrederikDeBacker
FrederikDeBacker
FrederikDeBacker
12 Posts
ACCEPTED ANSWER

Pinned topic OSGi: JNDI lookup of Datasource

‏2011-11-04T09:06:42Z |
Hello,

I am working on implementing an OSGi application on the latest version of WAS CE 3.0.0. I use JPA to acces the database. Via the console I have defined two datasources called jdbc/dexiaosgipoc and jdbc/xadexiaosgipoc. In my JPA persistence.xml file I have the following:

<jta-data-source>jdbc/xadexiaosgipocdb</jta-data-source>
<non-jta-data-source>jdbc/dexiaosgipocdb</non-jta-data-source>

However when I try to run the application I get the exception:

2011-11-04 08:57:42,382 ERROR container No JTA datasource could be located using the JNDI name jdbc/xadexiaosgipocdb
javax.naming.NotContextException: openejb/remote/jdbc/xadexiaosgipocdb
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:165)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:605)
at org.apache.geronimo.openejb.DeepBindableContext$ContextWrapper.lookup(DeepBindableContext.java:97)
at org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:197)
at org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:136)
I have tried to change the name of the jta-data-source and non-jta-data-source like this:

<jta-data-source>java:comp/env/jdbc/xadexiaosgipocdb</jta-data-source>
<non-jta-data-source>java:comp/env/jdbc/dexiaosgipocdb</non-jta-data-source>

but then i get

2011-11-04 09:23:13,726 ERROR container No JTA datasource could be located usi
ng the JNDI name java:comp/env/jdbc/xadexiaosgipocdb
javax.naming.NotContextException: jdbc/xadexiaosgipocdb
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:165)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:619)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:156)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:619)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:156)
at org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
t.java:605)
at org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:6
3)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161
)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getD
s(DelayedLookupDataSource.java:43)
I was wondering how I need to configure this? Any help would be appreciated.

kr,

Frederik.
Updated on 2011-11-07T11:22:23Z at 2011-11-07T11:22:23Z by FrederikDeBacker
  • FrederikDeBacker
    FrederikDeBacker
    12 Posts
    ACCEPTED ANSWER

    Re: OSGi: JNDI lookup of Datasource

    ‏2011-11-07T11:22:23Z  in response to FrederikDeBacker
    Hi all,

    I managed to solve my issue.

    I configured the datapool via the command line deploy command:

    deploy --user <set yours> --password <set yours> deploy tranql-connector-derby-embed-xa-1.6.rar osgipoc-xadatasource.xml
    (see attachment for file osgipoc-xadatasource.xml)

    then you can lookup your datasource via the jndi lookup string:

    jca:/<moduleId/groupId>/<moduleId/artifactId>/JCAConnectionManager/<connectiondefinition-instance/name>

    or for the example in attach

    jca:/dexia.osgipoc/xadexiaosgipocdb/JCAConnectionManager/xadexiaosgipocdb

    kr,

    Frederik.