This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Scenario: - Run Netbeans with C/C++ Pack only - Create new project - Push "File|New File..." menu item - Select "Other|HTML File" category and create file ==> "Warning" window appears with such message: --------------------------------------------------------------------------------------- The encoding ${ENCODING} specified in meta tag of the document newhtml.html is invalid. Do you want to load the file using UTF-8 encoding. ---------------------------------------------------------------------------------------
html files are not part of CND. Please refile against correct module....
what os locale are you in when it happens ? what project encoding is being used ?(see project properties) does it happen if create a web project and then a new html file ? ken.frank@sun.com
Linux en_US.UTF-8 This bug appears if I installed NetBeans with C/C++ Pack only.If I installed NetBeans with Java SE pack (with or without C/C++ Pack), then bug disappears. I can install Web pack without Java SE pack, therefore I cannot reproduce this bug in web projects.
I see this using all packs installed in the following situation: open template manager and choose the other->html or the web->html and the same popup appears. it happens also for jsp template file opened from template manager. (also the xml file template does not have encoding variable but new xml file itself does) when creating a new html file from a cnd project, it does not appear. thus perhaps the code that avoids this msg when actually creating the file is found in javase or web pack, but since cnd pack not have those, thats why it happens then when actually creates the html file ? but in any case it seems a valid issue even for case when template manager opens the file - and since project is in utf-8 encoding anyway or user started ide in utf-8 encoding, why should the message appear ? marking as p2 in this case. since the error message refers to ${encoding} rather than actual project encoding, perhaps the code is not consulting the feq or other encoding data ? ken.frank@sun.com
Could this be related to issue 129775 that Andrei is currently working on?
Marku, any idea what the problem could be? Thanks.
I can reproduce this problem on NB 6.0.1 (Web & Java EE distribution). Steps to reproduce: (1) menu Tools > Templates (2) select Other > HTML File (3) click button Open in Editor Warning window appears: "The encoding ${ENCODING} specified in meta tag of the document html.html is invalid. Do you want to load the file using UTF-8 encoding?" (Yes + No option)
Original HTML template contains the following line: <meta http-equiv="Content-Type" content="text/html; charset=${encoding}"> When opening template, the variable "${encoding}" is not replaced with some value (which is OK, because we want to edit template) and NB cannot resolve file encoding (don't know encoding "${encoding}"). The same happens when you want to save HTML template with the line above. (If you replace "${encoding}" with "UTF-8" and save the template, then next time when opening the template there will be no errors.) When new HTML file is created, the variable "${encoding}" is properly replaced: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> and there is no problem with the newly created file (at least on NB 6.0.1 Web & Java EE distribution). It seems to me that there are two problems: (1) Edit Template: the warning message should not be shown, encoding should be resolved somehow internally. The rule how to check file encoding should be applied only to new/opened files, not to templates (2) New/Open File: if encoding is not replaced properly (I was not able to reproduce this on NB 6.0.1 Web & Java EE) then it should be fixed
Variable replacement in template for new HTML file does not work on NB 6.1beta C++ distro. C++ file template: // // File: %<%NAME%>%.%<%EXTENSION%>% // Author: %<%USER%>% // // Created on %<%DATE%>%, %<%TIME%>% // After replacement (on C++ distro): // // File: newmain.cpp // Author: petr // // Created on March 31, 2008, 11:16 AM // HTML template: <!-- Document : ${name} Created on : ${date}, ${time} Author : ${user} --> After replacement (on C++ distro): <!-- Document : ${name} Created on : ${date}, ${time} Author : ${user} --> (no replacement was done)
It seems that C++ distro has some problem with freemarker lookup (freemarker not properly registered?)... Class org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler, method private static ScriptEngine engine(FileObject fo), contains the following code: Object obj = fo.getAttribute("javax.script.ScriptEngine"); // NOI18N ... if (manager == null) { manager = new ScriptEngineManager(); } ... return manager.getEngineByName((String)obj); parameter for manager.getEngineByName call is "freemarker". On C++ distro, the call returns null, so no replacements can be done. On Web & J2EE distro, the call returns instance of org.netbeans.libs.freemarker.FreemarkerEngine, so replacements are done correctly. Why freemarker is registered OK on Web & J2EE distro, but is not registered on C++ distro?
ScriptEngineManager on Web & J2EE distro has two engines registered: (1) RhinoScriptEngineFactory, and (2) FreemarkerFactory. However, ScriptEngineManager on C++ distro has only one engine registered: RhinoScriptEngineFactory... Freemarker is missing there...
The fix for this bug is to create dependency between HTML module and FreeMarker module. FreeMarker is part of C++ disrto.
Fixed. 0281b264a972
Verified at continuous build.
The fix was ported to release61 repository. http://hg.netbeans.org/release61/rev/b3f890dd0919
verified at release61 build.