RE: AdaptiveClassLoader, getResources, jndi.properties (Tomcat bug?)

2001-07-19 Thread Rob S.

If this is what I'm remembering, your ContextFactory class can't be found.
This is cuz the JNDI code is broken in that it doesn't rely on its parent
classloader (in our case, the one that knows about WEB-INF/classes and lib)
to load the context factory.

You have to implement your own InitialContextFactoryBuilder.  Check the Sun
messages boards.  I ran into the same problem last month.

- r

 -Original Message-
 From: David Haraburda [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 19, 2001 10:51 AM
 To: [EMAIL PROTECTED]
 Subject: AdaptiveClassLoader, getResources, jndi.properties (Tomcat
 bug?)


 Hi,

 I got no response to this message on the tomcat-user list, so I am
 trying here.  I could find nothing in the archives except the message I
 refer to below -- I apologize if this issue has been addressed and I
 just couldn't find the info...

 I am having problems with jndi.properties being read from my
 WEB-INF/classes directory.  I have seen this problem referenced once on
 the tomcat-dev mailing list -- someone submitted a patch, but apparently

 it did not get committed.  (I couldn't find a reason why, so I am not
 sure if that was the real solution to the problem or not).  The original

 message is here:
 http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg06588.html

 I have verified that the same behaivor he refers to is going on with my
 application -- InitialContext is using getResources(), which doesn't
 return anything becuase AdaptiveClassLoader doesn't implement
 findResource or findResources.

 Has anyone else having this problem found a solution/work-around?  Is
 there a Tomcat guru/developer out there who can explain why
 AdaptiveClassLoader doesn't implement findResources()?

 Thanks,

 David






Re: AdaptiveClassLoader, getResources, jndi.properties (Tomcat bug?)

2001-07-19 Thread David Haraburda

Hi,

Thanks for responding.  As far as I can tell this is a problem with Tomcat...
AdaptiveClassLoader doesn't override findResources, which is causing the
problem.  I am digging through the source, and here is what happens when you
instantiate an InitialContext object:

InitialContext.init(null) is called, which calls
ResourceManager.getInitialEnvironment(null)

At this point, ResourceManager is going to load any JNDI properties it can
find.  After getInitialEnvironment checks the system properties, it then
attempts to load application resources, by calling

ResourceManager.getApplicationResources()

This method will load resources with a ClassLoader of course, and it gets the
class loader from the current thread by calling
VersionHelper12.getContextClassLoader().  Because I am using Jdk12Interceptor,
it will return AdaptiveClassLoader.  This is where the important stuff
happens.  It will look for the JNDI properties file by calling getResources().
This is a final method on java.lang.ClassLoader that calls findResources()...

The JavaDoc states that ClassLoader implementations should override this method
to load resources.  AdaptiveClassLoader doesn't.  Why not? :)

I can submit a patch, but it looks like someone else already did awhile back...
I wondered why it wasn't applied, and thought maybe I missed something?  If I
patch is needed, let me know, I can get one to this list tonight...

Thanks again,
David

Rob S. wrote:

 If this is what I'm remembering, your ContextFactory class can't be found.
 This is cuz the JNDI code is broken in that it doesn't rely on its parent
 classloader (in our case, the one that knows about WEB-INF/classes and lib)
 to load the context factory.

 You have to implement your own InitialContextFactoryBuilder.  Check the Sun
 messages boards.  I ran into the same problem last month.

 - r

  -Original Message-
  From: David Haraburda [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, July 19, 2001 10:51 AM
  To: [EMAIL PROTECTED]
  Subject: AdaptiveClassLoader, getResources, jndi.properties (Tomcat
  bug?)
 
 
  Hi,
 
  I got no response to this message on the tomcat-user list, so I am
  trying here.  I could find nothing in the archives except the message I
  refer to below -- I apologize if this issue has been addressed and I
  just couldn't find the info...
 
  I am having problems with jndi.properties being read from my
  WEB-INF/classes directory.  I have seen this problem referenced once on
  the tomcat-dev mailing list -- someone submitted a patch, but apparently
 
  it did not get committed.  (I couldn't find a reason why, so I am not
  sure if that was the real solution to the problem or not).  The original
 
  message is here:
  http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg06588.html
 
  I have verified that the same behaivor he refers to is going on with my
  application -- InitialContext is using getResources(), which doesn't
  return anything becuase AdaptiveClassLoader doesn't implement
  findResource or findResources.
 
  Has anyone else having this problem found a solution/work-around?  Is
  there a Tomcat guru/developer out there who can explain why
  AdaptiveClassLoader doesn't implement findResources()?
 
  Thanks,
 
  David