3
respostas

Não consigo navegar no site.

Senhores, como não consigo instalar o mysql aqui no local onde realizo meus cursos tive que configurar a aplicação para acessar o HSQLDB. Estou utilizando o WildFly com java 8, como pode ser analisado no log não está dando erro para subir o servidor e também verifiquei que as persistencias em banco também estão sendo realizadas, porém, após digitar login e senha a aplicação não me direciona para página livros de acordo com código abaixo : @Named @RequestScoped public class LoginBean {

......................

if (usuarioEncontrado != null && possuiMesmaSenha(usuarioEncontrado)) { usuarioLogado.logar(usuarioEncontrado); System.out.println("Logou!"); return menu.paginaLivros(); }

14:24:38,058 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
14:24:38,223 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
14:24:38,282 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.1.Final "Tweek" starting
14:24:39,155 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found livraria.war in deployment directory. To trigger deployment create a file called livraria.war.dodeploy
14:24:39,187 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
14:24:39,200 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.3.0.Final
14:24:39,206 INFO  [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.3.0.Final
14:24:39,229 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
14:24:39,233 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
14:24:39,237 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
14:24:39,238 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem
14:24:39,245 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
14:24:39,252 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:24:39,252 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]
14:24:39,253 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem
14:24:39,281 INFO  [org.jboss.as.security] (MSC service thread 1-6) JBAS013170: Current PicketBox version=4.0.21.Final
14:24:39,283 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.hsqldb.jdbc.JDBCDriver (version 2.3)
14:24:39,290 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)
14:24:39,309 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = com.hsqldb
14:24:39,309 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = h2
14:24:39,311 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017502: Undertow 1.1.8.Final starting
14:24:39,313 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.8.Final starting
14:24:39,319 INFO  [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service
14:24:39,331 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:24:39,432 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path C:\temp\wildfly-8.2.1.Final/welcome-content
14:24:39,490 INFO  [org.jboss.remoting] (MSC service thread 1-5) JBoss Remoting version 4.0.7.Final
14:24:39,516 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017525: Started server default-server.
14:24:39,526 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017531: Host default-host starting
14:24:39,571 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory C:\temp\wildfly-8.2.1.Final\standalone\deployments
14:24:39,572 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "livraria.war" (runtime-name: "livraria.war")
14:24:39,573 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8084
14:24:39,656 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:24:39,661 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:/livrariaDS]
14:24:39,791 INFO  [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final
14:24:40,325 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for livraria
14:24:40,439 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 1 of 2) Service 'livraria.war#livraria'
14:24:40,478 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 50) HHH000204: Processing PersistenceUnitInfo [
    name: livraria
    ...]
14:24:40,600 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 50) HHH000412: Hibernate Core {4.3.7.Final}
14:24:40,601 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000206: hibernate.properties not found
14:24:40,603 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000021: Bytecode provider name : javassist
14:24:40,724 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016002: Processing weld deployment livraria.war
14:24:40,773 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-8) HV000001: Hibernate Validator 5.1.3.Final
14:24:40,820 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named LivroDao in deployment unit deployment "livraria.war" are as follows:

    java:global/livraria/LivroDao!br.com.caelum.livraria.dao.LivroDao
    java:app/livraria/LivroDao!br.com.caelum.livraria.dao.LivroDao
    java:module/LivroDao!br.com.caelum.livraria.dao.LivroDao
    java:global/livraria/LivroDao
    java:app/livraria/LivroDao
    java:module/LivroDao

14:24:40,820 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named Banco in deployment unit deployment "livraria.war" are as follows:

    java:global/livraria/Banco!br.com.caelum.livraria.dao.Banco
    java:app/livraria/Banco!br.com.caelum.livraria.dao.Banco
    java:module/Banco!br.com.caelum.livraria.dao.Banco
    java:global/livraria/Banco
    java:app/livraria/Banco
    java:module/Banco

14:24:40,820 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named AutorDao in deployment unit deployment "livraria.war" are as follows:

    java:global/livraria/AutorDao!br.com.caelum.livraria.dao.AutorDao
    java:app/livraria/AutorDao!br.com.caelum.livraria.dao.AutorDao
    java:module/AutorDao!br.com.caelum.livraria.dao.AutorDao
    java:global/livraria/AutorDao
    java:app/livraria/AutorDao
    java:module/AutorDao

14:24:40,821 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named UsuarioDao in deployment unit deployment "livraria.war" are as follows:

    java:global/livraria/UsuarioDao!br.com.caelum.livraria.dao.UsuarioDao
    java:app/livraria/UsuarioDao!br.com.caelum.livraria.dao.UsuarioDao
    java:module/UsuarioDao!br.com.caelum.livraria.dao.UsuarioDao
    java:global/livraria/UsuarioDao
    java:app/livraria/UsuarioDao
    java:module/UsuarioDao

