Share February 2009: Project of the Month

ZK - Simply Ajax and Mobile

Tracker: Bugs

5 zk.xml is loaded before /metainfo/zk/config.xml - ID: 2269206
Last Update: Comment added ( gback )

Hi,

I'm trying to use the <zscript-config> element in WEB-INF/zk.xml to install
my own interpreter-class for the Java language.

However, this setting is not respected. When I placed a stack trace dump in
Interpreters.java's add method, I found that it is overwritten by the
<interpreter-class> setting that is part of the /metainfo/zk/config.xml
file that is bundled with zk.jar. (My zk.jar is in WEB-INF/libs). In other
words, the settings in zk.jar:/metainfo/zk/config.xml are read AFTER the
settings in zk.xml, making zk.xml useless.

How do I resolve this? Do I need to remove the /metainfo/zk/config.xml file
from zk.jar?

Thanks!


Godmar Back ( gback ) - 2008-11-12 12:23

5

Deleted

Wont Fix

Nobody/Anonymous

General

2.4.1

Public


Comments ( 6 )

Date: 2008-11-19 01:06
Sender: gback

thank you, Tom.


Date: 2008-11-19 00:57
Sender: tomyehProject Admin

Workaround:

Provide a file at WEB-INF/classes/metainfo/zk/config.xml
Note: you have to specify depends to ensure it was loaded after the other
module.

<config>
<config-name>MyApp</config-name>
<depends>zk,zkmax</depends>
<zscript-config>
<language-name>Java</language-name>
<interpreter-class>org.zkoss.zk.scripting.bsh.BSHInterpreter</interpreter-class>
</zscript-config>
</config>


Date: 2008-11-18 07:16
Sender: tomyehProject Admin

It was fixed since ZK 3.5 by introducing additional phase to parse
config.xml before zk.xml (and then lang.xml).

ZK 2.4 is under minimal maintenance, so it won't be fixed.


Date: 2008-11-14 17:37
Sender: gback

Please find attached the log I obtained if I add this code:

public static final String add(Element config) {
//Spec: it is OK to declare an nonexist interpreter, since
//deployer might remove unused jar files.
final String zslang =
IDOMs.getRequiredElementValue(config, "language-name");
final String clsnm =
IDOMs.getRequiredElementValue(config, "interpreter-class");
System.out.println("now adding: language=" + zslang + " class=" +
clsnm);
System.out.print("Called from: ");
new Throwable().printStackTrace();
return add(zslang, clsnm);
}

This is with Apache Tomcat 6.0.18 and ZK 2.4.1 (sorry for providing the
wrong version - could that behavior have changed?)

File Added: log-of-wrong-initialization.txt


Date: 2008-11-14 13:15
Sender: gback

Did you place zk.jar in the WEB-INF/lib directory of your web application
or did you place it in the tomcat/lib directory?



Date: 2008-11-14 07:20
Sender: tomyehProject Admin

Unable to replicate the problem. It works correctly.

I tried to add the following setting in zk.xml
<zscript-config>
<language-name>Javax</language-name>
<interpreter-class>org.zkoss.zk.scripting.bsh.BSHInterpreter</interpreter-class>
</zscript-config>


and here is what I saw (line 140, Interpreters.java)

add Java, org.zkoss.zk.scripting.bsh.BSHInterpreter
add JavaScript, org.zkoss.zkmax.scripting.rhino.RhinoInterpreter
add Groovy, org.zkoss.zkmax.scripting.groovy.GroovyInterpreter
add Ruby, org.zkoss.zkmax.scripting.jruby.JRubyInterpreter
add Python, org.zkoss.zkmax.scripting.jython.JythonInterpreter
add Javax, org.zkoss.zk.scripting.bsh.BSHInterpreter



Attached File ( 1 )

Filename Description Download
log-of-wrong-initialization.txt initialization log Download

Changes ( 5 )

Field Old Value Date By
status_id Open 2008-11-18 07:16 tomyeh
resolution_id None 2008-11-18 07:16 tomyeh
close_date - 2008-11-18 07:16 tomyeh
File Added 301387: log-of-wrong-initialization.txt 2008-11-14 17:37 gback
artifact_group_id 3.5.1 2008-11-14 17:37 gback