[OpenLayers-Dev] Problem with Auto-Detection of Script Path (and not a 2.5 release-blocker!)

Christopher Schmidt crschmidt at metacarta.com
Mon Oct 8 16:42:14 EDT 2007


On Mon, Oct 08, 2007 at 03:19:55PM -0400, Peterson Eric-EEP002 wrote:
> I am building a J2EE application using OpenLayers, and I'm including the
> OL tree in the .WAR file I build for release. My app deploys just fine.
> When I get to the JSP that displays my map, I get weird errors - it
> seems like lib/OpenLayers.js is getting loaded correctly, but it doesn't
> load any of the other .js files.

I think the first mistake you're making is to include a non-single file
version of OpenLayers in what (sounds like) a deployment environment. I
can't say for sure, but you should really really really investigate
using a single file build for anything you expect other people to use.
(Not the least because the development build doesn't work in Safari half
the time.)

> I traced the problem in the _getScriptLocation() function. Specifically,
> after this line is executed:
>  
> var scripts = document.getElementsByTagName('script');
>  
> Then the "scripts" variable has only two entries in it, neither of which
> have anything to do with Open Layers. So the _getScriptLocation()
> function returns "", which gives the wrong path to the file-loading code
> later on in OpenLayers.js. I can see the <script> tags in the page
> source, but I'm completely confused as to why they're not loaded into
> the DOM structure by the time the OL code runs.

I don't know specifically why this is happening, but it might be due to
different types of HTML, DTD, etc. You might try saving the HTML rom
your Java app directly out to a file and seeing if you can reproduce it
in that way.

> Has anyone seen this issue before? Any ideas what might be causing this
> behavior? I have no problem patching each OL release before I
> incorporate it into my app, but I'd rather just use the plain vanilla OL
> code.

I highly recommend just using the single file build -- presumably after
crafting a build profile for your application, since that can cut up to
75% of the download size of OpenLayers -- and not using the development
build.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list