From: Fencer on
On 2010-01-27 16:48, Fencer wrote:
> On 2010-01-27 16:02, Fencer wrote:
>> Hello, I have a problem with getResourceAsStream().
> [snip my OP]
>
> I believe I solved this problem!
>
> - Fencer

Hello again. I wish to offer my sincere apologies for not specifying the
details of my solution in my previous post.

The problem turned out to be not in the actual Java code but in how I
was using my tools. Adding a directory to the classpath in the Eclipse
project settings didn't propagate to Tomcat in my context. What I did
was to add the directory to the classpath to Tomcat's launch
configuration under Eclipse. That solved it!

If you you doubleclick on the Tomcat server under the Server tab (in the
window that usually holds tabs like console, problems etc, I'm not sure
what it's called), an "Overview" of settings should open. There's a link
there "Open Launch Configuration" which opens a configuration dialog.
The dialog has a tab called "classpath" and you can add your entry
there, under "User Entries".

Again, I apologise for not writing this the first time around and thanks
to those who reminded me to do so.

- Fencer
From: Lew on
On Jan 28, 10:26 am, Fencer <no.i.d...(a)want.mail.from.spammers.com>
wrote:
> On 2010-01-27 16:48, Fencer wrote:
>
> > On 2010-01-27 16:02, Fencer wrote:
> >> Hello, I have a problem with getResourceAsStream().
> > [snip my OP]
>
> > I believe I solved this problem!
>
> > - Fencer
>
> Hello again. I wish to offer my sincere apologies for not specifying the
> details of my solution in my previous post.
>
> The problem turned out to be not in the actual Java code but in how I
> was using my tools. Adding a directory to the classpath in the Eclipse
> project settings didn't propagate to Tomcat in my context. What I did
> was to add the directory to the classpath to Tomcat's launch
> configuration under Eclipse. That solved it!
>
> If you you doubleclick on the Tomcat server under the Server tab (in the
> window that usually holds tabs like console, problems etc, I'm not sure
> what it's called), an "Overview" of settings should open. There's a link
> there "Open Launch Configuration" which opens a configuration dialog.
> The dialog has a tab called "classpath" and you can add your entry
> there, under "User Entries".
>

You're supposed to include libraries needed by a web app in the "lib/"
directory of the web app.

You shouldn't entirely depend on the IDE to specify a class path. You
should be able to deploy the application from the command line.

--
Lew
From: Fencer on
On 2010-01-28 20:29, Lew wrote:
>>
>
> You're supposed to include libraries needed by a web app in the "lib/"
> directory of the web app.
>
> You shouldn't entirely depend on the IDE to specify a class path. You
> should be able to deploy the application from the command line.

Thanks for your reply, Lew, and you make a dood point. There are several
jar-files in my WebContent->WEB-INF->lib folder, but if I put my XQuery
file in there, getResourceAsStream() doesn't find it :(

If I could make it work without adding a directory to classpath like I'm
doing that would be even better!

- Fencer
From: Lew on
Fencer wrote:
> Thanks for your reply, Lew, and you make a dood point. There are several
> jar-files in my WebContent->WEB-INF->lib folder, but if I put my XQuery
> file in there, getResourceAsStream() doesn't find it :(
>
> If I could make it work without adding a directory to classpath like I'm
> doing that would be even better!

There are already several directories in your class path for a web app.

Is your "XQuery file" a JAR? No? Then it doesn't go in the "lib/" directory.

The root directory of your application ("application-name/") and the classes
directory ("application-name/WEB-INF/classes/") are already in your path. Put
your resource relative to one of those.

--
Lew
From: Roedy Green on
On Thu, 28 Jan 2010 16:26:34 +0100, Fencer
<no.i.dont(a)want.mail.from.spammers.com> wrote, quoted or indirectly
quoted someone who said :

>
>Again, I apologise for not writing this the first time around and thanks
>to those who reminded me to do so.

Thank you for sharing your solution rather than getting defensive as a
normal person would.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Computers are useless. They can only give you answers.
~ Pablo Picasso (born: 1881-10-25 died: 1973-04-08 at age: 91)