Sunday, September 29, 2013

java.lang.NoSuchMethodError: antlr.collections.AST.getLine()

After adding Velocity to my Spring Web Application, I'm getting this error:

29.09.2013 22:44:26  WARN ( - Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I


The error is due by the conflicts between two differents version of "antlr". You need to exclude the version from velocity-tool.

So add the following exclusion to the velocity-tools maven dependency.


Wednesday, September 25, 2013

Tar following symlinks


Suppose that we have to tar gzip a directory that contains two symlinks.




If you use the usual command tar -zcvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get an archive that contains two symbolic links.


If you want to include the content of symbolic links, you need to add a "h" just after the "c",

The command is tar -zchvf ROOT_DIRECTORY.tgz ROOT_DIRECTORY

You will get the directory including all the files under the ROOT_DIRECTORY



Thursday, September 19, 2013

Nice Grep tool for Windows - grepWin


I've found a great tool to do greps in Windows.

Please have a look at

Thursday, September 12, 2013

Ruby Application Server - Installation notes for Nginx and Passenger


Here's how to install Passenger and Nginx. You will get a very fast Ruby application server.

Compile nginx :
tar -xzvf nginx-1.3.14.tar.gz
cd nginx-1.3.14
./configure --prefix=/etc/nginx --with-http_ssl_module

cd /etc/init.d/
ln -snf /etc/nginx/sbin/nginx

Compile passenger :

cd /usr/local/ruby/bin

 1. Yes: download, compile and install Nginx for me. (recommended)
    The easiest way to get started. A stock Nginx 1.0.6 with Passenger
    support, but with no other additional third party modules, will be
    installed for you to a directory of your choice.

 2. No: I want to customize my Nginx installation. (for advanced users)
    Choose this if you want to compile Nginx with more third party modules
    besides Passenger, or if you need to pass additional options to Nginx's
    'configure' script. This installer will  1) ask you for the location of
    the Nginx source code,  2) run the 'configure' script according to your
    instructions, and  3) run 'make install'.

Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.

Enter your choice (1 or 2) or press Ctrl-C to abort: 2

The next step is to point passenger to the source directory. Is this example, the source is in my home folder so it’s -> /home/xxx/nginx-1.3.14.

Than point the installation of nginx to /etc/nginx

Passenger is now installed. Here’s what your nginx config should look like this:
worker_processes  2;

error_log  logs/error.log  debug;

#pid        logs/;

