0

After I added f:ajax tag to one of my pages, tomcat automatically inserted jsf.js script into header:

<script type="text/javascript" src="<app-name>/javax.faces.resource/jsf.js.jsf?ln=javax.faces&amp;stage=Development">

it started causing some weird errors in IE on page loading. Most amazing is that each time page is reloaded the number of errors and places they occurred may differ, sometimes significantly. Should I mention that in Chrome everything loads without any problems?

    SCRIPT5007: Unable to get value of the property '_mfClazz': object is null or undefined 
jsf.js.jsf?ln=javax.faces&stage=Development, line 734 character 13
SCRIPT5009: '_MF_OBJECT' is undefined 
_HtmlStripper.js.jsf?ln=org.apache.myfaces.core.impl.util, line 28 character 1
SCRIPT5009: '_MF_OBJECT' is undefined 
_AjaxUtils.js.jsf?ln=org.apache.myfaces.core.impl.xhrCore, line 27 character 1
SCRIPT5007: Unable to get value of the property 'engine': object is null or undefined 
Xhr1.js.jsf?ln=org.apache.myfaces.core.impl.xhrCore, line 29 character 1
SCRIPT5009: '_MF_OBJECT' is undefined 
_Queue.js.jsf?ln=org.apache.myfaces.core.impl.util, line 25 character 1
SCRIPT5007: Unable to get value of the property '_mfClazz': object is null or undefined 
jsf.js.jsf?ln=javax.faces&stage=Development, line 720 character 15
SCRIPT5007: Unable to get value of the property '_mfClazz': object is null or undefined 
jsf.js.jsf?ln=javax.faces&stage=Development, line 720 character 15
SCRIPT5007: Unable to get value of the property 'engine': object is null or undefined 
IFrame.js.jsf?ln=org.apache.myfaces.core.impl.xhrCore, line 27 character 1
SCRIPT5009: '_MF_OBJECT' is undefined 
_AjaxRequest.js.jsf?ln=org.apache.myfaces.core.impl.xhrCore, line 32 character 1
SCRIPT5009: '_MF_OBJECT' is undefined 
_AjaxResponse.js.jsf?ln=org.apache.myfaces.core.impl.xhrCore, line 32 character 1
AndreiM
  • 4,406
  • 2
  • 18
  • 20

1 Answers1

2

Its not tomcat who is adding the jsf.js , its the jsf implementation library (in your case myfaces) read this one ()What can cause “jsf is not defined” error in browser console

so its normal

regarding your errors , maybe you got some illegal html structure? like nested forms? what version of myfaces are you using ? is it official rls version ? try a more recent one

another option would be to try to add the js file manually (just to see if its any good) like this

<h:outputScript name="jsf.js" library="javax.faces" target="head"/>
Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • Thanks for the response. I'm using latest version of myfaces (2.1.8); I'm pretty sure that there are no nested forms. Also, those errors happen at the time of initial JS load, before document is loaded. I will try some simple page though to see if it will help. – AndreiM Aug 23 '12 at 19:00
  • b.t.w if you change your PROJECT_STAGE mode in `web.xml` to from `Development` to `Production` , does solve those issues? – Daniel Aug 23 '12 at 19:07
  • Yes it did solve the problem! The errors are gone... should I permanently switch to Production mode? what was supposed to be the difference between those? – AndreiM Aug 23 '12 at 19:52
  • well , while in `Development` mode you will get some notification regarding various errors that you `better` fix (for example duplicate ids that are cause by using c:foreach sometimes) , eventually when you deploy your app in production server you must switch the PROJECT_STAGE to Production , in your particular case I really dunno why you are getting those specific errors (you might consider asking that in myfaces mailing list if you wont get exact answer in stackoverflow) – Daniel Aug 23 '12 at 20:23
  • you also might try a previous myfacase jsf implementation - 2.1.7 to see if its a bug in 2.1.8 – Daniel Aug 23 '12 at 20:25