O tópico está meio parado, mas vamos reanimá-lo.
Estou tentando criar minha primeira aplicação usando o Seam (1.2.1GA) porém estou com alguns problemas.
O ambiente é o Tomcat 5.5.20, o banco de dados é o MySQL 5.0.24a.
Estou usando o JBoss Microcontainer.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
org.hibernate.ejb.HibernatePersistence
java:/lojinhaDatasource
jboss-beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<bean name="lojinhaDatasourceBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="connectionURL">jdbc:mysql://localhost:3306/lojinha</property>
<property name="userName">lojinha</property>
<property name="password">lojinha</property>
<property name="jndiName">java:/lojinhaDatasource</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
<property name="blockingTimeout">1000</property>
<property name="idleTimeout">100000</property>
<property name="transactionManager"><inject bean="TransactionManager"/></property>
<property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
<property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
</bean>
<bean name="lojinhaDatasource" class="java.lang.Object">
<constructor factoryMethod="getDatasource">
<factory bean="lojinhaDatasourceBootstrap"/>
</constructor>
</bean>
O fonte das entidades:
@MappedSuperclass
public class SuperEntidade implements Serializable {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = “NCOD_ID”, nullable = false, insertable = false)
protected Long id;
…
@Entity
@Name(“contato”)
@AttributeOverride(name = “id”, column = @Column(name = “NCOD_ID”))
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = “TB_CT_CONTATO”)
public class Contato extends SuperEntidade {
public static final String[] TIPOS_CONTATOS = {"Pessoa física", "Pessoa Jurídica"};
@Column(name = "CNOM_NOME", nullable = false, length = 150)
@NotNull(message = "Valor requerido.")
protected String nome;
@Column(name = "CTXT_EMAIL", nullable = false, length = 220, unique = true)
@NotNull(message = "Valor requerido.") @Email(message = "O endereço de e-mail deve ser válido.")
protected String mail;
@Column(name = "CTXT_OBS", nullable = true, length = 1500, unique = false)
protected String observacoes;
@Column(name = "CTIP_TIPO_PESSOA", nullable = false, length = 1, unique = false)
@Length(min = 1, max = 1, message = "Tamanho máximo excedido.")
protected String tipo;
…
@Entity
@Name(“pessoa fisica”)
@AttributeOverride(name = “id”, column = @Column(name = “NCOD_ID_CONTATO”))
@PrimaryKeyJoinColumn(name = “NCOD_ID_CONTATO”)
@Table(name = “TB_CT_PESSOA_FISICA”)
public class PessoaFisica extends Contato {
@Column(name = "CNUM_CPF", nullable = false, length = 11, unique = true)
@NotNull(message = "Valor requerido.")
protected String cpf;
@Column(name = "CNUM_RG", nullable = true, length = 10, unique = false)
@NotNull(message = "Valor requerido.")
protected String rg;
@Temporal(TemporalType.DATE)
@Column(name = "DDAT_NASCIMENTO", nullable = false, unique = false)
@NotNull(message = "Valor requerido.")
protected Date dataNascimento;
…
@Entity
@Name(“credencial”)
@AttributeOverride(name = “id”, column = @Column(name = “NCOD_ID_PESSOA_FISICA”))
@PrimaryKeyJoinColumn(name = “NCOD_ID_PESSOA_FISICA”)
@Table(name = “TB_SG_CREDENCIAL”)
public class Credencial extends PessoaFisica {
@Column(name = "CTXT_SENHA", nullable = false, length = 64)
@NotNull(message = "Valor requerido.") @Length(min = 8, max = 100, message = "Tamanho deve estar entre 8 e 100 caracteres.")
protected String senha;
@Column(name = "DDAT_CADASTRO", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
protected Calendar dataCadastro;
@Column(name = "DDAT_MODIFICACAO", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
protected Calendar dataModificacao;
@Column(name = "CURL_AVATAR", nullable = true, length = 256)
protected String urlAvatar;
@Column(name = "NSTA_ADMINISTRADOR", nullable = false)
protected Boolean administrador;
@Column(name = "NSTA_STATUS", nullable = false)
protected Integer status;
…
o form
<h:form>
<table border="0">
<tr>
<td class="cntForm">#{messages.lblContactPFName}</td>
<td class="cntForm">
<h:inputText id="nome" required="true" value="#{credencial.nome}">
<s:validate />
</h:inputText> *
</td>
<td><h:message for="nome" styleClass="cntError" /></td>
</tr>
<tr>
<td>#{messages.lblContactPFCPF}</td>
<td>
<h:inputText id="cpf" required="true" value="#{credential.cpf}">
<s:validate />
</h:inputText> *
</td>
<td><h:message for="cpf" styleClass="cntError" /></td>
</tr>
<tr>
<td>#{messages.lblContactPFRG}</td>
<td>
<h:inputText id="rg" required="true" value="#{credential.rg}">
<s:validate />
</h:inputText> *
</td>
<td><h:message for="rg" styleClass="cntError" /></td>
</tr>
<tr>
<td>#{messages.lblContactPFDtNascimento}</td>
<td>
<h:inputText id="dataNascimento" value="#{credential.dataNascimento}" required="true">
<s:convertDateTime pattern="dd/MM/yyyy"/>
<s:validate />
</h:inputText>
<s:selectDate for="dataNascimento" dateFormat="dd/MM/yyyy" startYear="1970">
<h:graphicImage url="/img/dtpick.gif" style="margin-left:5px;cursor:pointer"/>
</s:selectDate>
</td>
<td><h:message for="dataNascimento" styleClass="cntError" /></td>
</tr>
</table>
<ui:remove><h:commandButton action="prev" value="Voltar" /></ui:remove>
<h:commandButton action="next" value="Avançar" />
</h:form>
Os problemas:
Quando tento inserir dados nos campos e aperto avançar, dá os seguintes erros:
“cpf”: Ocorreu um erro de conversão. (model validation failed)
“rg”: Ocorreu um erro de conversão. (model validation failed)
model validation failed:null (para a data de nascimento)
O que pode estar ocasionando isso?
Não existem erros no console do Tomcat.
Já procurei na web e existem poucas referências sobre o erro para o Seam.