events {
    worker_connections  2000;

http {
    passenger_root /usr/local/ruby-1.8.7-p352/lib/ruby/gems/1.8/gems/passenger-3.0.9;
    passenger_ruby /usr/local/ruby-1.8.7-p352/bin/ruby;
    passenger_max_pool_size 3;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

  server {
     listen 8666;
     server_name localhost;
     root /data/opt/local/ruby/myapp/public/;   # <--- be sure to point to 'public'!
     passenger_enabled on;
     passenger_use_global_queue on;

     auth_basic "myapp Access"; # <--- For password auth
     auth_basic_user_file /home/myapp/passwd;

     #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html

Stop :
/etc/init.d/nginx -s stop

Tuesday, September 10, 2013

JPA / Hibernate - On Delete Set NULL

It's impossible to configure a ON DELETE SET NULL with JPA / Hibernate.

To achieve this, you could define a @PreRemove method that specify the fields to set NULL.

Here's an example:


 * The persistent class for the user database table.
@Table(name = "`user`")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(unique = true, nullable = false)
    private Long id;

    @Column(length = 255)
    private String address;

    @Column(length = 255)
    private String city;

    @Column(nullable = false, length = 2)
    private String country;

    @Column(nullable = false, length = 255)
    private String email;

    @Column(name = "is_active", nullable = false)
    private Boolean isActive;

    @Column(nullable = false, length = 255)
    private String name;

    @Column(nullable = false, length = 40)
    private String password;

    @Column(length = 15)
    private String phone;

    @Column(name = "postal_code", length = 7)
    private String postalCode;

    @Column(nullable = false, length = 2)
    private String province;

    @Column(length = 1)
    private String role;

            schema = "stratageme_ca",
            name = "favourite_product"
            , joinColumns = {
            @JoinColumn(name = "user_id", nullable = false)
            , inverseJoinColumns = {
            @JoinColumn(name = "product_id", nullable = false)
    private List<Product> products;

    @OneToMany(mappedBy = "user")
    private List<PurchaseOrder> purchaseOrders;

    @OneToOne(mappedBy = "user")
    private SavedCart savedCart;

    @OneToMany(mappedBy = "specialist")
    private List<Store> storesSpecialist;

    @OneToMany(mappedBy = "director")
    private List<Store> storesDirector;

    @OneToMany(mappedBy = "vp")
    private List<Store> storesVp;

    @OneToMany(mappedBy = "conseiller")
    private List<Store> storesConseiller;

    @OneToMany(mappedBy = "user")
    private List<Territory> territories;

    @JoinColumn(name = "all_under_banner_id")
    private Banner banner;

    @JoinColumn(name = "title_id")
    private Title title;

    public User() {

    public Long getId() {

    public void setId(Long id) { = id;

    public String getAddress() {
        return this.address;

    public void setAddress(String address) {
        this.address = address;

    public String getCity() {

    public void setCity(String city) { = city;

    public String getCountry() {

    public void setCountry(String country) { = country;

    public String getEmail() {

    public void setEmail(String email) { = email;

    public Boolean getIsActive() {
        return this.isActive;

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;

    public String getName() {

    public void setName(String name) { = name;

    public String getPassword() {
        return this.password;

    public void setPassword(String password) {
        this.password = password;

    public String getPhone() {

    public void setPhone(String phone) { = phone;

    public String getPostalCode() {
        return this.postalCode;

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;

    public String getProvince() {
        return this.province;

    public void setProvince(String province) {
        this.province = province;

    public String getRole() {
        return this.role;

    public void setRole(String role) {
        this.role = role;

    public List<Product> getProducts() {
        return this.products;

    public void setProducts(List<Product> products) {
        this.products = products;

    public List<PurchaseOrder> getPurchaseOrders() {
        return this.purchaseOrders;

    public void setPurchaseOrders(List<PurchaseOrder> purchaseOrders) {
        this.purchaseOrders = purchaseOrders;

    public SavedCart getSavedCart() {
        return this.savedCart;

    public void setSavedCart(SavedCart savedCart) {
        this.savedCart = savedCart;

    public List<Store> getStoresSpecialist() {
        return storesSpecialist;

    public void setStoresSpecialist(List<Store> storesSpecialist) {
        this.storesSpecialist = storesSpecialist;

    public List<Store> getStoresDirector() {
        return storesDirector;

    public void setStoresDirector(List<Store> storesDirector) {
        this.storesDirector = storesDirector;

    public List<Store> getStoresVp() {
        return storesVp;

    public void setStoresVp(List<Store> storesVp) {
        this.storesVp = storesVp;

    public List<Store> getStoresConseiller() {
        return storesConseiller;

    public void setStoresConseiller(List<Store> storesConseiller) {
        this.storesConseiller = storesConseiller;

    public List<Territory> getTerritories() {
        return this.territories;

    public void setTerritories(List<Territory> territories) {
        this.territories = territories;

    public Banner getBanner() {
        return this.banner;

    public void setBanner(Banner banner) {
        this.banner = banner;

    public Title getTitle() {
        return this.title;

    public void setTitle(Title title) {
        this.title = title;

     * Pre Remove to set ON DELETE SET NULL
    public void preRemove(){
        for(Store s : storesConseiller){

        for(Store s : storesSpecialist){

        for(Store s : storesDirector){

        for(Store s : storesVp){



Monday, September 9, 2013

Linux - find file in specific directory

If you want to search for all files under a specific directory and remove them, you could use the following command:

find . -type f -wholename '*/DIRECTORY/*' -exec rm -rf {} \;

Where DIRECTORY is the name of your directory.

For example, you will be able to find all theses files


You must execute the command from /home/toto

Friday, September 6, 2013

Eclipse / SVN - Attempted to lock an already-locked dir

After an Eclipse crash, impossible to commit / update files. I'm getting this error

org.apache.subversion.javahl.ClientException: Attempted to lock an already-locked dir
svn: Working copy 'D:\XXX' locked.
svn: 'D:\XXX' is already locked.

In Eclipse- Right Click- Team / Refresh Cleanup