Wednesday, April 29, 2009

"Migration" from 5.1.0 (JBoss 4.2) to 5.2.2 (Tomcat 5.5) - general steps

Hello everybody,

finally I did it: I managed the "migration" from 5.1.0 to 5.2.2.

As some of you might now the change to 5.2. is quite a major change for liferay.
Funnily the final reason for me to migrate was a quite small change: In 5.2.2. finally Blog-Entries get a HTML Title and a friendly URL. This is quite important from an SEO perspective.
(By the way: Big thanks to the liferay community - I triggered this feature by myself by writing a forum post about it - and it has been implemented quite quickly afterwards!)

Why do I write "Migration" in quotationmarks?
After some bad experiences while trying to migrate from 4.3.5 to 5.1.0 (over 4.4.2) I came up with a new "migration" strategy: I install a fresh new bundle and make the necessary changes in the file system. This seems to work with much less problems to me.

Here are the general steps I use to follow:

Step 1: The new installation

  1. point to database (+ potentially install driver) - now in portal-ext.properties
  2. config mail service - now in portal-ext.properties
  3. configure the start script (for tomcat: setenv.sh)

Step 2: Do the post installation steps

  1. Transport additional webcontent (In my case I had some html and applets in a folder. This needs to go into the ROOT folder)
  2. Finalize the portal-ext.properties file (Normally you have to take everything that is in the _legacy_ properties provided by liferay. This goes especially for authorizations - you can't login if you are migration from an old version due to some algorithm changes)
  3. (optional) In my case I have to change the port to 9080 - so I have to modify the web.xml file of tomcat
  4. provide "authentication"files for google or yahoo webmastertools

Said and done. :)

No honestly: Of course it cost my about two days again - but this time especially due to some tomcat specific things I wasn't used to - and some changes in 5.2.2.
But I will describe this in the next post.

Tuesday, March 3, 2009

Problem: Could not initialize class HibernateUtil / org.slf4j.LoggerFactory not found

Hi all,

after testing the "upgrade" to the long awaited version 5.2.2 (I can describe the procedure as well if you are interested) I got some nasty problems with hibernate.

For the portlet "EasyComments" hibernate3 worked fine so far - but suddenly I got the following errors:

Could not initialize class HibernateUtil
....
at HibernateUtil.closeSession(session);
Annoyingly there was not more to take from the standard out of tomcat (nor from the logs). Only an additional catch blog in the HibernateUtil class showed the real problem:

org.slf4j.LoggerFactory not found

and later:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

So it seems that hibernate is using slf4j internally.
Adding the following jars solved the problem:

slf4-api-1.5.6.jar
slf4-simple-1.5.6.jar

The files can be found here:
www.slf4j.org

And finally all worked again.


Saturday, January 31, 2009

By the way: [DriverManagerConnectionProvider:41] Using Hibernate built-in connection pool (not for production use

.... one addition to my last hibernate post:

The main reason why I tried the c3p0 solution first (besides me not being an experienced mysql admin) was the following message in the output of my local Tomcat test-instance:

[DriverManagerConnectionProvider:41] Using Hibernate built-in connection pool (not for production use!)

(See my last post how to configure c3p0 for liferay portlets:

Portlets for liferay portal with java jsf: Meanwhile: Hibernate / mySQL Problems: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes....)

Meanwhile: Hibernate / mySQL Problems: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes....

Hi all,

we're almost there.
My "user generated content" portlets are running (EasyBlogEntry and EasyComments) - but as expected: There are unforeseen problems. :)

Since I deployed the Hibernate3 based portled EasyComments I get the following exception always after the liferay server is running for some time - roughly every second day. (I use mySQL 5.0.22-0ubuntu6.06.5)


10:53:20,430 ERROR [jsp] java.lang.Exception: org.hibernate.exception.JDBCConnectionException: could not execute query
...
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
...
Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:


** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure

Last packet sent to the server was 1442 ms ago.

STACKTRACE:


com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 1442 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2873)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2763)
...
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2332)

at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2774)


After quite some research in the web I got different clues about which jdbc driver to use, what mysql parameters to set and how to configure hibernate.

At first I harmonized my mySQL drivers (liferay portal had mysql-connector-java-5.0.8-bin.jar and in my portlet mysql-connector-java-5.1.5-bin.jar for some reason. (I should use the one shared library here anyway - well next time..))
Anyway: I didn't help. (I could image that it took longer until the error - but it still kept coming)

As suggested by the mySQL forum I tried now to use c3p0 as the connection pool.
I achieved this by:

1. configuring the hibernate.cfg.xml file

simply add the following to your file:

<!-- Sessions and transactions -->
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="current_session_context_class">thread</property>



As I did here:



Additionally you have to add the c3p0.jar to your portlet! I took the one from the sample portlet sample-dao-portlet-5.1.1.1.war from liferay. (Again you should by able to add it to your server and reference it via the liferay-plugin-package.properties file - but I just put in the /lib folder at first for the sake of ease.)

Unfortunately I have to wait now for at least three days to see if it really helps. Of course I will update you folks with the result. So come back and find out. :)

Sunday, January 18, 2009

Meanwhile: different JSF Versions on JBoss.. (Exception regarding org.jboss.web.jsf.integration.config.JBossJSFConfigureListener)

Hi,

before finishing my post on the user generated contend I want to put something very technical in between.

While deploying my final solution for the anonymous comments (EasyComment-Portlet) I stumpled for the tenth time about an issue regarding the various JSF Versions - and how compatible they are with the different Containers.

So once and for all I want to persist this topic here. :)

