Make Zk WebApp OSGi

From iDempiere en


Start Point

I'm big fan of idempiere, special at technical, a lot things is new with me. OSGi, Zk, Buckminster, Jasper report,... at the moment, I want setup a web application same zk project in idempiere.

  • what's same? it's Web application has feature:
    • a plug-in project contain all library for zk web same org.zkoss.zk.library
    • a plug-in project contain web application same org.adempiere.ui.zk
    • and all deploy in embed web container Gemini, with a fragment project to config same org.adempiere.tomcat.config

I loss two day to finish it, because I will make a guideline for it to remember.

Start with guideline

google for guideline

I google a lot to find a complete guideline for (Zk + OSGi). This is my result Develop_ZK_application_in_OSGi_Framework

  • have two problem with this guideline:
    • it's out-date. for zk 5.
    • hasn't guideline for Gemini

I. read "Develop ZK Application" section, I can learn this:

1. make zk web app as normal plug-in.

2. add below text to MANIFEST.MF.

Web-ContextPath: /osgidemo
Webapp-Context: /osgidemo

3. add WEB-INF with two file zk.xml and web.xml

Check other article:

Detail about normal web as OSGi plug-in

Other article about setup normal web application

has a bit difference, sometime context with "/" some time without.

in practice, two way, with or without "/" is ok.

II. with Gemini we can use guideline Use Gemini


Practice with support of guideline

1. open eclipse, with new clear workspace 2. make plug-in project with name "vn.hsv.zk.library" 3. make new folder name lib in this project 4. download ZK OSGi latest Zk OSGi 7.0.1 extract file zk-bin-osgi-7.0.1.tar.gz, copy all file in zk-bin-osgi-7.0.1/dist/lib to folder lib in step 3 2.

Some know-how

Config Issue with DSP Loader

1. pre requirement

  • Using DSP file with a taglib
  • Place web in a project plug-in, lib of zk in other project (same idempiere and project in this guideline)

2. condition when have issue config use DSP as document DSP_Loader I test parameter "class-resource" with value is false same idempiere and true, It always make error file not found:

FNF dsp.web.core.jpg
FNF dsp.web.core.404.jpg

3. reason in file *.css.dsp we see line:

<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %>
<%@ taglib uri="http://www.zkoss.org/dsp/zk/core" prefix="z" %>
<%@ taglib uri="http://www.zkoss.org/dsp/web/theme"

see in zweb.*.jar have a file config.xml in metainfo.tld (* can is osgi rely what lib you use)

<config>
	<version>
		<version-class>org.zkoss.web.Version</version-class>
		<version-uid>7.0.1</version-uid>
	</version>
	<taglib>
		<taglib-uri>http://www.zkoss.org/dsp/web/core</taglib-uri>
		<taglib-location>/web/WEB-INF/tld/web/core.dsp.tld</taglib-location>
	</taglib>
	<taglib>
		<taglib-uri>http://www.zkoss.org/dsp/web/html</taglib-uri>
		<taglib-location>/web/WEB-INF/tld/web/html.dsp.tld</taglib-location>
	</taglib>
	<taglib>
		<taglib-uri>http://www.zkoss.org/dsp/web/theme</taglib-uri>
		<taglib-location>/web/WEB-INF/tld/web/theme.dsp.tld</taglib-location>
	</taglib>
</config>

see zweb.*.jar have all file tld in folder /web/WEB-INF/tld/web/

=> something wrong, because web container don't load file *.tld

4. solution

  • way of idempiere:

In web project plug-in, make folder tld/web below folder WEB-INF and put all file *.tld into

in library project, open MANIFEST.MF file, add "web.WEB-INF.tld.web" and "web.WEB-INF.tld.zk" into Export-Package area

 Export-Package: org.zkoss,
 .....
 web.WEB-INF.tld.web,
 web.WEB-INF.tld.zk

this way make MANIFEST.MF see as have error. but don't care, just ignore it

FNF dsp.web.core.manifest.jpg

5. update project to use zk 7 and jetty server https://bitbucket.org/hieplq/hsv-website branch zk7.jetty

Cookies help us deliver our services. By using our services, you agree to our use of cookies.