0

Can I use zkspringboot-starter with ZK10 jakarta and light client ?

asked 2024-02-15 01:22:24 +0800

YannUnil gravatar image YannUnil
51 1

updated 2024-02-15 21:28:29 +0800

I want to start a new ZK project with latest versions, i.e. :

  • JDK 21
  • Spring Boot 3.2.2
  • ZK 10.0.0-Beta-jakarta

And using ZK light client.

Can I use the zkspringboot-starter ?

It seems it pulls zkbind 9.6.0-jakarta (not ZK 10).

So when I use EL expressions in my ZUL it works fine, while according to the documentation EL expression should not be supported ?

I can explicitely override the dependency to load zkbind 10.0.0-Beta-jakarta but then I get exceptions like :

java.lang.NoSuchMethodError: 'boolean org.apache.commons.fileupload.servlet.ServletFileUpload.isMultipartContent(jakarta.servlet.http.HttpServletRequest)'

Below is my minimal configuration :

pom.xml :

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.2</version>
    <relativePath/>
</parent>

<properties>
    <java.version>21</java.version>
    <zkspringboot.version>3.2.1</zkspringboot.version>
    <zk.version>10.0.0-Beta-jakarta</zk.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.zkoss.zkspringboot</groupId>
        <artifactId>zkspringboot-starter</artifactId>
        <type>pom</type>
        <version>${zkspringboot.version}</version>
    </dependency>

    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>client-bind</artifactId>
        <version>${zk.version}</version>
    </dependency>

    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zkbind</artifactId>
        <version>${zk.version}</version>
    </dependency>

<dependencies>

Viewmodel :

public class MainVm {

    @Getter
    private String message = "HELLO WORLD";

}

ZUL file :

<zk>
    <nodom viewModel="@id('mainVm') @init('com.example.vm.MainVm')">
        <label value="${mainVm.message}"/>
    </nodom>
</zk>

ZK configuration :

@Configuration
public class ZkConfig {

    @PostConstruct
    public void zkConfig() throws Exception {
        WebApps.getCurrent().getConfiguration()
               .addListener(org.zkoss.clientbind.BinderPropertiesRenderer.class);
        Library.setProperty("org.zkoss.bind.defaultComposer.class", "org.zkoss.clientbind.ClientBindComposer");
    }

}

EDIT : Actually the exception also occurs when not using light client. The only way to get rid of it is to downgrade to zk 9.6.4-jakarta.

Thanks ! Best.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2024-02-23 14:09:48 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

Hey there, regarding the NoSuchMethodError: This is likely a conflict between commons-fileupload versions.

Latest ZK 10 has moved from commons-fileupload v1.5 to commons-fileupload2-javax v2.0.0-M2, or commons-fileupload2-jakarta-servlet5 depending on whether you are pulling the java or the jakarta version.

See here for more info about fileupload support in java / jakarta in latest ZK 10:

https://tracker.zkoss.org/browse/ZK-5393

Can you run a mvn dependency:tree command on your project, and check which commons-fileupload dependencies are loaded? If you see the old commons-fileupload v1.5, you may need to exclude it.

link publish delete flag offensive edit

Comments

Hi, I'm not sure I understand, indeed ZK-5393 is marked as solved in ZK 10.0.0-Beta release notes, but still ZK 10.0.0-Beta-jakarta pulls common-fileupload 1.5. I can exclude it and load commons-fileupload2-javax and commons-fileupload2-jakarta-servlet instead, but then I get ClassNotFoundException.

YannUnil ( 2024-02-23 19:22:08 +0800 )edit

it's not fixed in -Beta releases (beta was an earlier snapshot, before that fix was added). Try latest FL: 10.0.0-jakarta.FL.20240221 or 10.0.0.FL.20240221 (or the Eval repository versions: 10.0.0-jakarta.FL.20240221-Eval or 10.0.0.FL.20240221-Eval)

MDuchemin ( 2024-02-23 21:34:13 +0800 )edit

(it was packaged into the FLs since 2023/12/06)

MDuchemin ( 2024-02-23 21:35:25 +0800 )edit

Ahh yes of course, sorry for that, I was looking at https://mavensync.zkoss.org/maven2/org/zkoss/ and did not find latest FL versions. It works fine with 10.0.0-jakarta.FL.20240221, thanks !

YannUnil ( 2024-02-23 23:05:24 +0800 )edit
0

answered 2024-02-20 18:28:32 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2024-02-20 18:31:02 +0800

It seems it pulls zkbind 9.6.0-jakarta (not ZK 10).

it's the default setting. but you can exclude that zk version by yourself, if you want to use another version

    <dependency>
        <groupId>org.zkoss.zkspringboot</groupId>
        <artifactId>zkspringboot-starter</artifactId>
        <type>pom</type>
        <version>${zkspringboot.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zkbind</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

So that you can include a consistent version of all zk dependencies.

EL expression should not be supported ?

Only when you apply client mvvm to a scope, then inside that scope, EL is not supported. But for other scope, EL still works.

link publish delete flag offensive edit

Comments

Thanks, yes I can exclude that zkbind version to get only consistent ZK10 dependencies. Unfortunately I still get the NoSuchMethodError exception. I can reproduce it in a minimal application. I can share the project if needed. About the EL expressions, I had applied the library property globally.

YannUnil ( 2024-02-22 20:49:54 +0800 )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: 2024-02-15 01:22:24 +0800

Seen: 12 times

Last updated: Feb 23

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