Thanks for your response - more details in my answer below.
JustinFrost ( 2019-12-20 10:10:19 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
We have an import statement on our zul page to import an Enum, since upgrading to zk9 we are getting an exception when we go to this page:
zul:
<?import com.enumerators.MyEnum?>
Exception:
org.zkoss.zel.ELException: The class [enumerators.MyEnum] could not be imported as it conflicts with [org.zkoss.zel.ImportHandler$NotFound] which has already been imported
Has anyone else come across this issue ?
The error you encounter seems related to ZK-4200, where the ImportHandler$NotFound
marker class was introduced to cache dynamic class loading failures (avoiding exceptions).
From what I can see it tries to load a class missing the com.
package prefix.
I tried several ideas but could not reproduce the sequence leading to this error. Can you please provide a more complete reproducing example?
If you can't share code in public, please contact our support.
Thanks for your response - more details in my answer below.
JustinFrost ( 2019-12-20 10:10:19 +0800 )editThanks @cor3000.
I believe this is a timing issue. It is not happening all the time for us, but I believe it happens when an Enum is referenced in a binding before the import statement is called.
The binding statement causes the enum name to execute resolveClass in ImportHandler and then since it cannot find it - it stores it in the map as NotFound.class.
When the import statement is run from the zul it then gets a conflict with the NotFound class from above.
Reproduced here:
http://zkfiddle.org/sample/1e8gaj7/14-EL-exception-on-import
What is the suggested work around here - when does the import statement run compared to the load bindings ?
Thanks.
Thanks for your clarifying/reproducing example. The import can only be executed when the included zul file is loaded. So the @load binding in your example is executed before processing the import.
An workaround idea is to pre-import the commonly used classes at application startup.
public class ImportInit implements WebAppInit {
@Override
public void init(WebApp wapp) throws Exception {
ImportHandler.getImportHandler().importClass(MyEnum.class.getName());
...
}
}
And configure this class in zk.xml as a listener-element:
<listener>
<listener-class>my.package.ImportInit</listener-class>
</listener>
UPDATE: issue ZK-4468
UPDATE 2: fixed in 9.0.1 (since 9.0.1.FL.20200310(-Eval)
)
Asked: 2019-12-17 06:42:17 +0800
Seen: 20 times
Last updated: Mar 13 '20