0

ELException in zk9 importing a class

asked 2019-12-17 06:42:17 +0800

JustinFrost gravatar image JustinFrost
145 1 6

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 ?

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2019-12-17 16:05:08 +0800

cor3000 gravatar image cor3000
5262 2 7
ZK Team

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.

link publish delete flag offensive edit

Comments

Thanks for your response - more details in my answer below.

JustinFrost ( 2019-12-20 10:10:19 +0800 )edit
0

answered 2019-12-20 10:09:36 +0800

JustinFrost gravatar image JustinFrost
145 1 6

Thanks @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.

link publish delete flag offensive edit
0

answered 2019-12-20 10:58:12 +0800

cor3000 gravatar image cor3000
5262 2 7
ZK Team

updated 2020-03-13 15:37:08 +0800

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))

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2019-12-17 06:42:17 +0800

Seen: 19 times

Last updated: Mar 13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More