You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Stanczak Group <ju...@stanczakgroup.com> on 2007/01/06 04:52:00 UTC

Access JNDI from Hivemind?

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


Re: Access JNDI from Hivemind?

Posted by Renat Zubairov <re...@gmail.com>.
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

Re: Access JNDI from Hivemind?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
Looks like I need to be using hivemind.lib.NameLookup with a custom 
service instead. I'll do that, if someone knows a better way then let me 
know. thanks.


Stanczak Group 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