You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Krzysztof Sobkowiak <kr...@gmail.com> on 2014/01/16 22:04:30 UTC
JNDI Commands - missing / delimiter in jndi name
Hi
If I correctly understand the JNDI Service Specification, each
registered service is available under the osgi:service/interface JNDI name
Assume following service
<bean id="dataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
<property name="databaseName" value="test"/>
<property name="createDatabase" value="create" />
</bean>
<service ref="dataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/test"/>
</service-properties>
</service>
This service should be available under following names:
* osgi:service/javax.sql.DataSource
* osgi:service/javax.sql.DataSourc/(osgi.jndi.service.name=jdbc/test)
* osgi:service/jdbc/test
I haven't tested in Karaf 3.x yet, if the services can be retrieved
using these jndi names and jndi api, but in Karaf 2.3.x in worked for me
as I needed it. I assume in Karaf 3.x it works too.
But if I use jndi:names command to list the available jndi names I'm
getting following result
karaf@root()> jndi:names
JNDI Name | Class Name
------------------------------------------------------------------------
osgi:service/jndi | org.apache.karaf.jndi.internal.JndiServiceImpl
osgi:servicejdbc/test | org.apache.derby.jdbc.EmbeddedXADataSource
The command completer gives following result
karaf@root()> jndi:alias osgi:service
osgi:service/jndi osgi:servicejdbc/test
I think, the jndi commands have an issue and the / character is missing
in the jndi name for services with defined osgi.jndi.service.name
property. The service osgi:service/jndi has a correct name but it is
registered with osgi.jndi.service.name=/jndi.
Best regards
Krzysztof
--
Krzysztof Sobkowiak
JEE & OSS Architect | Technical Architect @ Capgemini
Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
<http://www.pl.capgemini-sdm.com/> | Wroclaw
e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
Twitter: @KSobkowiak
Re: JNDI Commands - missing / delimiter in jndi name
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
FYI:
https://issues.apache.org/jira/browse/KARAF-2690
I will push in around 30mn.
Regards
JB
On 01/17/2014 08:30 AM, Krzysztof Sobkowiak wrote:
> Hi
>
> I still don't understand something. Specification says:
>
> The URL scheme is specified
> as follows:
> service ::= ’osgi:service/’ query
> query ::= jndi-name | qname ( ’/’ filter )?
> jndi-name ::= <any string>
>
> ....
>
> Thus the following lookup is valid:
> osgi:servicelist/javax.sql.DataSource/(&(db=mydb)(version=3.1))
> A service can provide a JNDI service name if it provides the following
> service property:
> • osgi.jndi.service.name - An alternative name that the service can be
> looked up by when the osgi: URL scheme is used.
> If a service is published with a JNDI service name then the service
> matches any URL that has this service name in the place of interface.
> For example, if the JNDI service name is foo, then the following URL
> selects this service:
> osgi:service/foo
>
> I think, the delimiter / should be added automatically. In this case
> when my sample configuration defines osgi.jndi.service.name as jdbc/test
> so I should be able to obtain the service using
>
> ctx.lookup("osgi:service/jdbc/test")
>
> I should be also able to reference the data source in my persistence using
>
> <non-jta-data-source>osgi:service/jdbc/test</non-jta-data-source>
>
> So, the service is registered in jndi as osgi:service/jdbc/test. When I
> am wrong at this point please correct me.
>
> If the text above is correct, I don't understand why the commands do
> something other
>
> Best regards
> Krzysztof
>
>
>
> On 17.01.2014 06:20, Jean-Baptiste Onofré wrote:
>> Hi,
>>
>> You have to use the correct name.
>>
>> You JNDI name should be /jdbc/test.
>>
>> I'm registering the JNDI service with /jndi as name (which is correct).
>>
>> As you don't define the prefix context, the JNDI name is
>> osgi:servicejdbc/test (which is correct as the context is osgi:service).
>>
>> So the JNDI command just display what you provided.
>>
>> In the special case of osgi:service, the command doesn't do a JNDI
>> lookup, it does a service lookup.
>>
>> Regards
>> JB
>>
>> On 01/16/2014 10:04 PM, Krzysztof Sobkowiak wrote:
>>> Hi
>>>
>>> If I correctly understand the JNDI Service Specification, each
>>> registered service is available under the osgi:service/interface JNDI
>>> name
>>>
>>> Assume following service
>>>
>>> <bean id="dataSource"
>>> class="org.apache.derby.jdbc.EmbeddedXADataSource">
>>> <property name="databaseName" value="test"/>
>>> <property name="createDatabase" value="create" />
>>> </bean>
>>>
>>> <service ref="dataSource" interface="javax.sql.DataSource">
>>> <service-properties>
>>> <entry key="osgi.jndi.service.name" value="jdbc/test"/>
>>> </service-properties>
>>> </service>
>>>
>>> This service should be available under following names:
>>>
>>> * osgi:service/javax.sql.DataSource
>>> * osgi:service/javax.sql.DataSourc/(osgi.jndi.service.name=jdbc/test)
>>> * osgi:service/jdbc/test
>>>
>>> I haven't tested in Karaf 3.x yet, if the services can be retrieved
>>> using these jndi names and jndi api, but in Karaf 2.3.x in worked for me
>>> as I needed it. I assume in Karaf 3.x it works too.
>>>
>>> But if I use jndi:names command to list the available jndi names I'm
>>> getting following result
>>>
>>> karaf@root()> jndi:names
>>> JNDI Name | Class Name
>>> ------------------------------------------------------------------------
>>> osgi:service/jndi | org.apache.karaf.jndi.internal.JndiServiceImpl
>>> osgi:servicejdbc/test | org.apache.derby.jdbc.EmbeddedXADataSource
>>>
>>> The command completer gives following result
>>>
>>> karaf@root()> jndi:alias osgi:service
>>> osgi:service/jndi osgi:servicejdbc/test
>>>
>>> I think, the jndi commands have an issue and the / character is missing
>>> in the jndi name for services with defined osgi.jndi.service.name
>>> property. The service osgi:service/jndi has a correct name but it is
>>> registered with osgi.jndi.service.name=/jndi.
>>>
>>> Best regards
>>> Krzysztof
>
>
> --
> Krzysztof Sobkowiak
>
> JEE & OSS Architect | Technical Architect @ Capgemini
> Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
> <http://www.pl.capgemini-sdm.com/> | Wroclaw
> e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
> Twitter: @KSobkowiak
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: JNDI Commands - missing / delimiter in jndi name
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
It's a difference between an URL and a JNDI name.
The spec talk about URL, I'm talking about JNDI name.
I will add the delimiter automatically, but it means that a URL could be
osgi:service//my-name.
Regards
JB
On 01/17/2014 08:30 AM, Krzysztof Sobkowiak wrote:
> Hi
>
> I still don't understand something. Specification says:
>
> The URL scheme is specified
> as follows:
> service ::= ’osgi:service/’ query
> query ::= jndi-name | qname ( ’/’ filter )?
> jndi-name ::= <any string>
>
> ....
>
> Thus the following lookup is valid:
> osgi:servicelist/javax.sql.DataSource/(&(db=mydb)(version=3.1))
> A service can provide a JNDI service name if it provides the following
> service property:
> • osgi.jndi.service.name - An alternative name that the service can be
> looked up by when the osgi: URL scheme is used.
> If a service is published with a JNDI service name then the service
> matches any URL that has this service name in the place of interface.
> For example, if the JNDI service name is foo, then the following URL
> selects this service:
> osgi:service/foo
>
> I think, the delimiter / should be added automatically. In this case
> when my sample configuration defines osgi.jndi.service.name as jdbc/test
> so I should be able to obtain the service using
>
> ctx.lookup("osgi:service/jdbc/test")
>
> I should be also able to reference the data source in my persistence using
>
> <non-jta-data-source>osgi:service/jdbc/test</non-jta-data-source>
>
> So, the service is registered in jndi as osgi:service/jdbc/test. When I
> am wrong at this point please correct me.
>
> If the text above is correct, I don't understand why the commands do
> something other
>
> Best regards
> Krzysztof
>
>
>
> On 17.01.2014 06:20, Jean-Baptiste Onofré wrote:
>> Hi,
>>
>> You have to use the correct name.
>>
>> You JNDI name should be /jdbc/test.
>>
>> I'm registering the JNDI service with /jndi as name (which is correct).
>>
>> As you don't define the prefix context, the JNDI name is
>> osgi:servicejdbc/test (which is correct as the context is osgi:service).
>>
>> So the JNDI command just display what you provided.
>>
>> In the special case of osgi:service, the command doesn't do a JNDI
>> lookup, it does a service lookup.
>>
>> Regards
>> JB
>>
>> On 01/16/2014 10:04 PM, Krzysztof Sobkowiak wrote:
>>> Hi
>>>
>>> If I correctly understand the JNDI Service Specification, each
>>> registered service is available under the osgi:service/interface JNDI
>>> name
>>>
>>> Assume following service
>>>
>>> <bean id="dataSource"
>>> class="org.apache.derby.jdbc.EmbeddedXADataSource">
>>> <property name="databaseName" value="test"/>
>>> <property name="createDatabase" value="create" />
>>> </bean>
>>>
>>> <service ref="dataSource" interface="javax.sql.DataSource">
>>> <service-properties>
>>> <entry key="osgi.jndi.service.name" value="jdbc/test"/>
>>> </service-properties>
>>> </service>
>>>
>>> This service should be available under following names:
>>>
>>> * osgi:service/javax.sql.DataSource
>>> * osgi:service/javax.sql.DataSourc/(osgi.jndi.service.name=jdbc/test)
>>> * osgi:service/jdbc/test
>>>
>>> I haven't tested in Karaf 3.x yet, if the services can be retrieved
>>> using these jndi names and jndi api, but in Karaf 2.3.x in worked for me
>>> as I needed it. I assume in Karaf 3.x it works too.
>>>
>>> But if I use jndi:names command to list the available jndi names I'm
>>> getting following result
>>>
>>> karaf@root()> jndi:names
>>> JNDI Name | Class Name
>>> ------------------------------------------------------------------------
>>> osgi:service/jndi | org.apache.karaf.jndi.internal.JndiServiceImpl
>>> osgi:servicejdbc/test | org.apache.derby.jdbc.EmbeddedXADataSource
>>>
>>> The command completer gives following result
>>>
>>> karaf@root()> jndi:alias osgi:service
>>> osgi:service/jndi osgi:servicejdbc/test
>>>
>>> I think, the jndi commands have an issue and the / character is missing
>>> in the jndi name for services with defined osgi.jndi.service.name
>>> property. The service osgi:service/jndi has a correct name but it is
>>> registered with osgi.jndi.service.name=/jndi.
>>>
>>> Best regards
>>> Krzysztof
>
>
> --
> Krzysztof Sobkowiak
>
> JEE & OSS Architect | Technical Architect @ Capgemini
> Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
> <http://www.pl.capgemini-sdm.com/> | Wroclaw
> e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
> Twitter: @KSobkowiak
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: JNDI Commands - missing / delimiter in jndi name
Posted by Krzysztof Sobkowiak <kr...@gmail.com>.
Hi
I still don't understand something. Specification says:
The URL scheme is specified
as follows:
service ::= ’osgi:service/’ query
query ::= jndi-name | qname ( ’/’ filter )?
jndi-name ::= <any string>
....
Thus the following lookup is valid:
osgi:servicelist/javax.sql.DataSource/(&(db=mydb)(version=3.1))
A service can provide a JNDI service name if it provides the following
service property:
• osgi.jndi.service.name - An alternative name that the service can be
looked up by when the osgi: URL scheme is used.
If a service is published with a JNDI service name then the service
matches any URL that has this service name in the place of interface.
For example, if the JNDI service name is foo, then the following URL
selects this service:
osgi:service/foo
I think, the delimiter / should be added automatically. In this case
when my sample configuration defines osgi.jndi.service.name as jdbc/test
so I should be able to obtain the service using
ctx.lookup("osgi:service/jdbc/test")
I should be also able to reference the data source in my persistence using
<non-jta-data-source>osgi:service/jdbc/test</non-jta-data-source>
So, the service is registered in jndi as osgi:service/jdbc/test. When I
am wrong at this point please correct me.
If the text above is correct, I don't understand why the commands do
something other
Best regards
Krzysztof
On 17.01.2014 06:20, Jean-Baptiste Onofré wrote:
> Hi,
>
> You have to use the correct name.
>
> You JNDI name should be /jdbc/test.
>
> I'm registering the JNDI service with /jndi as name (which is correct).
>
> As you don't define the prefix context, the JNDI name is
> osgi:servicejdbc/test (which is correct as the context is osgi:service).
>
> So the JNDI command just display what you provided.
>
> In the special case of osgi:service, the command doesn't do a JNDI
> lookup, it does a service lookup.
>
> Regards
> JB
>
> On 01/16/2014 10:04 PM, Krzysztof Sobkowiak wrote:
>> Hi
>>
>> If I correctly understand the JNDI Service Specification, each
>> registered service is available under the osgi:service/interface JNDI
>> name
>>
>> Assume following service
>>
>> <bean id="dataSource"
>> class="org.apache.derby.jdbc.EmbeddedXADataSource">
>> <property name="databaseName" value="test"/>
>> <property name="createDatabase" value="create" />
>> </bean>
>>
>> <service ref="dataSource" interface="javax.sql.DataSource">
>> <service-properties>
>> <entry key="osgi.jndi.service.name" value="jdbc/test"/>
>> </service-properties>
>> </service>
>>
>> This service should be available under following names:
>>
>> * osgi:service/javax.sql.DataSource
>> * osgi:service/javax.sql.DataSourc/(osgi.jndi.service.name=jdbc/test)
>> * osgi:service/jdbc/test
>>
>> I haven't tested in Karaf 3.x yet, if the services can be retrieved
>> using these jndi names and jndi api, but in Karaf 2.3.x in worked for me
>> as I needed it. I assume in Karaf 3.x it works too.
>>
>> But if I use jndi:names command to list the available jndi names I'm
>> getting following result
>>
>> karaf@root()> jndi:names
>> JNDI Name | Class Name
>> ------------------------------------------------------------------------
>> osgi:service/jndi | org.apache.karaf.jndi.internal.JndiServiceImpl
>> osgi:servicejdbc/test | org.apache.derby.jdbc.EmbeddedXADataSource
>>
>> The command completer gives following result
>>
>> karaf@root()> jndi:alias osgi:service
>> osgi:service/jndi osgi:servicejdbc/test
>>
>> I think, the jndi commands have an issue and the / character is missing
>> in the jndi name for services with defined osgi.jndi.service.name
>> property. The service osgi:service/jndi has a correct name but it is
>> registered with osgi.jndi.service.name=/jndi.
>>
>> Best regards
>> Krzysztof
--
Krzysztof Sobkowiak
JEE & OSS Architect | Technical Architect @ Capgemini
Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
<http://www.pl.capgemini-sdm.com/> | Wroclaw
e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
Twitter: @KSobkowiak
Re: JNDI Commands - missing / delimiter in jndi name
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
You have to use the correct name.
You JNDI name should be /jdbc/test.
I'm registering the JNDI service with /jndi as name (which is correct).
As you don't define the prefix context, the JNDI name is
osgi:servicejdbc/test (which is correct as the context is osgi:service).
So the JNDI command just display what you provided.
In the special case of osgi:service, the command doesn't do a JNDI
lookup, it does a service lookup.
Regards
JB
On 01/16/2014 10:04 PM, Krzysztof Sobkowiak wrote:
> Hi
>
> If I correctly understand the JNDI Service Specification, each
> registered service is available under the osgi:service/interface JNDI name
>
> Assume following service
>
> <bean id="dataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
> <property name="databaseName" value="test"/>
> <property name="createDatabase" value="create" />
> </bean>
>
> <service ref="dataSource" interface="javax.sql.DataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name" value="jdbc/test"/>
> </service-properties>
> </service>
>
> This service should be available under following names:
>
> * osgi:service/javax.sql.DataSource
> * osgi:service/javax.sql.DataSourc/(osgi.jndi.service.name=jdbc/test)
> * osgi:service/jdbc/test
>
> I haven't tested in Karaf 3.x yet, if the services can be retrieved
> using these jndi names and jndi api, but in Karaf 2.3.x in worked for me
> as I needed it. I assume in Karaf 3.x it works too.
>
> But if I use jndi:names command to list the available jndi names I'm
> getting following result
>
> karaf@root()> jndi:names
> JNDI Name | Class Name
> ------------------------------------------------------------------------
> osgi:service/jndi | org.apache.karaf.jndi.internal.JndiServiceImpl
> osgi:servicejdbc/test | org.apache.derby.jdbc.EmbeddedXADataSource
>
> The command completer gives following result
>
> karaf@root()> jndi:alias osgi:service
> osgi:service/jndi osgi:servicejdbc/test
>
> I think, the jndi commands have an issue and the / character is missing
> in the jndi name for services with defined osgi.jndi.service.name
> property. The service osgi:service/jndi has a correct name but it is
> registered with osgi.jndi.service.name=/jndi.
>
> Best regards
> Krzysztof
>
>
>
>
>
> --
> Krzysztof Sobkowiak
>
> JEE & OSS Architect | Technical Architect @ Capgemini
> Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
> <http://www.pl.capgemini-sdm.com/> | Wroclaw
> e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
> Twitter: @KSobkowiak
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com