Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm moving a ZK standard Spring application to Spring Boot .

I have a problem with the CKEditor configuration. I'm using external plugins, below is the configuration :

CKEDITOR.plugins.addExternal('wordcount', 'plugins/wordcount/', 'plugin.js');
CKEDITOR.plugins.addExternal('notification', 'plugins/notification/', 'plugin.js');
CKEDITOR.editorConfig = function (config) {
    config.extraPlugins = 'wordcount,notification';
    config.mytoolbar = [ ... ]
    config.wordcount = { ... };

With old standard Spring application, I had it configured that way :

1 - plugins (wordcount and notification folders) put in src/webapp/zkpatch/js/ckez/ext/CKeditor/plugins

2 - ckeditor configuration file (config.js) put in src/webapp/js

3 - In zk.xml :

<library-property>
    <name>org.zkoss.web.util.resource.dir</name>
    <value>/zkpatch</value>
</library-property>

4 - in ZUL file :

<ckeditor customConfigurationsPath="/js/config-ckeditor.js" value="@load(vm.myvalue)"/>

This worked perfectly.

With Spring Boot, resources location has changed so I use the following :

1 - plugins (wordcount and notification folders) put in src/resources/web/zul/js/ckez/ext/CKeditor/plugins

2 - ckeditor configuration file (config.js) put in src/resources/static/js

3 - in ZUL file :

<ckeditor customConfigurationsPath="/js/config-ckeditor.js" value="@load(vm.myvalue)"/>

But I get the following error (ZK popup) when reaching the page :

/js/ckez/ext/CKeditor/plugins/wordcount/plugin.js not found

I can see from the page source that the plugin JavaScript file is correctly loaded, there is also a TypeError: k is null error in the browser console.

Where do I need to move the custom plugin folders so that they can be found by Spring Boot ?

EDIT 1

I miss-typed some paths above, I of course use src/main/resources and not src/resources, and CKEditor plugin folders have been put in src/resources/web/js/ckez/ext/CKeditor/plugins (not in the zul folder).

I forgot to mention that we are using a custom application initializer to support custom scopes (one of my colleague opened an issue here https://github.com/zkoss/zkspringboot/issues/7).

We're using Java 11, ZK 8.6.0, and the zkspringboot 1.0.3 starter with Spring boot 2.0.5.RELEASE (I tried last 2.1.0 but it seems it is not compatible with your starter yet, btw it would be nice to be able to use 2.1.0 release for production as it officially support java 11).

EDIT 2

Undertow is configured with HTTPS and HTTP/2.

When reaching the application directly (https://locahost:8443/myapp) I indeed don't get any problem, CKEditor is loading fine.

I just noticed that the problem occurs when I use a front Apache server with AJP (https://locahost/myapp), then the CKEditor fail to load with the above error message. I can see from the browser network tab that I also get code 403 for some static resources (custom js/css).

Apache configuration is very basic :

ProxyPass "/myapp" "ajp://localhost:8009/myapp"
ProxyPassReverse "/myapp" "ajp://localhost:8009/myapp"

Undertow configuration too :

@Configuration
public class UndertowEmbeddedAjpConfiguration {
    public UndertowEmbeddedAjpConfiguration() { }
    @Bean
    public UndertowServletWebServerFactory undertowServletWebServerFactory() {
        final UndertowServletWebServerFactory undertow = new UndertowServletWebServerFactory();
        undertow.addBuilderCustomizers((UndertowBuilderCustomizer) builder -> {
            builder.addAjpListener(8009, "localhost");
        return undertow;

I know AJP is out of fashion, unfortunately this is a requirement for us as we are forced to use Shibboleth SSO for all our applications, which requires AJP...

I can provide a ready to use Docker version if necessary.

EDIT 3

The problem finally went away after I upgraded some dependencies. Unfortunately, I didn't notice which ones since I realized several weeks later after multiple deployments...

as already commented on zkspringboot/issues/7 so far it is not blocking - just keep using the xml config approach until a more convenient java config based method is available. We'll address this once we upgrade zkspring to use spring 5 (since the original way still works, there's no high urgency to do so) – cor3000 Dec 5, 2018 at 3:04 hmm I think I can't say much about the undertow / AJP specific challenges - (I am working for ZK). At least not without doing further tests. I'll be on vacation for a week, so maybe someone else in the springboot/undertow community can take over with the configuration specifics. Otherwise if the days are quiet during the xmas time I might have to time to try your scenario. I'd suggest to – cor3000 Dec 7, 2018 at 8:35 I'd suggest to test the resource urls manually and observe the network traffic to see where they are going and at what point they fail. – cor3000 Dec 7, 2018 at 10:31 I have to keep moving forward on the project but I will try to get back to the problem next week and implement a minimal ready-to-use Docker container so that everyone can reproduce the problem easily. We have full ZK EE licenses so I could have made a ticket too, but I like to share questions here for the community, and so that it better publicize ZK which is really an awesome tool :) – Yann39 Dec 7, 2018 at 14:03

That's going to be tough to untangle but I'll try.

The extra folder configured by "org.zkoss.web.util.resource.dir" has never been necessary. And is really just useful for patches, as you can only configure one of these.

The old/original place to put resources is into the package folder src/main/resources/web (or as you probably using a non default src/resources/web) - Thats what you'll see when looking into any of the ZK jars ... this mechanism has always been available to anyone.

So there's nothing new in a Spring Boot application the difference is that the WEB-INF folder is not available when building a spring boot application as a jar-file.

I assume it's just a typo in your config:

1 - plugins (wordcount and notification folders) put in src/resources/web/zul/js/ckez/ext/CKeditor/plugins

ckeditor will search for the plugins in the classpath folder web/js/ckez/ext/CKeditor/plugins no zul in between just follow the same structure as in the ckez.jar

That should fix the error /js/ckez/ext/CKeditor/plugins/wordcount/plugin.js not found.

Maybe that's already all you need.

For additional trouble shooting I'd suggest to look into the Browsers developer tools - Network tab. This will give you better (than just the page source) information about which path is used to load files, and how the server responds.

Thanks for the clarification on some points. Sorry I have miss-typed some paths in the question. Actually I indeed use src/main/resources and not src/resources, and plugin folders are of course in src/main/resources/web/js/ckez/ext/CKeditor (not in the zul folder). Anyway wherever I put the js/ckez/... folder I still get the error. Looking at the network tab I have a GET request https://localhost/myapp/zkau/web/js/ckez/ext/CKeditor/plugins/wordcount/plugin.js?t=H4P with response (window.zk&&zk.error?zk.error:alert)('/js/ckez/ext/CKeditor/plugins/wordcount/plugin.js not found'); – Yann39 Dec 3, 2018 at 10:40

I based my test on the zkspringboot-demo-jar example

Another Hint: I released zkspringboot-starter 1.0.4 just 5 days ago, it uses spring boot 2.1.0. In any case the -starter is meant to get started quickly, it doesn't mean you're stuck with it. The zkspringboot-autoconfig dependency enables you to use your own springboot-starter-web parent version (or dependency) and just add the ZK specific config on top - it's all maven after all with all it's flexibility (and pain). It's mostly orthogonal to springboot. It's more like running the same ZK application on tomcat 7/8/8.5 or 9 or jetty - the container may change, still the configuration be it a web.xml or a spring java config remains the same.

Thank you for your time, it is really appreciated. I think I see the problem now, I have updated the original question again. – Yann39 Dec 5, 2018 at 17:20

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.