2
respostas

Problemas ao usar tag <h:form>

Toda vez quando tento acessar uma pagina que tenha a tag

aparece esse erro:

HTTP ERROR 500

Problem accessing /fitecproject/index.xhtml. Reason:

Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly? Caused by:

java.lang.IllegalStateException: Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly? at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:47) at org.jboss.weld.Container.instance(Container.java:65) at org.jboss.weld.jsf.ConversationAwareViewHandler.getConversationContext(ConversationAwareViewHandler.java:81) at org.jboss.weld.jsf.ConversationAwareViewHandler.getActionURL(ConversationAwareViewHandler.java:110) at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:250) at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:143) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221) at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:177) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Powered by Jetty://

Para a pagina abrir eu tenho q remover a tag

<h:form id="autor">
                    <p:outputLabel value="Nome:"/> 
                    <p:inputText value="#{loginController.usuario.nome}" >
                    </p:inputText>
                    <p:outputLabel value="email:"/> 
                    <p:inputText value="#{loginController.usuario.email}">
                    </p:inputText>
                    <p:outputLabel value="senha:"/> 

                    <p:inputText value="#{loginController.usuario.senha}">
                    </p:inputText>

                    <p:commandButton actionListener="#{loginController.gravarUsuario}" value="cadastrar"/>

            </h:form>
2 respostas

Posta a sua pagína completa do html

conseguir Alisson, agora estou com o problema para minha classe Bean se comunicar com meu xHTML stou usando Spring como injeção de dependencia:

package br.com.fitecproject.controllers;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;

import br.com.fitecproject.daos.UsuarioDao;
import br.com.fitecproject.models.Usuario;



@Controller
public class LoginController
{
    private Usuario usuario = new Usuario();

    private String mensagem;

    @Inject
    UsuarioDao dao;


    @Transactional
    public void gravarUsuario(){
        this.dao.incluir(usuario);
    }

    public void enviarMensg(){
        this.mensagem = "Olá Mundo";
    }

    public String getMensagem() {
        return mensagem;
    }


}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Hello World!</title>
</h:head>


<h:body>
    <div class="ui-g">
        <div class="ui-g-12">

                tetse
                <p:outputLabel value="#{loginController.enviarMensg}"/>
                <h:form id="autor">
                    <p:outputLabel value="Nome:"/> 
                    <p:inputText value="#{loginController.usuario.nome}" >
                    </p:inputText>
                    <p:outputLabel value="email:"/> 
                    <p:inputText value="#{loginController.usuario.email}">
                    </p:inputText>
                    <p:outputLabel value="senha:"/> 
                    <p:password value="#{loginController.usuario.senha}">
                    </p:password>

                    <p:commandButton actionListener="#{loginController.gravarUsuario}" value="cadastrar"/>

            </h:form>

        </div>
    </div>
</h:body>
</html>