As you might be aware JBoss (at least version 4.2) brings its own JSF libraries - and dislikes the deployment of other JSF implementation libraries within an .war file. However as not all versions seem to harminize with liferay properly (I plan to publish a matrix on this one soon if there is interest) its sometimes easier to just bundle the JSF implementation of choice.

In my case I use the myfaces JSP (JSF 1.1) - based on the example portlet "Sample JSF 1.1 (MyFaces JSP)"

So as some times before I got the following error at deployment:
2009-01-17 12:58:29,454 WARN [org.jboss.web.jsf.integration.config.JBossJSFConfigureListener] MyFaces JSF implementation found! This version of JBoss AS ships with the java.net implementation of JSF. There are known issues when mixing JSF implementations. This warning does not apply to MyFaces component libraries such as Tomahawk. However, myfaces-impl.jar and myfaces-api.jar should not be used without disabling the built-in JSF implementation. See the JBoss wiki for more details.
2009-01-17 12:58:29,908 FATAL [javax.enterprise.resource.webcontainer.jsf.config] null MessageFactory
2009-01-17 12:58:29,908 ERROR [STDERR] java.lang.ClassCastException: org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener
2009-01-17 12:58:29,909 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:825)


2009-01-17 12:58:29,927 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/EasyComments-portlet]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
javax.faces.FacesException: java.lang.ClassCastException: org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:387)
at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)

(It was especially annoying because in my local version the portlet worket (on tomcat) - whereas on my productive server (JBoss) it didn't...)

After some time I remebered what this error was about: I had to tell JBoss to take my war included libraries.

So I set the according parameter in the Web.xml of my portlet as shown below:


Here the parameter again:


<context-param>

<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>

<param-value>true</param-value>

</context-param>

I hope this helps all the people that find this.

Friday, December 26, 2008

User generated content with liferay -for anonymous users (part 1)




If you are creating a "Web 2.0" site you might want to allow the users to generate content by themselves. Unfortunately there is no real "out of the box" support for this by liferay -except the discussion forum, which is way to limited in it's functionalitites or better: flexibility.

So to achieve this functionality lets first define the requirements a bit further:

  1. User shall be able to create content (entries)
  2. It shall be possible to comment and rate these entries
  3. It shall be possible to display the content in various ways (aggregated, isolated, pre-view,..)
  4. The entries should be stored search engine friendly
  5. Optimized for external users and internet (simple + user friendly, captcha support, evtl key word/html code blocking,...)

From my perspective there are three ways to achieve this:

  1. Complete custom coding
  2. Use API: Page, Journal articles, page comments, ...
  3. Use API: Blog

As I chose to use liferay to use a lot out of the box functionalties and not to do everything on my own (especially to be able to benefit from ongoing updates and improvements) I chose to go for option 2 or 3.

As 3 seemed to be easier and more comprehensive I chose to go for that option first...

Regarding the requirements:
There are still a lot of open questions which I will address in the following posts - but one thing already: Requirement 5 (simplicity, captcha, etc.) is of course not very much build in for guest.

So I will do that for my own based on JSF-portlets. Details on this will also come in the next posts. To give you an impression how my "API-wrapper" looks like - see the screenshot above

Saturday, December 6, 2008

Content, Navigation, Layout - and first Theme experience

Hi again,

today I want to inform you about roughly the first half year.

In this period of time the main focus was on the standard portlets, content and on some first tests in the area of themes.

Content
Well - the most important aspect of a website is hopefully still the content. So this was the first focus. The portlets around journal articles are quite good. Very easy to start with. Creation and publishing of content is good and easy. Really.
What I miss a bit though is a bit more comprehensive way to manage links maybe. After some changes after some time regarding structure and links it was not completely obvious which journal articles linked to which pages. A link list could be interesting here I guess - or maybe I'm just missing a feature? :)
Well that's something for sure by the way: I'm strongly suppose that I'm missing some features. But I'm happy for any clue - so just feel free to point it out if you find anything stupid.

Navigation & basic layout
Woooow! Big respect to liferay here! I worked quite a bit with other "professional" portals - but what liferay offers here is really awesome. The possibilities to easily arrange pages and portles is just great. It's really just fun to create structures and to play around with the layout. It reminds me a lot of agile programming - meaning that you can consider the building of the website as continous prototyping.
You just place some content - and if it doesn't really convince or just doesn't seem to provide the usability you need - you drag and drop the stuff around.

And it even goes further: Border, colors, font can be changed in a matter of seconds. Especially nice if you want to quickly highlight certain parts to guide the user and to increase user conversion rates.
(www.batifolez.com is a good little example)

Theme editing / creation
As we were pretty convinced in the beginning - the next thing we wanted to do is to really brand our website. So we started with the plugin environment and created a theme. Not bad - especially with the firefox webdeveloper tools - you can quickly get some results.

But as we are no webdesigners we realized that it is A LOT of effort to make all the small details fit. So our first results never REALLY went life - as they simply were not good enough. We tried them out - and removed them again then. :) What I liked most back then was the "desktop theme" - a pity that liferay removed that by now - but that was really a tricky bit of a theme.
Well - and after liferay significantly improved their own standard look and feel (i think with 5.0) - we simply changed back to that. :)

One last small comment: I didn't really get why liferay takes velocity for their theme creation. It seems quite ok - but again a learning effort. And all the new things together are really quite a hurdle to get started. I think this knowledge and hurdle point shouldn't be underrated. Maybe some time it's even better to leverage knowledge and make it easy for people to just start then to take the little-bit-better-technology.

That's it for today - stay tuned for the experiences with migration and then portlet development.

Cheers!