Bom dia já postei esse problema no forum do vRaptor, mas acredito que aqui seja respondido mais prontamente.
estou fazendo uma aplicação para testar o vRaptor
então fiz as duas seguintes classes
package br.com.teste.negocio;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import br.com.teste.dao.ClienteDAO;
import br.com.teste.jdbc.ConnectionFactory;
import br.com.teste.orm.ClienteDAOImpl;
public class Cliente implements java.io.Serializable, Cloneable {
private static final long serialVersionUID = 5303313432366260399L;
private ClienteKey key = null;
/* CLI_ID, PK */
protected java.math.BigDecimal cliId;
/* CLI_NOME */
protected String cliNome;
/* CLI_ENDERECO */
protected String cliEndereco;
/* UF_ID */
protected Uf uf;
public Cliente(){
//uf = new Uf();
key = new ClienteKey();
}
/* Return the key object. */
public ClienteKey getKeyObject() {
return key;
}
/* CLI_ID, PK */
public java.math.BigDecimal getCliId() {
return cliId;
}
/* CLI_ID, PK */
public void setCliId(java.math.BigDecimal cliId) {
this.cliId = cliId;
key.setCliId(cliId);
}
/* CLI_NOME */
public String getCliNome() {
return cliNome;
}
/* CLI_NOME */
public void setCliNome(String cliNome) {
this.cliNome = cliNome;
}
/* CLI_ENDERECO */
public String getCliEndereco() {
return cliEndereco;
}
/* CLI_ENDERECO */
public void setCliEndereco(String cliEndereco) {
this.cliEndereco = cliEndereco;
}
/* UF_ID */
public Uf getUf() {
return uf;
}
/* UF_ID */
public void setUf(Uf uf) {
this.uf = uf;
}
/* Indicates whether some other object is "equal to" this one. */
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || !(obj instanceof Cliente))
return false;
Cliente bean = (Cliente) obj;
if (this.cliId == null) {
if (bean.cliId != null)
return false;
}
else if (!this.cliId.equals(bean.cliId))
return false;
if (this.cliNome == null) {
if (bean.cliNome != null)
return false;
}
else if (!this.cliNome.equals(bean.cliNome))
return false;
if (this.cliEndereco == null) {
if (bean.cliEndereco != null)
return false;
}
else if (!this.cliEndereco.equals(bean.cliEndereco))
return false;
if (this.uf == null) {
if (bean.uf != null)
return false;
}
else if (this.uf.getUfId()!= bean.uf.getUfId())
return false;
return true;
}
/* Creates and returns a copy of this object. */
public Object clone()
{
Cliente bean = new Cliente();
if (this.cliId != null)
bean.cliId = new java.math.BigDecimal(this.cliId.toString());
bean.cliNome = this.cliNome;
bean.cliEndereco = this.cliEndereco;
if (this.uf != null)
bean.uf =(Uf) bean.uf.clone();
return bean;
}
/* Returns a string representation of the object. */
public String toString() {
String sep = "\r\n";
StringBuffer sb = new StringBuffer();
sb.append(this.getClass().getName()).append(sep);
sb.append("[").append("cliId").append(" = ").append(cliId).append("]").append(sep);
sb.append("[").append("cliNome").append(" = ").append(cliNome).append("]").append(sep);
sb.append("[").append("cliEndereco").append(" = ").append(cliEndereco).append("]").append(sep);
//sb.append("[").append("ufId").append(" = ").append(uf.getUfId()).append("]").append(sep);
return sb.toString();
}
// inicio da logica de negocio
/**
* metodo que insere um cliente
* @param cliente o cliente a ser inserido
* @return a chave do registro inserido
* @throws SQLException
*/
public ClienteKey insere(Cliente cliente) throws SQLException{
ClienteKey ck = null;
Connection conn = null;
try{
conn = ConnectionFactory.getConnection();
ClienteDAO cdao = new ClienteDAOImpl();
cdao.create(cliente, conn);
ck = cdao.loadCurrentKey(conn);
}finally{
ConnectionFactory.closeConnection(conn);
}
return ck;
}
/**
* metodo que edita um cliente
* @param cliente o cliente a ser editado
* @throws SQLException
*/
public void edita(Cliente cliente) throws SQLException{
Connection conn = null;
try{
conn = ConnectionFactory.getConnection();
ClienteDAO cdao = new ClienteDAOImpl();
cdao.update(cliente, conn);
}finally{
ConnectionFactory.closeConnection(conn);
}
}
/**
* metodo que exclui um cliente
* @param clienteKey a pk do cliente a ser excluido
* @throws SQLException
*/
public void exclui (ClienteKey clienteKey) throws SQLException{
Connection conn = null;
try{
conn = ConnectionFactory.getConnection();
ClienteDAO cdao = new ClienteDAOImpl();
cdao.delete(clienteKey, conn);
}finally{
ConnectionFactory.closeConnection(conn);
}
}
/**
* metodo que retorna uma coleção de clientes baseado no filtro passado
* em filtro
* @param filtro o filtro usado para a consulta
* @return a lista de clientes
* @throws SQLException
*/
public Collection<Cliente> lista(Cliente filtro) throws SQLException{
Connection conn = null;
List<Cliente> clientes = new ArrayList<Cliente>();
try{
conn = ConnectionFactory.getConnection();
ClienteDAO cdao = new ClienteDAOImpl();
clientes = cdao.list(filtro, conn);
}finally{
ConnectionFactory.closeConnection(conn);
}
return clientes;
}
/**
* metodo que retorna um cliente baseado na sua pk
* @param clienteKey a chave que identifica um cliente
* @return o cliente carregado
* @throws SQLException
*/
public Cliente consulta(ClienteKey clienteKey) throws SQLException{
Connection conn = null;
Cliente cliente = null;
try{
conn = ConnectionFactory.getConnection();
ClienteDAO cdao = new ClienteDAOImpl();
cliente = cdao.load(clienteKey, conn);
}finally{
ConnectionFactory.closeConnection(conn);
}
return cliente;
}
}
e
package br.com.teste.negocio;
public class Uf implements java.io.Serializable, Cloneable {
private static final long serialVersionUID = -3250500264212572861L;
private UfKey key = new UfKey();
/* UF_ID, PK */
protected java.math.BigDecimal ufId;
/* UF_DESCRICAO */
protected String ufDescricao;
/* Return the key object. */
public UfKey getKeyObject() {
return key;
}
/* UF_ID, PK */
public java.math.BigDecimal getUfId() {
return ufId;
}
/* UF_ID, PK */
public void setUfId(java.math.BigDecimal ufId) {
this.ufId = ufId;
key.setUfId(ufId);
}
/* UF_DESCRICAO */
public String getUfDescricao() {
return ufDescricao;
}
/* UF_DESCRICAO */
public void setUfDescricao(String ufDescricao) {
this.ufDescricao = ufDescricao;
}
/* Indicates whether some other object is "equal to" this one. */
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || !(obj instanceof Uf))
return false;
Uf bean = (Uf) obj;
if (this.ufId == null) {
if (bean.ufId != null)
return false;
}
else if (!this.ufId.equals(bean.ufId))
return false;
if (this.ufDescricao == null) {
if (bean.ufDescricao != null)
return false;
}
else if (!this.ufDescricao.equals(bean.ufDescricao))
return false;
return true;
}
/* Creates and returns a copy of this object. */
public Object clone()
{
Uf bean = new Uf();
if (this.ufId != null)
bean.ufId = new java.math.BigDecimal(this.ufId.toString());
bean.ufDescricao = this.ufDescricao;
return bean;
}
/* Returns a string representation of the object. */
public String toString() {
String sep = "\r\n";
StringBuffer sb = new StringBuffer();
sb.append(this.getClass().getName()).append(sep);
sb.append("[").append("ufId").append(" = ").append(ufId).append("]").append(sep);
sb.append("[").append("ufDescricao").append(" = ").append(ufDescricao).append("]").append(sep);
return sb.toString();
}
}
então fiz a classe anotada como componete com o seguinte metodo
@Out
private Collection<Cliente> clientes;
//private Cliente cliente;
/**
* metodo que controla a listagem de um cliente
* @param cliente
* @return
*/
public String lista(Cliente cliente){
try {
this.clientes = cliente.lista(null);
} catch (SQLException e) {
e.printStackTrace();
return "erro";
}
return "";
}
quando em uma html ou jsp dou o submit para cliente.lista.teste
da o seguinte erro
exception
javax.servlet.ServletException: Servlet.init() for servlet vraptor2 threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.IllegalArgumentException: cant check if br.com.teste.negocio.Uf is a class, unable to load it: java.lang.ClassNotFoundException: br.com.teste.negocio.Uf
org.vraptor.config.Configuration.classIsComponent(Configuration.java:52)
org.vraptor.config.Configuration.readDirectory(Configuration.java:115)
org.vraptor.config.Configuration.readDirectory(Configuration.java:112)
org.vraptor.config.Configuration.readDirectory(Configuration.java:112)
org.vraptor.config.Configuration.readDirectory(Configuration.java:112)
org.vraptor.config.Configuration.readDirectory(Configuration.java:112)
org.vraptor.config.Configuration.readDirectory(Configuration.java:85)
org.vraptor.config.Configuration.autoDiscoverComponents(Configuration.java:157)
org.vraptor.config.Configuration.load(Configuration.java:130)
org.vraptor.webapp.DefaultWebApplication.init(DefaultWebApplication.java:88)
org.vraptor.core.ControllerFactory.configure(ControllerFactory.java:37)
org.vraptor.VRaptorServlet.init(VRaptorServlet.java:43)
javax.servlet.GenericServlet.init(GenericServlet.java:211)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
mas a classe Uf existe ja verifiquei se ela está sendo compilada corretamente… então não consigo encontrar o problema… se alguem puder ajudar, ou se faltar alguma informação…
obrigado
Duran