I have a question. How to you pass a data stream with XML using URL
connection object to test a servlet on Tomcat?
I am having problems in sending across this data stream to Tomcat.
Thanks
-----Original Message-----
From: William Kaufman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 10:04 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Class loader behavior with resource bundles...
I have only one guess: you've got the wrong package (or no package) in your
ListResourceBundle implementation,...
-- Bill K.
> -----Original Message-----
> From: James Lehmer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 20, 2001 6:48 PM
> To: [EMAIL PROTECTED]
> Subject: Class loader behavior with resource bundles...
>
>
> First off, if the following has an answer that's been posted
> before, my
> apologies. I searched the archives (and the Web in general)
> and didn't get
> any hits. Really. I swear! :-)
>
> I am going to try and be as detailed as possible, because it
> appears that it
> COULD be a Tomcat bug, since the behavior displayed is
> different depending
> on whether it's Tomcat under Windows 2000 or Linux. So bear
> with me, this is
> long. However, I'd appreciate any insight, if it is NOT a
> bug, as to why the
> behavior is different on those two platforms, and what we
> could have done to
> have mitigated it in the first place. Luckily, I found out
> how to fix the
> non-optimal behavior, but that just leaves me confused as to why, and
> nervous that we don't understand the environment as well as
> we should (what
> else is lurking to bite us?)
>
> o Tomcat version 3.1.1
> o Redhat 7.0 with up2date on everything within a week or so.
> o Windows 2000 SP1
> o JDK 1.3
>
> 1) I created a set of Java classes in a package, let's call
> it com.foo.bar.
> There are the main classes, some exception classes, and a
> ListResourceBundle
> class, FooListResourceBundle, for holding error messages used when an
> exception is thrown.
>
> 2) The main classes in com.foo.bar load the resource bundle
> in a static
> initializer as follows:
>
> /**
> *** Initialize error messages.
> **/
> static
> {
> try
> {
> msgs =
> java.util.ResourceBundle.getBundle("com.foo.bar.FooListResourc
> eBundle");
> }
> catch (Throwable t)
> {
> // Note that we can't throw our own exception here
> // (not allowed in static initializers).
> // See initializer() for where we DO throw the exception
> // if this didn't load correctly.
> }
> }
>
> As per the comments, the initializer method, called by all
> constructors,
> simply checks the msgs field for null, and throws an
> exception if it is so.
> This is how we know the problem exists later on.
>
> 3) Tested the library code using unit tests at the command
> line. Everything
> works great.
>
> 4) Published code to colleague who is doing actual servlet writing.
> Colleague is developing under Windows 2000, running Tomcat there. He
> installed my code (more on that in a bit), wrote his servlets
> to call it,
> tested it. Everything worked great.
>
> 5) Colleague published his code, along with mine, to QA. QA is running
> Tomcat under Linux (the final product distribution will be released on
> Linux). Right away, we get the first error, which is the
> exception from my
> main class that is thrown in the initializer method when it
> detects the
> resource bundle wasn't successfully loaded.
>
> 6) Started poking around. I delivered the code to my
> colleague in both jar
> and class file forms, he has decided to install it for his servlet as
> classes under WEB-INF/classes/com/foo/bar. The class loader
> is obviously
> finding the main class from there (since that class is
> throwing a custom
> exception because it can't find the resource bundle), so why
> can't it load
> the resource bundle class file, which is in the same package,
> from the same
> location?
>
> 7) After much hacking and poking around, I figure out that I
> can get past
> this if I create a properties file that has the appropriate
> contents in it,
> and place it under $TOMCAT_HOME/classes/com/foo/bar. Placing
> the class file
> there doesn't work. Only the properties file works (as far as
> loading is
> concerned, but read on). See java.util.ResourceBundle JDK
> docs if you don't
> know about being able to back a bundle with a properties file.
>
> 8) So, I think "that's weird", but am happy - kind of.
> Because (a) I still
> don't know WHY the class loader choked, and (b) the lack of
> problems lasts
> for about a day. Then I get a new bug from QA. This one
> occurs when my main
> class tries to throw an exception and tries to look up an
> error message from
> the resource bundle (which is now backed by the properties
> file, remember).
> In this case, the message is:
>
> Error: 500 Location: /you/go Internal Servlet Error:
> java.lang.ClassFormatError: com/foo/bar/FooListResourceBundle (Illegal
> constant pool index)
>
> Arg!
>
> 9) I do some more hacking around. Finally figure out that
> everything will
> work great if I use the jar file, Foo.jar, and place it in
> WEB-INF/lib. I
> also have to remove the existing class files from
> WEB-INF/classes/com/foo/bar, or otherwise the main class gets
> loaded from
> there first, and we are back to the symptoms in #5.
>
> So, wise ones on the list, I beseech thee! What were we doing
> wrong? Why
> can't the class loader load a resource bundle class file, in the same
> package, from the same location from which it's just loaded
> the main class
> that is using the bundle? Why did it work in the first place
> on Tomcat under
> Windows 2000, and not under Linux, for the same release of Tomcat?
>
> I am confused, and would appreciate ANY pointers to
> documentation that says,
> "Look, dummy, you're doing it wrong", so that I might adopt
> my best Colonel
> Foghorn Leghorn voice and mutter, "I see that I was
> mistaken." Otherwise,
> can someone confirm that verily, this does seem to be a bug?
> We will be
> upgrading to a later release of Tomcat soon (release
> timeframe pressures
> keep us from destabilizing the environment and doing so now),
> and if it is a
> bug, was it already known and has it been fixed?
>
> I appreciate any and all comments. Thanks.
>
> Jim
> ScienceXchange
>
> Dilbert: I *have* a personality!
> Dogbert: Let's not get into that "Is zero a number" debate again.
>