Thursday, 28 January 2016

Liferay Themes

This is a followup of the blog entry about Liferay1 2 3.

As I wished to tailor the website layout of my Liferay instance, I started looking at themes. What I found was a bit of a surprise for me, as it seems themes for Liferay needs to be compiled/build using ant or maven.

There is a big body of documentation regarding the creation of Themes, but the procedure seems a bit brittle. It uses ant, needs to be able to reach the files of the classic theme, is dependent of the type of Application Server you are using, and a bit of other stuff.

Below are some of the error messages I got and had to solve before I got anything that worked.

Creating a Theme with Ant

  • Download the Plugins SDK that compiles new themes (and plugins) using Ant.
  • Create a properties file like build.<username>.properties
    [glassfish@localhost glassfish]$ cat liferay-plugins-sdk-6.2/
  • In this directory, there should be a directory themes, where we can create our new theme6.
    [glassfish@localhost themes]$ ./ mine "Mine"
    Parallel execution with configuration on demand is an incubating feature.


    Total time: 2.377 secs
  • Changed the build.xml in mine-theme, to use 'classic' as the parent theme.
    <property name="theme.parent" value="classic" />
    If you create your own theme with the Plugins SDK, place the icon in themes/Your_theme/docroot/_diffs/images/favicon.ico if you want to have your own favicon to bookmark.
  • Then "ant war"
  • Then "ant deploy" (or just copy the war into glassfish4/deploy)
The first problem I ran into was a problem with the xml file.
[2015-09-19T20:45:06.136+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506136] [levelValue: 800] [[
20:45:06,136 INFO  [AutoDeployer][HotDeployEvent:145] Plugin mine-theme requires marketplace-portlet]]

[2015-09-19T20:45:06.142+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506142] [levelValue: 800] [[
20:45:06,136 INFO  [AutoDeployer][HotDeployImpl:217] Deploying mine-theme from queue]]

[2015-09-19T20:45:06.149+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506149] [levelValue: 800] [[
20:45:06,142 INFO  [AutoDeployer][PluginPackageUtil:1016] Reading plugin package for mine-theme]]

[2015-09-19T20:45:06.193+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.web] [tid: _ThreadID=140 _ThreadName=AutoDeployer] [timeMillis: 1442695506193] [levelValue: 800] [[
WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext]]

[2015-09-19T20:45:06.204+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506204] [levelValue: 800] [[
20:45:06,204 INFO  [AutoDeployer][ThemeHotDeployListener:98] Registering themes for mine-theme]]

