Google gdata maven repository

Недавно пришлось столкнуться с тем что для гугловской библиотеки gdata отсутствуют maven-репозитории. Конечно есть новая библиотека google-api-java-client, но в ней реализованы не все API, например недостает Provisioning API для доменов.

В поиске было найдено несколько репозиториев, но во всех из них лежат только старые версии библиотеки.

Так же был найден замечательный скрипт для создания локального maven-репозитория.

Поскольку не у всех есть время и возможность создать свой репозиторий (под Windows например у меня этот скрипт запустить так и не получилось), то я решил выложить результаты работы у себя на сервере — вдруг кому-то и сгодится.

Подробности под катом
Читать далее »

Поддержка Java 7 try-with-resources в MyBatis

В Java 7 появился аналог конструкции using из C# — try-with-resources. Данную фишку очень хорошо использовать для автоматического закрытия ресурсов типа коннектов к базам данных и тд. Например так:

try (SqlSession session = ConnectionFactory.getSqlSessionFactory().openSession()) {
// Work with session
session.commit();
}

Но вот беда — класс org.apache.ibatis.session.SqlSession из MyBatis 3.0.6 использующегося в проекте не реализует интерфейс AutoCloseable необходимый для того что бы эта конструкция заработала. Надеюсь что в следующей версии поддержку добавят, а пока предлагаю небольшой workaround.

Читать далее »

Обход исключения org.apache.ibatis.transaction.TransactionException в iBATIS при временной недоступности сервера баз данных

Иногда происходит неприятная ситуация когда сервер баз данных уходит в ребут.
В этом случае можно поймать неприятное исключение такого вида:

Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error opening session.  Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 59,121,876 milliseconds ago.  The last packet sent successfully to the server was 59,121,984 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
### Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 59,121,876 milliseconds ago.  The last packet sent successfully to the server was 59,121,984 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:83)
        at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:32)
        at com.greytower.htmltemplates.core.dao.ibatis.TemplatesDAOImpl.readAll(TemplatesDAOImpl.java:70)
        at com.greytower.htmltemplates.beans.TemplatesEditorBean.init(TemplatesEditorBean.java:86)
        ... 59 more
Caused by: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 59,121,876 milliseconds ago.  The last packet sent successfully to the server was 59,121,984 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
        at org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:51)
        at org.apache.ibatis.transaction.jdbc.JdbcTransaction.<init>(JdbcTransaction.java:19)
        at org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory.newTransaction(JdbcTransactionFactory.java:15)
        at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:78)
        ... 62 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 59,121,876 milliseconds ago.  The last packet sent successfully to the server was 59,121,984 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

Читать далее »

PrimeFaces tips & tricks

В данном посте я постараюсь описать решения типичных проблем возникающих при работе с прекрасной библиотекой JSF компонентов PrimeFaces.
Читать далее »

Установка связки Mercurial + UWSGI + Nginx + HTTPS на Ubuntu Server 10.04

Недавно появилась необходимость установить Mercurial сервер, используя в качестве фронтэнда nginx. В интернете довольно много информации на данную тему, но пришлось довольно много импровизировать что бы добиться результата. Итак, ниже представлен результат труда по настройке этой связки.

Читать далее »