14:24:41,104 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016005: Starting Services for CDI deployment: livraria.war
14:24:41,197 INFO  [org.jboss.weld.Version] (MSC service thread 1-6) WELD-000900: 2.2.6 (Final)
14:24:41,219 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment livraria.war
14:24:41,315 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'livraria.war#livraria'
14:24:41,684 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 50) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
14:24:41,787 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
14:24:41,896 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 50) HHH000397: Using ASTQueryTranslatorFactory
14:24:42,139 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 50) HHH000228: Running hbm2ddl schema update
14:24:42,140 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 50) HHH000102: Fetching database metadata
14:24:42,146 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 50) HHH000396: Updating schema
14:24:42,156 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000261: Table found: PUBLIC.PUBLIC.AUTOR
14:24:42,156 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000037: Columns: [nome, id]
14:24:42,156 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000108: Foreign keys: []
14:24:42,157 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000126: Indexes: [sys_idx_sys_pk_10091_10092]
14:24:42,159 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000261: Table found: PUBLIC.PUBLIC.LIVRO
14:24:42,159 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000037: Columns: [titulo, autor_id, id]
14:24:42,159 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000108: Foreign keys: [fk_jv3j1vdenaxujec2bv6clswb1]
14:24:42,160 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000126: Indexes: [sys_idx_10098, sys_idx_sys_pk_10093_10094]
14:24:42,162 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000261: Table found: PUBLIC.PUBLIC.USUARIO
14:24:42,162 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000037: Columns: [senha, id, login]
14:24:42,162 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000108: Foreign keys: []
14:24:42,162 INFO  [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 50) HHH000126: Indexes: [sys_idx_sys_pk_10095_10096]
14:24:42,163 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 50) HHH000232: Schema update complete
14:24:42,567 INFO  [stdout] (ServerService Thread Pool -- 52) [INFO] O Banco acabou de ser criado.

14:24:42,721 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Inicializando Mojarra 2.2.8-jbossorg-1 20140822-1131 para o contexto '/livraria'
14:24:43,688 INFO  [org.primefaces.webapp.PostConstructApplicationEventListener] (MSC service thread 1-4) Running on PrimeFaces 4.0
14:24:43,699 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /livraria
14:24:43,762 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "livraria.war" (runtime-name : "livraria.war")
14:24:43,893 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
14:24:43,893 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:24:43,894 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.1.Final "Tweek" started in 6073ms - Started 351 of 404 services (92 services are lazy, passive or on-demand)
14:29:25,708 INFO  [stdout] (default task-7) [INFO] UsuarioDao foi criado.

14:29:25,933 INFO  [stdout] (default task-7) Hibernate: 
14:29:25,933 INFO  [stdout] (default task-7)     select
14:29:25,933 INFO  [stdout] (default task-7)         usuario0_.id as id1_2_,
14:29:25,933 INFO  [stdout] (default task-7)         usuario0_.login as login2_2_,
14:29:25,933 INFO  [stdout] (default task-7)         usuario0_.senha as senha3_2_ 
14:29:25,933 INFO  [stdout] (default task-7)     from
14:29:25,933 INFO  [stdout] (default task-7)         Usuario usuario0_ 
14:29:25,933 INFO  [stdout] (default task-7)     where
14:29:25,934 INFO  [stdout] (default task-7)         usuario0_.login=?
3 respostas

Opa, para onde vc está sendo redirecionado? Tem como postar o código completo do bean?

Amigo, Não estou sendo direcionado para lugar algum, a validação no banco é realizada mas a página não é direcionada para "return menu.paginaLivros();" if (usuarioEncontrado != null && possuiMesmaSenha(usuarioEncontrado)) { usuarioLogado.logar(usuarioEncontrado); System.out.println("Logou!"); return menu.paginaLivros(); }

Segue Beans : package br.com.caelum.livraria.bean;

import java.util.List;

import javax.enterprise.inject.Model; import javax.inject.Inject;

import br.com.caelum.livraria.dao.AutorDao; import br.com.caelum.livraria.modelo.Autor;

@Model public class AutorBean {

private Autor autor = new Autor(); @Inject private AutorDao dao;

public Autor getAutor() { return autor; }

public void cadastra() { this.dao.salva(autor); this.autor = new Autor(); }

public List getAutores() { return this.dao.todosAutores(); } } package br.com.caelum.livraria.bean;

import java.util.List;

import javax.enterprise.inject.Model; import javax.inject.Inject;

import br.com.caelum.livraria.dao.AutorDao; import br.com.caelum.livraria.dao.LivroDao; import br.com.caelum.livraria.modelo.Autor; import br.com.caelum.livraria.modelo.Livro;

@Model public class LivroBean {

private Livro livro = new Livro(); private Integer autorId;

@Inject private LivroDao livroDao; @Inject private AutorDao autorDao;

public void cadastra() {

Autor autor = this.autorDao.buscaPelaId(this.autorId); this.livro.setAutor(autor);

this.livroDao.salva(livro);

this.livro = new Livro(); }

public List getAutores() { return autorDao.todosAutores(); }

public Livro getLivro() { return livro; }

public void setAutorId(Integer autorId) { this.autorId = autorId; }

public Integer getAutorId() { return autorId; }

public List getLivros() { return this.livroDao.todosLivros(); } } package br.com.caelum.livraria.bean;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped; import javax.inject.Named;

@Named @SessionScoped public class MenuBean implements Serializable {

private static final long serialVersionUID = 1L; private Integer index = 0;

public Integer getIndex() { return index; }

public void setIndex(Integer index) { this.index = index; }

public String paginaLivros() { this.index = 0; return "livros?faces-redirect=true"; }

public String paginaAutores() { this.index = 1; return "autores?faces-redirect=true"; }

public String paginaLogin() { this.index = 0; return "login?faces-redirect=true"; } }

Entendi, bom, olhando o código realmente parece que devia ta rolando a navegação... Vou chutar aqui.. Eu não sei de qual endereço ta vindo sua requisição, então eu chutaria para que os métodos do menu sempre retornassem a string começando com /, para que a navegação sempre seja relativa ao endereço da base da aplicação.

Se esse chute não funcionar, rola compartilhar o código no github, se for possível?