Access JNDI from Hivemind?

View: New views
3 Messages — Rating Filter:   Alert me  

Access JNDI from Hivemind?

by Stanczak Group :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

by Stanczak Group :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


Re: Access JNDI from Hivemind?

by Renat Zubairov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <justin@...> 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