Andrei Ermicioi's Blog

Just another weblog

Archive for the ‘Coding’ Category

Hibernate UserType field

leave a comment »

Nu voi incepe sa vorbesc ce este Hibernate, doar voi spune ca e ORM Framework pentru Java.

Problema pe care o voi incerca s-o tratez este, cum facem atunci cind vrem sa mapam un tip de date defenit de noi cu relatia bazei de date? Incerc sa explic. Presupunem avem un bean care are un parametru ce arata starea obiectului, sa zicem SUCCESS/ERROR, acest parametru este un ENUM. Apare intrebarea sub ce tip de date pastram acest parametru in DB, si cum facem asa ca atunci cind bean-ul se pastreaza in DB sa lucreze conform tipului de date ales in DB, iar cind lucram cu el in applicatie el sa fie un ENUM? Aici in ajutor ne vine interfata UserType, astfel vom avea ca field-ul in DB va fi de tip varchar, iar in bean el va fi ENUM.

Read the rest of this entry »


Written by eraniblog

May 4, 2010 at 10:46

Posted in Coding

Web proiect pe SpringFramework 3.0

Acest post va fi un refactoring la alt post de al meu postat pe fostul blog, pe care nu-l mai utilizez šŸ™‚

Aici voi incerca sa arat cum utilizez eu SpringFramework-ul si MVC-ul sau.

Tehnologiile utilizate in proiect sunt:

  • Spring framework 3.0
  • Hibernate
  • Tiles2
  • Maven

Tiles2 – este un framework ce tine de partea de layouting.

Maven – raspunde de satisfacerea dependetilor de librarii. Read the rest of this entry »

Written by eraniblog

April 26, 2010 at 17:30

Posted in Coding

Fu**ing with java PL localization :(

That was the post on twitter 16 min. ago, without stars :). What happen?

I’m working on a Java web application which must have PL localization. The current task was to add the PL localization to application, so with fmt tag lib from jstl I start to implement it. When all static text was replaced with fmt tags I found that some chars are not rendered correctly. Today all morning I was searching why it happening, I was thinking that problem was JSTL, but not at finally I found that the problem is JVM it trying to convert sources and resource files from any encoding to unicode and somewhere something is not working as I expected :(. Ok here is the solution if you have resource files in ru, pl, etc.

In java exist utility native2ascii translate your files with that utility like:

# native2ascii

and all will be ok.

Ok, I leave to take a launch, now I can do it quite šŸ™‚

Written by eraniblog

April 20, 2010 at 13:40

Posted in Coding

Adding a Java library to local maven repository

Downloading jar file somewhere on hdd.
Execute command:

mvn install:install-file -Dfile=/home/erani/jlibs/kaptcha-2.3.jar
-DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar

adding dependency in pom.xml


Written by eraniblog

April 20, 2010 at 13:36

Posted in Coding

SVN and web access

So we need an access to svn throw apache, here is how to do it.
I will assume that a svn repository already made, if not, consult pleaseĀ

1. Install apache2, and libapache2-svn
2. Create “svn” directory in /etc and enter in it.

mkdir /etc/svn
cd /etc/svn

3. Create access file for two users:

htpasswd -cm users root
htpasswd -m users user

You will be prompted to enter password twice for each user, do it.
4. Create roles file

nano control

And add following:


If you want to add role for specific folder in project than add also


5. Configure Apache2.
Find configuration file for apache2, it’s depend of Linux distribution. Add/Edit the file so that in result you will have:

DAV svn
SVNPath /lib/svn # path to svn repository
AuthzSVNAccessFile /etc/svn/control
Require valid-user
AuthType Basic
AuthName "Subversion Repositories at"
AuthUserFile /etc/svn/users

6. Restart apache

I hope it will be helpful.

Also you can look at:

Written by eraniblog

April 20, 2010 at 13:29

Posted in Coding

Kubuntu KDE4 file sharing

So, I have problem sharing the folders on my Kubuntu 9.04 desktop. So I do following to enable it:

1.Ā apt-get install samba4, kdenetwork-filesharing
2.Ā sudo chmod u+s /usr/lib/kde4/libexec/fileshareset
3.Ā sudo rm -R /var/tmp/kdecache-root

Maybe not all of this is needed, but next time when I will have the same problem I’ll try to figure how fix it correct.

Written by eraniblog

April 20, 2010 at 13:21

Posted in Coding

Java, get a file from URL

The following code show how to get a file from URL.

URL serviceUrl = new URL("");
URLConnection urlConn = serviceUrl.openConnection();
InputStream is = serviceUrl.openStream();
FileOutputStream fos = new FileOutputStream("/tmp/myfile.tmp");
int aChar;
while ((aChar = != -1) {

If you want to save in original file name then you can add the code

String filename;
StringTokenizer tokenizer = new StringTokenizer(serviceUrl.getFile(), "/");
while (tokenizer.hasMoreTokens()) {
filename = tokenizer.nextToken();

before code

FileOutputStream fos = new FileOutputStream("/tmp/myfile.tmp");

do not forget to change name toĀ filenameĀ variable

Written by eraniblog

April 20, 2010 at 13:15

Posted in Coding