[RESOLVIDO] VRaptor 3 + 10 min. guide + validations

Estou seguindo o guia de 10 minutos do VRaptor, mas quando adiciono o seguinte código:

                       this.validator.checking(new Validations() {{
				that(!product.getName().isEmpty(), "product.name", "name.empty");
				that(product.getPrice() > 0, "product.price", "price.invalid");
			}});

Ele apresenta um erro no início do arquivo (package) e quando clico ele pede para configurar o build path.
Se eu comentar o “that” ele não apresenta erro…
Ao ficar com o mouse no local do erro ele mostra:

Multiple markers at this line:

  • The type org.hamcrest.Matcher cannot be resolved. It is indirectly referenced from required .class files
  • The type org.hamcrest.Matcher cannot be resolved. It is indirectly referenced from required .class files

Por acaso você não esta com dois métodos ou dois path com o mesmo nome não ?

Esta é a classe com problema:

import java.util.ArrayList;

import daos.ProductDao;
import entities.Product;

import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.caelum.vraptor.validator.Validations;

@Resource
public class ProductController {
	
	private Result result;
	private ProductDao dao;
	private Validator validator;
	
	public ProductController(ProductDao dao, Result result, Validator validator) {
		this.dao = dao;
		this.result = result;
		this.validator = validator;
	}
	
	public ArrayList<Product> list() {
		return new ArrayList<Product>();
	}
	
	public void form() {
	}
	
	public void add(final Product product) {
		// validar dados
		this.validator.checking(new Validations() {{
				that(!product.getName().isEmpty(), "product.name", "name.empty");
				that(product.getPrice() > 0, "product.price", "price.invalid");
			}});
		// se houver erro direciona para formulário novamente
		this.validator.onErrorUsePageOf(ProductController.class).form();
		
		// adicionar novo produto
		this.dao.add(product);
		
		this.result.redirectTo(ProductController.class).list();
	}
	
	public void update() {
	}
	
	public void save(Product product) {
		
		this.result.redirectTo(ProductController.class).list();
	}
	
	public void delete() {
	}

}

Esta é minha classe produto:

public class Product {
	
	private Long id;
	private String name;
	private String description;
	private Double price;
	
	public Product() {
		super();
	}

	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public Double getPrice() {
		return price;
	}
	
	public void setPrice(Double price) {
		this.price = price;
	}

}

Você tem o hamcrest-all-1.2RC3.jar na pasta web-inf\lib ?Tem ele no \lib\optional nos arquivos fontes do Vraptor.

The type org.hamcrest.Matcher cannot be resolved

precisa do jar do hamcrest.

Obrigado pessoal, funcionou.
Eu apenas coloquei o arquivo hamcrest-all-1.2RC3.jar dentro do diretório “lib”.