From: Tom Anderson on
On Sun, 11 Apr 2010, Abu Yahya wrote:

> Roedy Green wrote:
>> On Thu, 08 Apr 2010 09:03:56 -0400, Tim Slattery <Slattery_T(a)bls.gov>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> This seems completely nuts to me. Am I missing a way around this, or
>>> am I doomed to recompile and/or add searches on more and more variants
>>> of the JNDI name?
>>
>> Hold your nose for this one. It smells of very old C++ code.
>>
>> Poke around in System.properties to see if you can find something that
>> will tell you which womb you are using. Then write a method that does
>> your JNDI given a magic string.
>
> We had a similar problem, and went with a solution similar to what Roedy
> suggests - finding out which womb we are in. We had to port our
> application to Websphere and Tomcat. For Tomcat, we instantiate
> InitialContext by calling the zero argument constructor, while in
> WebSphere we need to pass a Properties object with a key-value pair of
> Context.INITIAL_CONTEXT_FACTORY==>"com.ibm.websphere.naming.WsnInitialContextFactory"

Really? Did you try setting the javax.naming.factory.initial system
property to that value at WebSphere startup, and then using the no-args
constructor?

tom

--
Standing on the shoulders of Google
From: Abu Yahya on
Tom Anderson wrote:
> On Sun, 11 Apr 2010, Abu Yahya wrote:
>
>> Roedy Green wrote:
>>> On Thu, 08 Apr 2010 09:03:56 -0400, Tim Slattery <Slattery_T(a)bls.gov>
>>> wrote, quoted or indirectly quoted someone who said :
>>>
>>>> This seems completely nuts to me. Am I missing a way around this, or
>>>> am I doomed to recompile and/or add searches on more and more variants
>>>> of the JNDI name?
>>>
>>> Hold your nose for this one. It smells of very old C++ code.
>>>
>>> Poke around in System.properties to see if you can find something
>>> that will tell you which womb you are using. Then write a method
>>> that does your JNDI given a magic string.
>>
>> We had a similar problem, and went with a solution similar to what
>> Roedy suggests - finding out which womb we are in. We had to port our
>> application to Websphere and Tomcat. For Tomcat, we instantiate
>> InitialContext by calling the zero argument constructor, while in
>> WebSphere we need to pass a Properties object with a key-value pair of
>> Context.INITIAL_CONTEXT_FACTORY==>"com.ibm.websphere.naming.WsnInitialContextFactory"
>>
>
> Really? Did you try setting the javax.naming.factory.initial system
> property to that value at WebSphere startup, and then using the no-args
> constructor?
>
I didn't know about that method previously - it certainly works :)

But setting the property as a JVM arg does not break the code I posted
above - that is, if you first test whether you're in Websphere rather
than in Tomcat.