tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arshad Mahmood" <>
Subject Re: JNDI with a custom factory not working
Date Fri, 14 Jun 2002 10:42:26 GMT

From: "Remy Maucherat" <>
To: "Tomcat Developers List" <>
Sent: Thursday, June 13, 2002 7:11 PM
Subject: Re: JNDI with a custom factory not working

> Arshad Mahmood wrote:
> > Hmm, I will investigate further. It seemed to be that "ResourceLink" in
> > server.xml
> > "<Context" entry was going into a naming context with name
> > "//Standard/myapp" but
> > the one which I retrieved from the servlet was called
> > "//Standard/localhost/webapp". I will
> > debug this further.
> The context name is not important for the global context. The
> ResourceLink are actually yet another reference which is bound into the
> webapp naming context, and use a standard JNDI object factory
> (factory.ResourceLinkFactory). The lookup in the actual global context
> then just uses a static reference instead of another lookup.

I had a look at the JNDI example, unfortunately it wasn't totally relevant
as everything
is defined in the web.xml and that has always worked for me.

After a lot more debugging and I am getting even more confused (!!!). I put
some trace
into the "init" function of my servlet. It's within the "init" that I do the
JNDI name lookups.
The "init" gets called twice per servlet. On the first call everything is OK
and my lookup
succeeds. The second time however the lookup fails with a NamingException.

I notice that the first time the "init" gets called, the context returned
has the bindings I expect.
The second call to "init" which performs identical processing gets a
NamingContext with
nothing bound (I don't have any entries in the web.xml, had I defined any I
think they would be
the only entries there).

It also looked like the two inits were done by different class loaders, as I
defined some static
members and they were not carried across to the second init.

Can anybody explain why the "init" may be called twice?

> > I will have a look at the JNDI example servlet. I must confess I was
> > the
> > JNDI-Howto in the docs.
> Which may not be totally accurate, and don't talk at all about how it
> actually works.
> > The latest version of 4.1 from CVS (although it's a little broken
> > MBeanUtils
> > does't compile, but I am not using that anyway).
> Really ? It does build for me. What's the problem ?
> I do get an exception on shutdown, or when removing a context, though.

Sorry, ant problems. I think the date on my machine may be a bit slow and
when I did an update it didn't recompile everything.


> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message