Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gemini-dev] How to register a data source instance with JNDI

Hi,

 

I made my first steps with Gemini DBAccess to register oracle data sources in an OSGi environment. And it works fine. Thanks for that.

Looking for a JNDI solution I found your project Gemini Naming. I analyzed the code and be aware that the Activator registers all the required components (even the OSGiURLContextFactory), to be able to look up for a JNDI-registered data source instance via a JNDI client as described in http://wiki.eclipse.org/Gemini/Naming/Documentation/JNDI_Clients.

What I´m not aware is how to register a data source instance with JNDI. How do I register a created data source instance with JNDI to be able to get that data source from another bundle.

I found in http://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#i1063832 the snippet:

Context ctx = new InitialContext();

ctx.bind("jdbc/sampledb", ods);

I tried with the following snippet, convinced that gemini naming registered every required components for that:

ServiceReference serviceReference = ctx.getServiceReference("org.osgi.service.jndi.JNDIContextManager");

JNDIContextManager contextManager = (JNDIContextManager) ctx.getService(serviceReference);

Context initialContext = contextManager.newInitialContext();

initialContext.bind(iDataSourceProps.getJNDIName(), createDataSource(iDataSourceProps));

But I received a javax.naming.NoInitialContextException.

Therefore I ask for the correct way how to do this.

Thanks a lot in advance.

 

Mit freundlichen Grüßen / Kind regards / Cordialmente

 

i. A. José Carlos Domínguez Fernández

Softwareentwickler / software developer

-------------------------------------------------------------------------------------------------

Compex Systemhaus GmbH, Hebelstraße 22, D-69115 Heidelberg

 

Telefon: +49 (6221) 53 81-61

Telefax: +49 (6221) 53 81-60

 

www.compex-commerce.com

 

Sitz / Siège Social / Registered Office: Heidelberg
Geschäftsführer / Gérant / General Manager: Christophe Loetz
Registergericht / Numéro de Registre / Commercial Register: Mannheim HRB 334033

 

Diese E-Mail bzw. die Anlagen enthalten vertrauliche oder rechtlich geschützte Informationen. Wenn Sie nicht der rechtmäßige Empfänger sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten diese E-Mail bzw. die Anlagen unverzüglich. Sie dürfen den Inhalt dieser e-Mail bzw. die Anlagen weder kopieren, verbreiten noch benutzen.

 

Ce courriel et les éventuelles pièces jointes contiennent des informations confidentielles ou protégées juridiquement. Si vous n’êtes pas la personne spécifiée ou que vous avez reçu ce courriel par erreur, nous vous remercions d’en informer l’expéditeur tout de suite et de détruire ce courriel et les éventuelles pièces jointes immédiatement. La copie, la divulgation ou l’utilisation du contenu de ce courriel et des éventuelles pièces jointes sont interdites.

 

This e-mail and its attachments may contain confidential or privileged information. If you are not the intended recipient or have received this e-mail or its attachments in error, please inform the sender immediately and destroy this e-mail and its attachments at once. You are not authorized to copy, disclose or use the content of this e-mail or its attachments.

 


Back to the top