[2015-09-19T20:45:06.236+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506236] [levelValue: 800] [[
20:45:06,228 ERROR [AutoDeployer][ThemeLocalServiceImpl:278] com.liferay.portal.kernel.xml.DocumentException: Error on line 8 of document  : Element type "theme" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "theme" must be followed by either attribute specifications, ">" or "/>".
com.liferay.portal.kernel.xml.DocumentException: Error on line 8 of document  : Element type "theme" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "theme" must be followed by either attribute specifications, ">" or "/>".
at com.liferay.portal.service.impl.ThemeLocalServiceImpl._readThemes(
at com.liferay.portal.service.impl.ThemeLocalServiceImpl.init(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(
at com.sun.proxy.$Proxy269.init(Unknown Source)
at com.liferay.portal.service.ThemeLocalServiceUtil.init(
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(
at org.apache.catalina.core.StandardContext.contextListenerStart(
at com.sun.enterprise.web.WebModule.contextListenerStart(
at org.apache.catalina.core.StandardContext.start(
at com.sun.enterprise.web.WebModule.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(
at com.sun.enterprise.web.WebContainer.loadWebModule(
at com.sun.enterprise.web.WebContainer.loadWebModule(
at com.sun.enterprise.web.WebApplication.start(
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
at org.glassfish.deployment.admin.DeployCommand.execute(
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$
at Method)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(
at com.sun.enterprise.v3.admin.CommandRunnerImpl$
at com.sun.enterprise.v3.admin.CommandRunnerImpl$
at Method)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(
at org.glassfish.deployment.autodeploy.AutoDeployService$
at java.util.TimerThread.mainLoop(
Caused by: org.dom4j.DocumentException: Error on line 8 of document  : Element type "theme" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "theme" must be followed by either attribute specifications, ">" or "/>".

[2015-09-19T20:45:06.236+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=140 _ThreadName=Thread-8] [timeMillis: 1442695506236] [levelValue: 800] [[
... 82 more]]
Seems the problem was Quotes (") around the name of the theme "Mine" in the docroot/WEB-INF/ file. Removed quotes, and things get picked up now.

Creating a Theme with Maven

mvn archetype:generate \
    -DarchetypeArtifactId=liferay-theme-archetype \
    -DarchetypeGroupId=com.liferay.maven.archetypes \
    -DarchetypeVersion=6.1.0 \
    -DartifactId=sample-theme \
    -DgroupId=com.liferay.sample \
I tried with Maven4 5 instead of Ant to develop a theme, but I couldn't rightly get it to work. Needs some time to work on it.

Uploading a theme

So there's a war file created containing the files. You can deploy the file into the application server.

There are several ways to do this. You can upload it to glassfish4/glassfish/domains/domain1/autodeploy.

But I find that in some cases the theme is not recorded by Liferay. Liferay listens to specific directories for new war files that are theme related. In my case the additional directory could well be glassfish4/deploy, because glassfish4 is the "home" of Liferay in my case.

You can verify if the theme was successfully picked up in your glassfish server log. You should see something lke:
[2016-01-11T14:38:26.668+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523106668] [levelValue: 800] [[
14:38:26,667 INFO  [][AutoDeployDir:204] Processing mine-theme-]]

[2016-01-11T14:38:26.673+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523106673] [levelValue: 800] [[
14:38:26,673 INFO  [][ThemeAutoDeployListener:51] Copying themes for /home/glassfish/glassfish4/deploy/mine-theme-]]

[2016-01-11T14:38:26.723+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523106723] [levelValue: 800] [[
14:38:26,722 INFO  [][BaseDeployer:863] Deploying mine-theme-]]

[2016-01-11T14:38:27.119+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107119] [levelValue: 800] [[
Expanding: /home/glassfish/glassfish4/deploy/mine-theme- into /tmp/20160111143826861]]

[2016-01-11T14:38:27.563+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107563] [levelValue: 800] [[
Copying 1 file to /tmp/20160111143826861/WEB-INF]]

[2016-01-11T14:38:27.568+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107568] [levelValue: 800] [[
Copying 1 file to /tmp/20160111143826861/WEB-INF]]

[2016-01-11T14:38:27.581+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107581] [levelValue: 800] [[
Copying 1 file to /tmp/20160111143826861/WEB-INF/classes]]

[2016-01-11T14:38:27.589+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107589] [levelValue: 800] [[
Copying 1 file to /tmp/20160111143826861/WEB-INF/classes]]

[2016-01-11T14:38:27.606+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107606] [levelValue: 800] [[
Copying 1 file to /tmp/20160111143826861/WEB-INF]]

[2016-01-11T14:38:27.760+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107760] [levelValue: 800] [[
14:38:27,760 INFO  [][BaseDeployer:2391] Modifying Servlet 2.4 /tmp/20160111143826861/WEB-INF/web.xml]]

[2016-01-11T14:38:27.860+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523107860] [levelValue: 800] [[
Building war: /tmp/20160111143827761]]

[2016-01-11T14:38:28.307+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523108307] [levelValue: 800] [[
Deleting directory /tmp/20160111143826861]]

[2016-01-11T14:38:28.331+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=112 _ThreadName=Thread-8] [timeMillis: 1452523108331] [levelValue: 800] [[
14:38:28,330 INFO  [][ThemeAutoDeployListener:57] Themes for /home/glassfish/glassfish4/deploy/mine-theme- copied successfully. Deployment will start in a few seconds

[2016-01-11T14:38:29.675+0000] [glassfish 4.1] [INFO] [NCLS-DEPLOYMENT-02027] [] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523109675] [levelValue: 800] [[
Selecting file /home/glassfish/glassfish4/glassfish/domains/domain1/autodeploy/mine-theme.war for autodeployment]]

[2016-01-11T14:38:30.239+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523110239] [levelValue: 800] [[
visiting unvisited references]]

[2016-01-11T14:38:31.349+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=Thread-8] [timeMillis: 1452523111349] [levelValue: 800] [[
14:38:31,348 INFO  [AutoDeployer][HotDeployEvent:145] Plugin mine-theme requires marketplace-portlet]]

[2016-01-11T14:38:31.350+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=Thread-8] [timeMillis: 1452523111350] [levelValue: 800] [[
14:38:31,349 INFO  [AutoDeployer][HotDeployImpl:217] Deploying mine-theme from queue]]

[2016-01-11T14:38:31.350+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=Thread-8] [timeMillis: 1452523111350] [levelValue: 800] [[
14:38:31,350 INFO  [AutoDeployer][PluginPackageUtil:1016] Reading plugin package for mine-theme]]

[2016-01-11T14:38:31.404+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.web] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523111404] [levelValue: 800] [[
WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext]]

[2016-01-11T14:38:31.414+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=Thread-8] [timeMillis: 1452523111414] [levelValue: 800] [[
14:38:31,413 INFO  [AutoDeployer][ThemeHotDeployListener:98] Registering themes for mine-theme]]

[2016-01-11T14:38:33.507+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=221 _ThreadName=Thread-8] [timeMillis: 1452523113507] [levelValue: 800] [[
14:38:33,507 INFO  [AutoDeployer][ThemeHotDeployListener:113] 1 theme for mine-theme is available for use]]

[2016-01-11T14:38:33.736+0000] [glassfish 4.1] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523113736] [levelValue: 800] [[
Loading application [mine-theme] at [/mine-theme]]]

[2016-01-11T14:38:33.992+0000] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523113992] [levelValue: 800] [[
mine-theme was successfully deployed in 4,148 milliseconds.]]

[2016-01-11T14:38:33.998+0000] [glassfish 4.1] [INFO] [NCLS-DEPLOYMENT-02035] [] [tid: _ThreadID=221 _ThreadName=AutoDeployer] [timeMillis: 1452523113998] [levelValue: 800] [[
[AutoDeploy] Successfully autodeployed : /home/glassfish/glassfish4/glassfish/domains/domain1/autodeploy/mine-theme.war.]]

Setting your theme

See Control Panel -> Configuration -> Portal settings -> Display Settings and below there's Look & Feel.

Also, there's this place: Control Panel -> Sites -> Your site -> Site Pages -> Look and Feel + Current Theme. You can select another theme from a list below in the same configuration page.

Your theme is actually a Plugin, and can be found among the Theme Plugins. Navigate to Control Panel -> Apps -> Plugins Configuration. Select the tab "Theme Plugins". Your theme should be visible in the list.

If not, you are likely to receive something like this in your logs7 8:
[2015-12-31T23:38:41.633+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=29 _ThreadName=Thread-8] [timeMillis: 1451605121633] [levelValue: 800] [[
23:38:41,633 WARN [http-listener-1(4)][ThemeLocalServiceImpl:156] No theme found for specified theme id mine_WAR_minetheme. Returning the default theme.]]
I don't know why this happened in my case, but I found a reference in the Liferay database to the old mine-theme. Even though I thought I got rid of it permanently, but removing it from the autodeploy directory. If I remove it from the glassfish autodeploy directory, it is also removed from the Application Server. Liferay is listening to what happenes on the autodeploying front, detects the deletion, and starts cleaning up after itself as well.

Apparently, there still was an entry left hanging. I had to update the database manually to reset a database tablerow back to "classic".

Adapting your theme

It is possible to adapt your theme, by replacing images and css and html files judiciously.

The interesting bit of theming is that you specify the parent theme. So, you've got "styled" and "unstyled" and the default theme called "classic" to choose from. But it would also be easy to create for example a "Christmas" theme, that is derived from the theme that you normally use. So it's kind of an Inheritance structure, similar to Object Oriented Programming.

I also like the fact that in your new theme you specify the "changes" compared to the parent theme in the _diffs folder. This way, when a parent theme changes (upon a new release of Liferay Portal), you automatically get the new updates, and if you do not change these defaults in your theme, they are just build into the target war upon the next release.

If you wish to start making bigger changes, there is the possibility of using the Liferay Application Display Templates9 (ADT).

Liferay uses Apache Velocity10 as its templating engine.

Adding JQuery to the Liferay portal can be done as described at [11].


[1] Randomthoughts - Liferay
[2] Liferay
[3] Wikipedia - Liferay
[4] Liferay Company Blogs - Creating Liferay Themes with Maven
[5] Liferay Developer Network - Developing Liferay Theme Plugins with Maven
[6] Liferay Developer Network - Creating a Theme Project in the Plugins SDK
[7] StackOverflow - Error occures when deploying theme to liferay portal. “No theme found for specified theme id .”
[8] Techspace - No theme found for specified theme id abc_WAR_xyztheme
[9] LiferaySavvy - List of Velocity Variables in Liferay
[10] Wikipedia - Apache Velocity
[11] Liferay Company Blogs - Using jQuery (or any Javascript library) in Liferay 6.0

Thursday, 21 January 2016

Yum replaced by DNF - Followup

Well, recently came into the problem that I had some configuration that requires porting, I think. I wanted to get into the DNF scene, whilst Centos 7 still uses yum by default.

From Yum to DNF

I installed dnf, simply using.
yum install dnf
The packages yum, yum-plugin-fastestmirror, yum-utils are now no longer needed. Your original configuration file can then be found in yum.conf.rpmsave.

I installed "dnf-yum", to be able to use yum as a automatic redirect to dnf.


The /etc/yum.conf shall have been replaced with /etc/dnf/dnf.conf.

Yum cron jobs

In DNF, this is replaced by the package "dnf-automatic"3. The configuration of which is in /etc/dnf/automatic.conf.

Removed package yum-cron as it is no longer needed.

To get started:
systemctl enable dnf-automatic.timer && systemctl start dnf-automatic.timer
To list the timers set:
systemctl list-timers *dnf-* -all

Excluding packages

I have added the java* packages to the exclude directive in yum.conf1.

Of course, I do wish to manually install the java updates along with all the other updates2. To do this I can use the command line:
yum --disableexcludes=all update
These switches in the commandline and changes in the config file of yum are ported identically over to dnf. So that's not a problem.

Yum Repos

Apparently, DNF still uses all the repositories defined under /etc/yum.repos.d. So that's a relief.


[1] Redhat - How do I exclude kernel or other packages from getting updated in Red Hat Enterprise Linux while updating system via yum?
[2] nixCraft - Force yum update Command To Exclude Certain Packages
[3] Fedora Project - AutoUpdates

Thursday, 14 January 2016

Glassfish Logging to Database

I wanted to redirect the logging messages from the Glassfish Application Server to the database.

Glassfish uses the standard Logging API available in the JDK. There are some who find the already existing logging APIs (log4j, etc) available better than the default provided in the SDK. But I find it sufficient for my purposes.

The Logging API uses Handlers to indicate what needs to be done with all those log messages. The default handlers available in the API are shown in the diagram below.

I have opted for having the logrecords sent via the network (local interface) to a small daemon that posts the log records into a database table. So that would mean using the SocketHandler.

In general, this is what you want. Several application servers all sending their log messages to a central repository that can deal with it. Of course, there are way more sophisticated solutions readily available compared to this home-brewed thing. But it helps to get the general idea of how it works.

The software I made is available at The sequence diagram below is basically how it works.

Since the data send over the network is in the XML format, I'm using StAX for interpreting the XML stream properly.

The funny thing is that the DatabaseHandler in the diagram above, is basically a child of the Handler class (depicted in the class diagram up top). So, what we have here is a kind of Logging proxy, really.

The database table follows the fields in the LogRecord class closely:
create table mm_systemlog (
  id bigint(20) NOT NULL AUTO_INCREMENT primary key,
  millis bigint(20) not null,
  sequence bigint(20) not null,
  logger varchar(255),
  level varchar(25),
  class varchar(255),
  method varchar(255),
  thread int(10),   
  message text not null,


Glassfish has a file (glassfish4.1/glassfish/domains/domain1/config/ It is possible to add or change the Log Handler used by Glassfish by changing it in the file1 3.

I was unable to provide Glassfish with a Logging Handler that directly posted the LogRecords into a database (see [2]). Hence the current solution described above.

The (fairly easy) steps were as follows:
  • the developer has put the custom handler JAR file into the domain-dir/lib/ext directory.
  • the class that extends java.util.logging.Handler must be in the server classpath.
  • add the new handler to the handlers attribute in the glassfish/domains/domain1/config/ file
  • reboot glassfish

XML Formatter

Below is an example of what the XML format looks like.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<message>Hello, World</message>
<message>Welcome Home</message>
<message>Config ....</message>
<message>Fine ....</message>
<message>Finest ....</message>
<message>Warning ....</message>
I would like to point out that, strictly speaking, the above XML document is not valid, as there is no closing </log> tag.

This makes sense, as the xml is streamed and never quite ended.

I would also like to point out that the XML document contains for each record both the number of milliseconds sinds 1970 and the date. This at first seems superfluous to me, but after some thought it makes sense. If you add both, you get valuable information in what timezone the server logging messages is working. This information is most likely lost in the milliseconds approach.


[1] Oracle Blog - Configure my Custom Log Handler in GlassFish 3.1
[2] StackOverflow - Capture GlassFish log file into SQL/JPA data base
[3] 7 Administering the Logging Service - Adding a Custom Logging Handler
Oracle GlassFish Server Administration Guide
HK2 - Dependency Injection Kernel
Oracle JavaTM Tutorials - Lesson: JDBC Introduction
JavaBendeR - Simple Log server with java SocketHandler and centralization of log records
Java Logging API Tutorial – Examples of Logger Levels, Handlers, Formatters and Filters
Oracle JavaTM Tutorials - Reading XML Data into a DOM
Oracle JavaTM Tutorials - Using StAX

Thursday, 7 January 2016

Vaadin 7

Vaadin1 is an open source framework for developing web applications2 running in your browser. What is interesting is that it uses Java to do it.

It feels like you're programming like Swing in Java, but the results are transferred to your webbrowser using Vaadin. Vaadin is able to do this with the help of the Google Web Toolkit3.

Vaadin can apparently be run on the Google App Engine, if you like.

Vaadin 7 supports the JSR-286 Portlet specification. Several portals are supported. Vaadin also has some deeper integration with Liferay Portal11, in which I am very interested, as it is the one that my website is running on.

I did find a youtube video12 that introduces Vaadin in combination with JEE and NetBeans.

Upgrading to Vaadin 7

One of the problems I encountered, when using Vaadin 74 is that most of the resources available are still referring to Vaadin 6. It is important to notice the differences.

The points in [4] that have been most relevant to me are:
  • com.vaadin.Application class no longer exists. The main entry point to your application is now a com.vaadin.ui.UI, which replaces Application and its main window.
  • Also com.vaadin.terminal.gwt.server.ApplicationServlet has been replaced with com.vaadin.server.VaadinServlet in web.xml and its parameter "application" with "UI" pointing to your UI class, and the application is ready to go. Of course you can use annotations, if you prefer.


As it is Java, I should have no problem Stubbing the Vaadin framework and junit-testing my code. This to me is a big bonus.


Persistence in Vaadin is possible by using the JPAContainer5.


I use the Servlet to inject a lot of things I need, and then provide those injected things to my UI. Works flawlessly6.

JEE and JPA together in Vaadin

I found helpful information on how to create a EjbEntityProvider here at [7]. That I can use as a base class for EJBBeans that I can inject in my Servlet and henceforth use in my UI for the JPAContainer.

A full downloadable example is available at [8].


I have not had to debug anything, everything just works. But, for those interested, you can find it at [9].


I get a "Failed to load the bootstrap javascript: ./VAADIN/vaadinBootstrap.js?v=7.5.5"
See [10]. Extend the @WebServlet annotation withe more than one urlPattern. See the example above.


[1] Vaadin
[2] Wikipedia - Vaadin
[3] Google Web Toolkit
[4] Vaadin Wiki - Mirating from Vaadin 6 to Vaadin 7
[5] Book of Vaadin - Chapter 19 - JPAContainer
[6] Vaadin Wiki - JEE6 integration with Vaadin 7
[7] Using JPA Container 2.0 in a JEE6 server
[8] Vaadin Forum - Unable to follow J6EE wiki - NullPointerException!/thread/386542/389263?_19_redirect
[9] Book of Vaadin - Chapter 11.3. Debug Mode and Window
[10] Book of Vaadin - 4.9. Deploying an Application
[11] Liferay
[12] YouTube - Java EE 7 with NetBeans and Vaadin