Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » How to use JNDI to lookup services(How to use JNDI to lookup services)
How to use JNDI to lookup services [message #924076] Wed, 26 September 2012 13:32 Go to next message
Tom Missing name is currently offline Tom Missing nameFriend
Messages: 16
Registered: February 2010
Junior Member
Does anyone have a working example how to lookup services via JNDI in virgo?

I've read through the gemini naming doc and the few hits i've found on google on the subject. But, ive not found anything concrete on how to configure virgo or the correct steps to use from the client side.

So does anyone have working examples on how to do the following:
1. How to set up virgo to enable looking up services using JNDI
2. How to lookup services via JNDI from a bundle.

Sorry if I've missed the obvious.

Thanks for any help.

Re: How to use JNDI to lookup services [message #924105 is a reply to message #924076] Wed, 26 September 2012 14:10 Go to previous messageGo to next message
Tom Missing name is currently offline Tom Missing nameFriend
Messages: 16
Registered: February 2010
Junior Member
I think I figured this out. I'll post here what I did:

I'm running Virgo Jetty 3.5

1. Get Gemini naming bundle from eclipse site.

1. Add Gemini naming bundle to user region.
For now I just dropped the bundle in my pickup dir.
I think the right way to do this is to install the gemini naming bundle in kernel but I haven't done this yet. Once I do i'll post those steps.

2. Imported org.osgi.service.jndi into user region
Update file /configuration/org.eclipse.virgo.kernel.userregion.properties
add org.osgi.service.jndi;version="0" to the packageImports as so:
packageImports =\
org.eclipse.virgo.kernel.artifact.*;version="0",\
org.eclipse.virgo.kernel.core;version="0",\
org.eclipse.virgo.kernel.deployer.core;version="0",\
org.eclipse.virgo.kernel.deployer.core.event;version="0",\
org.eclipse.virgo.kernel.deployer.config;version="0",\
org.eclipse.virgo.kernel.install.*;version="0",\
org.eclipse.virgo.kernel.osgi.*;version="0",\
org.eclipse.virgo.kernel.model;version="0",\
org.eclipse.virgo.kernel.model.management;version="0",\
org.eclipse.virgo.kernel.module;version="0",\
org.eclipse.virgo.kernel.serviceability;version="0",\
org.eclipse.virgo.kernel.serviceability.*;version="0",\
org.eclipse.virgo.kernel.services.work;version="0",\
org.eclipse.virgo.kernel.shell;version="0",\
org.eclipse.virgo.kernel.shell.*;version="0",\
org.eclipse.virgo.kernel.shim.*;version="0",\
org.eclipse.virgo.medic.*;version="0",\
org.eclipse.virgo.repository;version="0",\
org.eclipse.virgo.repository.*;version="0",\
org.eclipse.virgo.util.*;version="0",\
org.apache.commons.logging;version="[1.0.0,2.0.0)",\
org.apache.commons.logging.impl;version="[1.0.0,2.0.0)",\
org.aspectj.*;version="[1.6.5.RELEASE,2.0.0)",\
org.osgi.service.event;version="0",\
org.osgi.service.log;version="0",\
org.eclipse.equinox.region;version="1",\
ch.qos.logback.*;version="[1.0.0,2.0.0)",\
org.slf4j;version="[1.6.1,2)",\
org.slf4j.helpers;version="[1.6.1,2)",\
org.slf4j.spi;version="[1.6.1,2)",\
org.osgi.service.jndi;version="0"

3. Coded client bundle as follows:
InitialContext ic = new InitialContext();
AdapterService adapterService = (AdapterService) ic.lookup("osgi:service/"+AdapterService.class.getName());

Where AdapterService is the service to lookup.

4. I'm developing in Eclipse so I had to add the Gemini naming bundle to my Plugin Target Environment. I did this so that I could import the package javax.naming in my client bundle.

5. Import javax.naming in client bundle.
If you do not do this you will get class not found for javax/naming/InitialContext. When running the client bundle.

6. Dropped my client bundle in my pickup dir.

7. Cycled the server to pickup the packageImports change

8. Used Bundle

9. Bob is my uncle.

I hope that helps anyone else trying to do this. I'm sure this seems obvious to some but for a nube like me this wasn't.

Also, I'll post the changes to get this installed without using the pickup dir.


Let me know if any questions/comments.
Thanks,
T




Re: How to use JNDI to lookup services [message #924348 is a reply to message #924105] Wed, 26 September 2012 19:22 Go to previous message
Violeta Georgieva is currently offline Violeta GeorgievaFriend
Messages: 244
Registered: October 2010
Senior Member
Hi,

You can do this also using Virgo Server for Apache Tomcat.

Again you have to install Gemini Naming etc. as you described above.
In addition you have to add -DuseNaming=osgi so that Virgo Server for Apache Tomcat will start with OSGi JNDI

Regards
Violeta
Previous Topic:working shared library war for VTS 3.5.0
Next Topic:NoClassDef: javax/management/ObjectName from Web Bundle
Goto Forum:
  


Current Time: Fri Nov 28 08:55:32 GMT 2014

Powered by FUDForum. Page generated in 0.16492 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software