1. Is your app running in Direct Connect mode?
Running in Direct Connect mode bypasses your web (HTTP) server; therefore, images in the web server's document root directory won't load. You're probably using Direct Connect mode if your URL contains a port number, i.e.:
http://localhost:4398/...
This is the default mode in WebObjects. If you are using Direct Connect, when you view your application's HTML source (with the browser View Source command), your IMG tags will have this format:
<IMG src="/cgi-bin/WebObjects.exe/ImageTest.woa/wr?wodata=pathname">
There are two ways to fix these broken images:
2. Look for correctly formed IMG tags
Use your browser's View Source command to see the HTML that is being sent to the browser. (This alone is a handy troubleshooting tip that is often overlooked.)
A correctly formed IMG tag will look something like this:
<IMG src="/WebObjects/ImageTest.woa/WebServerResources/foo.jpg">
If your image tags are missing some of the components:
<IMG src="/WebObjects/ImageTest/foo.jpg">
then you should take the following steps:
Please note that the default NSProjectSearchPath is "(../..)", which is relative to the application executable. When running from the source directory, "../.." is usually one level up from the PB.project. The resource manager then searches all subdirectories for a directory matching PROJECTNAME, and looks in there for resources. If one is found, it prepends the value of WOApplicationBaseURL to its pathname to get something like "/WebObjects/ImageTest/foo.jpg".
After changing NSProjectSearchPath, it is sometimes necessary to rebuild using the "install" target.
3. Look for error messages in the IMG tags
When you view your document source, your IMG tags may look like this (for a Direct Connect application):
<IMG src="/cgi-bin/WebObjects.exe/ImageTest.woa/wr?wodata=ERROR_NOT_FOUND_framework_*nil*_filename_foo.jpg">
or like this (for a non-Direct Connect application):
<IMG src="/ERROR/NOT_FOUND/app=ImageTest/filename=foo.jpg">
To fix either of these problems, take the following steps:
4. Is the correct image displayed?
Sometimes you may see the wrong image displayed correctly, or an image with the correct filename but from a different directory. These problems can usually be corrected by setting NSProjectSearchPath. You may use the launch option "-NSProjectSearchPath "()"", or the command-line "defaults write MyAppName NSProjectSearchPath "()"".
This problem happens when you have two copies of a project in a common directory. Even if the two projects are in subdirectories with different names, they will have the same internal name (identified by PROJECTNAME in the PB.project file), and the resource manager can't tell the difference unless NSProjectSearchPath is set.