You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Yegor Bugayenko <eg...@technoparkcorp.com> on 2011/05/07 00:37:54 UTC
Re: InitialContext in tomcat
Mansour,
Did you manage to solve the problem? I actually faced the same issue today.
Tomcat defines INITIAL_CONTEXT_FACTORY explicitly and jndi.properties do not
override it. Did you find a way to solve it?
—
Yegor
On Mon, Apr 25, 2011 at 7:48 AM, Mansour Al Akeel <mansour.alakeel@gmail.com
> wrote:
> Stephen,
>
> ~hank you for the reply. I am aware of this nature with regard to the
> jndi.properties, and it will be loaded by the class loader, but it
> wouldn't override the property of Context.INITIAL_CONTEXT_FACTORY
> that's loaded during tomcat start up. So I still need to pass this value
> manually everytime I need to do a lookup, or use service locator.
>
>
> On Mon Apr 25,2011 09:11 am, Stephen Connolly wrote:
> > you are missing the point. if you have jndi.properties on your classpath,
> > then that value is used by default. you don't need to look it up, the jre
> > looks it up for you
> >
> > - Stephen
> >
> > ---
> > Sent from my Android phone, so random spelling mistakes, random nonsense
> > words and other nonsense are a direct result of using swype to type on
> the
> > screen
> > On 25 Apr 2011 03:21, "Mansour Al Akeel" <ma...@gmail.com>
> wrote:
> > > Ok, but I still have to load the
> > > properties from the file, and pass it to the InitialContext constructor
> > > every time I need to create an InitialContext.
> > >
> > > This wouldn't give the desired effect.
> > >
> > > On Mon Apr 25,2011 03:53 am, Yegor Bugayenko wrote:
> > >> You can (and should) store the value into jndi.properties file, and
> make
> > it
> > >> available in classpath.
> > >>
> > >> ?
> > >> Yegor Bugayenko
> > >>
> > >>
> > >> On Sun, Apr 24, 2011 at 9:10 PM, Mansour Al Akeel <
> > mansour.alakeel@gmail.com
> > >> > wrote:
> > >>
> > >> > Is there a way to avoid doing:
> > >> >
> > >> > Properties env = new Properties();
> > >> > env.put(Context.INITIAL_CONTEXT_FACTORY,
> > >> > "org.apache.openejb.client.LocalInitialContextFactory");
> > >> > InitialContext initContext = new InitialContext(env);
> > >> >
> > >> > Everytime I need a context. I am trying to avoid putting the
> > >> > InitialContext Factory in my code. If I don't se the
> > >> > INITIAL_CONTEXT_FACTORY the value for this property is :
> > >> >
> > >> > java.naming.factory.initial:
> > org.apache.naming.java.javaURLContextFactory
> > >> >
> > >> > Which is the default tomcat JNDI. Is there a way to make this
> property
> > >> > the default for the application, so I don't have to set it every
> time ?
> > >> > I am trying to perform the lookup from jsp. I thought about using a
> > >> > service locator. Is there a better way ?
> > >> >
> > >> > Thank you.
> > >> >
> > >> >
> > >> >
> > >> >
>
Re: InitialContext in tomcat
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi all,
No, AFAIK that is not possible to override Tomcat behavior.
Be default when looking up resources in java: prefix, Tomcat will be always
the default one who will answer (not OpenEJB).
In OpenEJB, we use openejb: prefix which is unknown for Tomcat.
It works fine in OpenEJB standalone as well as embedded in Tomcat.
Some years ago, we tried to manage java: prefix only in Tomcat but it
created a lot of noise and hooks in Tomcat for an added value not really
clear for me.
To conclude, I don't think you need to set the ICF because when you need a
resource managed by OpenJB, you will use the openejb: prefix.
Hope it helps.
If it's not totally clear, feel free to hit somebody here or in IRC.
In the mid time, I guess it would be useful to add an entry in the web site.
Jean-Louis
2011/5/7 Yegor Bugayenko <eg...@technoparkcorp.com>
> Mansour,
>
> Did you manage to solve the problem? I actually faced the same issue today.
> Tomcat defines INITIAL_CONTEXT_FACTORY explicitly and jndi.properties do
> not
> override it. Did you find a way to solve it?
>
> —
> Yegor
>
>
>
> On Mon, Apr 25, 2011 at 7:48 AM, Mansour Al Akeel <
> mansour.alakeel@gmail.com
> > wrote:
>
> > Stephen,
> >
> > ~hank you for the reply. I am aware of this nature with regard to the
> > jndi.properties, and it will be loaded by the class loader, but it
> > wouldn't override the property of Context.INITIAL_CONTEXT_FACTORY
> > that's loaded during tomcat start up. So I still need to pass this value
> > manually everytime I need to do a lookup, or use service locator.
> >
> >
> > On Mon Apr 25,2011 09:11 am, Stephen Connolly wrote:
> > > you are missing the point. if you have jndi.properties on your
> classpath,
> > > then that value is used by default. you don't need to look it up, the
> jre
> > > looks it up for you
> > >
> > > - Stephen
> > >
> > > ---
> > > Sent from my Android phone, so random spelling mistakes, random
> nonsense
> > > words and other nonsense are a direct result of using swype to type on
> > the
> > > screen
> > > On 25 Apr 2011 03:21, "Mansour Al Akeel" <ma...@gmail.com>
> > wrote:
> > > > Ok, but I still have to load the
> > > > properties from the file, and pass it to the InitialContext
> constructor
> > > > every time I need to create an InitialContext.
> > > >
> > > > This wouldn't give the desired effect.
> > > >
> > > > On Mon Apr 25,2011 03:53 am, Yegor Bugayenko wrote:
> > > >> You can (and should) store the value into jndi.properties file, and
> > make
> > > it
> > > >> available in classpath.
> > > >>
> > > >> ?
> > > >> Yegor Bugayenko
> > > >>
> > > >>
> > > >> On Sun, Apr 24, 2011 at 9:10 PM, Mansour Al Akeel <
> > > mansour.alakeel@gmail.com
> > > >> > wrote:
> > > >>
> > > >> > Is there a way to avoid doing:
> > > >> >
> > > >> > Properties env = new Properties();
> > > >> > env.put(Context.INITIAL_CONTEXT_FACTORY,
> > > >> > "org.apache.openejb.client.LocalInitialContextFactory");
> > > >> > InitialContext initContext = new InitialContext(env);
> > > >> >
> > > >> > Everytime I need a context. I am trying to avoid putting the
> > > >> > InitialContext Factory in my code. If I don't se the
> > > >> > INITIAL_CONTEXT_FACTORY the value for this property is :
> > > >> >
> > > >> > java.naming.factory.initial:
> > > org.apache.naming.java.javaURLContextFactory
> > > >> >
> > > >> > Which is the default tomcat JNDI. Is there a way to make this
> > property
> > > >> > the default for the application, so I don't have to set it every
> > time ?
> > > >> > I am trying to perform the lookup from jsp. I thought about using
> a
> > > >> > service locator. Is there a better way ?
> > > >> >
> > > >> > Thank you.
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> >
>