Сyrillic query params in Tomcat Application Server

Today I had a problem with Tomcat encoding with query params.I have solution for search entities.It was working with latin words. But when I tried to add query params in cyrillic, tomcat treat them as unreadable symbols, despite the fact, that I have URLEncodingFilter in my web application, that encodes everything in UTF-8, So, request like this turns to be invalid. http://{HOST}:8080/is-lnu-rest-api/api/specoffers/types?name=Молодший So, as usual, I started investigation of this issue. First, I scanned my project, especially web.xml deployment descriptor for some unusual encoding thing, but I failed, I found nothing. So I delegated all the investigation to google, and found that I should edit my tomcat/conf/server.xml You need to find Connector with port=”8080” and add two lines. <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" useBodyEncodingForURI="true" <!-- This line --> URIEncoding="UTF-8" <!-- This line --> redirectPort="8443" /> Restart your tomcat, and now everythig will be okay

Combining POSTGRESQL and JAVA enums with HIBERNATE together

How many times did you have to use java enums in your JPA/Hubernate entities ? Yes, instead of having some relations with reference-tables, which are some sort of dictionaries, you wrote simple field with varchar type Something like class Model with RowStatus enum RowStatus is used to detemine whether row is deleted from the system, or row is active.It seems, that this should be enough to have no problems while using this functionality. But there is one potential problem: When we set enum in our system, we made a contract, that we will send only values from RowStatus enum. But how about updating data outside our system ? For example, system administrator of your database made some critical update and committed some critical bug - instead of values from RowStatus - ACTIVE, DELETED he updated row with syntax error - DELITED. From now on, when Hibernate will try to map such row - he will throw an exception. That’s an issue. Possible solutions ? The only solution that I can offer you is that you will controll adding your data on database. You can use database enums, constraints, triggers, etc… I choosed postgres enums. To add such, you simply need...

Jenkins and Maven SQL Plugin for cleaning Postgresql database

How many times did you experienced issue, when you need to clean your database from unused data ?For example, you have a qa server with thousands of rows, which you don’t need anymore, so it’s time to delete them. To clean up your database, someone call separate scripts for each table, someone create-drops database.I decided to delete all tables. To remove all rows, you can use maven sql plugin, which has powerful possibilities for doing work with sql. First of all, if you have your maven application, I would reccomend to create separate module for sql. If you don’t want to do this, just leave it as it is in your root pom.xml. You will need to add Maven Sql Plugin. Then, you need to map execution to install goal. You will need to create resource folder.This will be the place, where you will store your scripts. Before we start I don’t want anyone to think, that such module is the best place for storing your database schemas creation.For this purposes there is a good framework called liquibase - it saves migration history and can surely know, what should be updated, and what should not. Such module is always good...

Google Guice - Hello world example

It has been more than two years since I first acquainted with Spring Dependency Injection technology. At first, I didn’t understood what it was, but after few weeks I realized what powerful instrument do I have. From that time I started to love this type of object instantiation and I really don’t want to instantiate objects in some other way. But today I want to represent you a new framework for bean instantiation - Google Guice. So, how to try this Google Guice dependency injection framework ? First of all, open your Eclipse/InteliJIDEA IDE and create maven project: write groupId, artifactId and other things. After that, go to your pom.xml file and add additional dependency: Then, you should create interface NotificationService: We will have multiple implementations of above service to show posibillities of Google Guice Email service is one of the implementations of NotificationService One thing that I noticed is that Google Guice has it’s own @Singleton annotation - from JSR330. Google Guice 3.0 added the support for JSR-330 and we can use annotations from com.google.inject or javax.inject package. Next, we will create second implementation of NotificationService - FacebookService: Consumer class Since we are implementing dependency injection in our application,...

Spring XML Namespaces handling

You all know, that spring supports xml namespaces for defining custom bean definition. For example, if you want to set mvn annotation driven benavior, you can write such code in your xml As you noticed, there is no <bean … /> in this piece of code, but there is So, who is responsible for handling this namespaces? Answer is: NamespaceHandler For example, here is AnnotationDrivenBeanDefinitionParser implementation. Every Spring namespace has an associated NamespaceHandler implementation. The namespace schemas are mapped to schema files inside Spring JARs in various spring.schemas files. The XML schema namespaces are also mapped to handler classes in spring.handlers files (several as each Spring JAR might introduce different namespaces). For your convenience here is a list of most common namespaces: Spring core aop - AopNamespaceHandler c - SimpleConstructorNamespaceHandler cache - CacheNamespaceHandler context - ContextNamespaceHandler jdbc - JdbcNamespaceHandler jee - JeeNamespaceHandler jms - JmsNamespaceHandler lang - LangNamespaceHandler mvc - MvcNamespaceHandler oxm - OxmNamespaceHandler p - SimplePropertyNamespaceHandler task - TaskNamespaceHandler tx - TxNamespaceHandler util - UtilNamespaceHandler Spring Security security - SecurityNamespaceHandler oauth - OAuthSecurityNamespaceHandler Spring integration int - IntegrationNamespaceHandler amqp - AmqpNamespaceHandler event - EventNamespaceHandler feed - FeedNamespaceHandler file - FileNamespaceHandler ftp - FtpNamespaceHandler gemfire - GemfireIntegrationNamespaceHandler groovy - GroovyNamespaceHandler...