You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Renat Zubairov <re...@gmail.com> on 2007/02/21 13:37:14 UTC

Re: Access JNDI from Hivemind?

I'm using hivemind.lib.NamingLookup for that and it works fine.
Here is example:

In your hivemodule.xml

...
	<dependency module-id="hivemind.lib" version="1.1.0"/>
...

In your service

   NameLookup lookup = null;

   public void setLookup(NameLookup lookup) {
       this.lookup = lookup;
   }

...
..
				log.info("Getting connection using JNDI located datasource "
						+ lookupName);
				try
				{
					DataSource ds = (DataSource)nameLookup.lookup(lookupName,
							DataSource.class);
					connection = ds.getConnection();
				}catch( SQLException e )
				{
					log.error("Exception by getting and opening connection ", e);
				}

Where lookup name is
				<set property="lookupName" value="jdbc/DS_NAME"/>

Offcourse you should have a datasource association configured in your
web.xml and in the server.



On 06/01/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
> How do I access JNDI from Hivemind? I've looked and tried what the docs
> say, but no luck. I'm accessing a Jackrabbit repository using this for
> normal code outside Hivemind.
>
> InitialContext context = new InitialContext();
> Context environment = (Context) context.lookup("java:comp/env");
> Repository jrRepository = (Repository) environment.lookup("jcr/repository");
>
> I've tried several thinks with no luck, anyone know or have example to
> do this?
>
> --
> Justin Stanczak
> Stanczak Group
> 812-735-3600
>
> "All that is necessary for the triumph of evil is that good men do nothing."
> Edmund Burke
>
>


-- 
Best regards,
Renat Zubairov