Yes Krzysztof, it's what I proposed in my previous e-mail (but by
removing the prefixing / in the datasource definition) ;)
Regards
JB
On 01/17/2014 07:36 PM, Krzysztof Sobkowiak wrote:
Hi
Could you please check this?
Context ctx = new InitialContext();
this.dataSource = (DataSource)
ctx.lookup("osgi:service//jdbc/person");
Best 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>ou
<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: [email protected] <mailto:[email protected]> |
Twitter: @KSobkowiak
--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com