NetBeans + Hibernate + VRaptor + Mysql == erro!

3 respostas
juniorsatanas

Bom senhores do Portal Java, obrigado desde já pela oportunidade, este é meu primeiro post, estou estudando percia, estou usando:

NetBeans + Hibernate + VRaptor + Mysql

estou tentando fazer a loja virtual da Caelum:

mais não consigo percistir minha tabela Usuario:

estar ai meus fontes:
tabela.sql
/***************************************************/
CREATE TABLE banco.Usuario (
id int(11) NOT NULL,
usuario varchar(50) NOT NULL,
senha varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

/*****************************************************/

hibernate.cfg.xml
/*****************************************************/
&lt?xml version=“1.0” encoding=“UTF-8”?&gt
<!DOCTYPE hibernate-configuration PUBLIC
“-//Hibernate/Hibernate Configuration DTD 3.0//EN”
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”>
<hibernate-configuration>
<session-factory>
<property name=“hibernate.connection.driver_class”>
com.mysql.jdbc.Driver
</property>
<property name=“hibernate.connection.url”>
jdbc:mysql://localhost/teste
</property>
<property name=“hibernate.dialect”>
org.hibernate.dialect.MySQLDialect

&lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
	&lt;property name="hibernate.connection.password"&gt;123456&lt;/property&gt;

	&lt;property name="hibernate.show_sql"&gt;false&lt;/property&gt;
	&lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
	&lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.HashtableCacheProvider&lt;/property&gt;

	        &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
                    &lt;property name="hibernate.format_sql"&gt;true&lt;/property&gt;
                    
                    
                    &lt;mapping class="br.com.caelum.lojavirtual.modelo.Usuario"/&gt;
                    
                    
&lt;/session-factory&gt;

</hibernate-configuration>

/************************************************/

varaptor.xml
/*************************************************/
<vraptor>

&lt;component&gt;org.vraptor.util.StatsQuery&lt;/component&gt;

&lt;plugin&gt;org.vraptor.plugin.hibernate.HibernateValidatorPlugin&lt;/plugin&gt;

</vraptor>
/************************************************/

Usuario.java
/***************************************************/
package br.com.caelum.lojavirtual.modelo;

import java.io.Serializable;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.Id;

import javax.persistence.NamedQueries;

import javax.persistence.NamedQuery;

import javax.persistence.Table;

import javax.persistence.*;

/**
  • Classe de entidade Usuario

  • @author root
    
    */
    
    @Entity
    
    @Table(name = Usuario)
    
    @NamedQueries( {
    
    @NamedQuery(name = Usuario.findById, query = SELECT u FROM Usuario u WHERE u.id = :id),
    
    @NamedQuery(name = Usuario.findByUsuario, query = SELECT u FROM Usuario u WHERE u.usuario = :usuario),
    
    @NamedQuery(name = Usuario.findBySenha, query = SELECT u FROM Usuario u WHERE u.senha = :senha)
    
    })
    
    public class Usuario implements Serializable {
    
    @Id
    
    @Column(name = id, nullable = false)
    
    private Integer id;
    

    @Column(name = “usuario”, nullable = false)
    private String usuario;

    @Column(name = “senha”, nullable = false)
    private String senha;

    /** Creates a new instance of Usuario */
    
    public Usuario() {
    
    }
    

    /**

    • Cria uma nova instância de Usuario com os valores especificados.
    • @param id o id do Usuario
      */
      public Usuario(Integer id) {
      this.id = id;
      }

    /**

    • Cria uma nova instância de Usuario com os valores especificados.
    • @param id o id do Usuario
    • @param usuario o usuario do Usuario
    • @param senha o senha do Usuario
      */
      public Usuario(Integer id, String usuario, String senha) {
      this.id = id;
      this.usuario = usuario;
      this.senha = senha;
      }

    /**

    • Define o id deste Usuario.
    • @return o id
      */
      public Integer getId() {
      return this.id;
      }

    /**

    • Define o id deste Usuario para o valor especificado.
    • @param id o novo id
      */
      public void setId(Integer id) {
      this.id = id;
      }

    /**

    • Define o usuario deste Usuario.
    • @return o usuario
      */
      public String getUsuario() {
      return this.usuario;
      }

    /**

    • Define o usuario deste Usuario para o valor especificado.
    • @param usuario o novo usuario
      */
      public void setUsuario(String usuario) {
      this.usuario = usuario;
      }

    /**

    • Define o senha deste Usuario.
    • @return o senha
      */
      public String getSenha() {
      return this.senha;
      }

    /**

    • Define o senha deste Usuario para o valor especificado.
    • @param senha o novo senha
      */
      public void setSenha(String senha) {
      this.senha = senha;
      }

    /**

    • Retorna um valor de código hash para o objeto. Esta implementação computa
    • um valor de código hash baseado nos campos id deste objeto.
    • @return um valor de código hash para este objeto.
      */
      @Override
      public int hashCode() {
      int hash = 0;
      hash += (this.id != null ? this.id.hashCode() : 0);
      return hash;
      }

    /**

    • Determina se outro objeto é igual a este Usuario. O resultado é
    • <code>true</code> se e somente se o argumento não for nulo e for um objeto Usuario o qual
    • tem o mesmo valor para o campo id como este objeto.
    • @param object o objeto de referência com o qual comparar
    • @return <code>true</code> se este objeto é o mesmo como o argumento;
    • <code>false</code> caso contrário.
      */
      @Override
      public boolean equals(Object object) {
      // TODO: Warning - this method won’t work in the case the id fields are not set
      if (!(object instanceof Usuario)) {
      return false;
      }
      Usuario other = (Usuario)object;
      if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
      return true;
      }

    /**

    • Retorna uma representação literal deste objeto. Esta implementação cria
    • uma representação baseada nos campos id.
    • @return uma representação literal deste objeto.
      */
      @Override
      public String toString() {
      return “br.com.caelum.lojavirtual.modelo.Usuario[id=” + id + “]”;
      }
    public void setLogin(String string) {
    
    throw new UnsupportedOperationException(Not yet implemented);
    
    }
    
    public boolean getLogin() {
    
    return false;
    
    }
    

}
/**********************************************/

mais não funciona !

3 Respostas

ricardolecheta

e qual o erro?

juniorsatanas

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException

org.vraptor.VRaptorServlet.service(VRaptorServlet.java:95)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

root cause

org.vraptor.reflection.SettingException

org.vraptor.reflection.JPathExecutor.internalSet(JPathExecutor.java:199)

org.vraptor.reflection.JPathExecutor.set(JPathExecutor.java:102)

org.vraptor.introspector.BasicIntrospector.readParameters(BasicIntrospector.java:81)

org.vraptor.interceptor.SettingAndValidationInterceptor.intercept(SettingAndValidationInterceptor.java:98)

org.vraptor.core.InterceptorsLogicFlow.execute(InterceptorsLogicFlow.java:72)

org.vraptor.interceptor.InjectionInterceptor.intercept(InjectionInterceptor.java:41)

org.vraptor.core.InterceptorsLogicFlow.execute(InterceptorsLogicFlow.java:72)

org.vraptor.interceptor.ComponentLookupInterceptor.intercept(ComponentLookupInterceptor.java:58)

org.vraptor.core.InterceptorsLogicFlow.execute(InterceptorsLogicFlow.java:72)

org.vraptor.interceptor.RegisterAttributesInteceptor.intercept(RegisterAttributesInteceptor.java:38)

org.vraptor.core.InterceptorsLogicFlow.execute(InterceptorsLogicFlow.java:72)

org.vraptor.core.VRaptorExecution.execute(VRaptorExecution.java:88)

org.vraptor.core.DefaultController.execute(DefaultController.java:42)

org.vraptor.VRaptorServlet.service(VRaptorServlet.java:70)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Apache Tomcat/5.5.17

UsuarioLogic.java


package br.com.caelum.lojavirtual.logic;

import br.com.caelum.lojavirtual.modelo.Usuario;
import org.vraptor.annotations.Component;

/**
*

  • @author root
    */
    @Component
    public class UsuarioLogic {
    public void adiciona (Usuario usuario) {
    // … logica de adicionar no banco aqui …
    System.out.println("Adiciona usuario " + usuario.getLogin());
    }
    }

index.jsp


<form action=“usuario.adiciona.logic”>

Login: <input type=“text” name=“usuario.login” />


Senha: <input type=“text” name=“usuario.senha” />


<input type=“submit” />

</form>

formulario.ok.jsp


<%<a class="mention" href="/u/page">@page</a> pageEncoding=“UTF-8” contentType=“text/html; charset=UTF-8 %>

<html>

<head>

<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”/>

<title>Cadastro de usuarios</title>

<link rel=“stylesheet” type=“text/css” href=“css/style.css”/>

</head>

<body>

<h1>Cadastro de usuarios</h1>

<form action=“usuario.adiciona.logic”>

Login: <input type=“text” name=“usuario.login” />


Senha: <input type=“text” name=“usuario.senha” />


<input type=“submit” />

</form>

</body>

</html>

juniorsatanas

Ricardo tu já fez essa loja virtual ca caelum ?

Criado 25 de junho de 2007
Ultima resposta 25 de jun. de 2007
Respostas 3
Participantes 2