After your fix in jndi commands it works perfectly :-) Only the derby data source still contains / for the non-xa service.

Best regards
Krzysztof

On 17.01.2014 19:52, Jean-Baptiste Onofré wrote:
FYI, To follow the other thread, I also updated the datasource template files by removing the / prefix.

Now (in 3.0.1), the datasource JNDI name will be jdbc/${name} by default.

Regards
JB

On 01/17/2014 07:49 PM, Krzysztof Sobkowiak wrote:
Hi

The another thread was about JNDI commands

You have defined you service with property osgi.jndi.service.name set to
/jdbc/person. According to the JNDI Service Specification your service
should be available under Url osgi:service//jdbc/person (one / is added
automatically). The implementation of JNDI commands does not add the /
automatically, thus you see the jndi name as if it was
osgi:service/jdbc/person. KARAF-2690 changes rhe behaviour of the
commands and now in Karaf 3.0.1-SNAPSHOT, if you set
osgi.jndi.service.name set to  jdbc/person your service will be
available under osgi:service/jdbc/person and the commands will show
osgi:service/jdbc/person too.

Regards
Krzysztof


On 17.01.2014 19:29, schmke wrote:
I have a JDBC DataSource defined with the following datasource.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>

     <bean id="dataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<property name="url" value="jdbc:mysql://localhost:3306/person"/>
         <property name="user" value="user"/>
         <property name="password" value="pass"/>
     </bean>

     <service interface="javax.sql.DataSource" ref="dataSource">
         <service-properties>
             <entry key="osgi.jndi.service.name" value="/jdbc/person"/>
         </service-properties>
     </service>
</blueprint>

Executing jdbc:datasources works and shows:

/jdbc/person | MySQL   | 5.6.10  | jdbc:mysql://localhost:3306/person

There is also a JNDI entry returned from jndi:names:

osgi:service/jdbc/person | com.mysql.jdbc.jdbc2.optional.MysqlDataSource

All looks fine, but the following code executed from within my bundle throws
a NameNotFoundException:

         Context ctx = new InitialContext();
         this.dataSource = (DataSource)
ctx.lookup("osgi:service/jdbc/person");

However, I can look it up using the following line of code:

         this.dataSource = (DataSource)
ctx.lookup("osgi:service/javax.sql.DataSource");

Note that I did have to define the JNDI entry with a leading '/' which I saw
another thread about and it sounds like that may be changing. Is that
causing the problem with the first lookup above and will the fix from the
other thread fix this problem too?



--
View this message in context:http://karaf.922171.n3.nabble.com/JNDI-lookup-of-JDBC-DataSource-failing-with-Karaf-3-0-0-tp4031158.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
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.sobkow...@gmail.com <mailto:krzys.sobkow...@gmail.com> |
Twitter: @KSobkowiak



--
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.sobkow...@gmail.com <mailto:krzys.sobkow...@gmail.com> | Twitter: @KSobkowiak

Reply via email to