Category: Java

Tomcat Logo 0

Add Connection Pool with auto connection cleanup functionality for Tomcat 7 and MySQL

Since we don’t want to use external classes or libraries to handle database connections for our web applications we should stick to what comes built-in with the container server – in my case Apache Tomcat 7 and MySQL database server. To keep the database connection pooling and cleanup functionality on...

Tomcat Logo 2

Tomcat 7 Fails to load Resource Factory class

In case you get the exception Could not load resource factory class when trying to retrieve the Connection object from the JDBC connection resource pool based on the factory class org.apache.tomcat.jdbc.pool.DataSourceFactory make sure to check if tomcat-jdbc.jar is installed in the tomcat/lib directory. Please note that this file is not...

Jersey Logo 3

Serving Files using Jersey Web Service (JAX-RS)

There are a lot of tutorials out there explaining how to send binary data (i.e. application/octet-stream) as response for Jersey web services (Java JAX-RS). Two possible solutions are based on either returning a Response or StreamingObject containing the appropriate binary data stream. Below you find a simple example for both...

Liferay Logo 2

Setting Custom Portlet Titles in Liferay

Setting custom portlet titles in Liferay can be a little tricky. Changing the title via the portlet configuration in the frontend is easy but when it comes to reading the custom title property programmatically things seem to get a little messy. Setting the Title So, first of set your portlet...

Liferay Logo 0

Determine Portlet URL in Liferay

Since Liferay has a helper class for almost everything but finding the correct one sometimes costs more time than expected here is how you determine a portlet’s current URL: Hopefully this saves you some time 🙂

Bugfix for urbanairship-java SDK Connection Still Allocated 0

Bugfix for urbanairship-java SDK Connection Still Allocated

Apart from another bug reported in https://www.kerstner.at/en/2012/12/bugfix-for-urbanairship-java-sdk-jsonparseexception/ there also exists a bug related to the internal use of BasicClientConnManager for sending HTTP requests. The Cause When trying to send multiple HTTP requests using sullis urbanairship-java SDK (occasionally) an IllegalStateException is thrown. This is caused due to the fact that the...

Bugfix für urbanairship-java SDK JsonParseExceptionBugfix for urbanairship-java SDK JsonParseException 0

Bugfix für urbanairship-java SDK JsonParseExceptionBugfix for urbanairship-java SDK JsonParseException

There (still) exists a bug in urbanairship-java SDK related to parsing valid ISO8601 dates. The original bug report can be found here: GSon date parsing error. The Cause ISO8601 states that for date-time strings the separator “T” can be left out. Unfortunately the urbanairship-java SDK expects only fully qualified ISO8601...

Liferay Logo 1

Setting Custom Timezones in Liferay

By default Liferay uses UTC as timezone. In order to set custom timezones you may choose from the following options: Create an EXT-Plugin Specify timezone in Tomcat’s setenv script EXT-Plugin Create an EXT-plugin (or use your existing one) and put system-ext.properties in extyour-extdocrootWEB-INFext-implsrc using the following setting: Be sure the...

Jersey Logo 0

Custom Response Types in Jersey SecurityContext

Sometimes you might need to return custom response types in your SecurityContext implementation when using Jersey RESTFul web services. Basically, there are two options available to do so: Use javax.ws.rs.core.Response and throw a WebApplicationException or write your own ExceptionMapper Throw WebApplicationException Custom ExceptionMapper The other (even nicer option) is to...

Liferay Logo 1

Setting Custom User Model Attributes in Liferay

Oftentimes you will need to extend Liferay’s built-in User model by adding custom attributes, such as a list of preferred settings. Fortunately, Liferay provides developers with an ExpandoBridge implementation to do so. Thus, in order to add custom attributes simply use the Custom Fields option via the Control Panel (or...

Liferay Logo 0

Dynamically determine Structure IDs in Liferay

When using multiple Web Content (aka JournalArticle) structures in Liferay managing their corresponding IDs via configuration files can become a tedious task. Luckily, there is an easy way to determine structure IDs dynamically based on their title, like the following code snippet demonstrates: