java.lang.Noclassdeffounderror

Asked

Viewed 343 times

0

I am locked in a project that should be a "bank", with an account and transaction CRUD. I have to use Oracle bank because of the facul. This error happens when giving an input to the bank.

Stacktrace:

jun 11, 2017 4:21:58 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
ADVERTÊNCIA: #{contaMB.salvar}: java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiException
javax.faces.FacesException: #{contaMB.salvar}: java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiException
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 29 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.jboss.logging.Logger$1.run(Logger.java:2252)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.logging.Logger.getMessageLogger(Logger.java:2227)
    at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
    at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:142)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at tois.DAO.ContaDAO.adicionar(ContaDAO.java:15)
    at tois.control.ContaMB.salvar(ContaMB.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 30 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jndi.JndiException
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    ... 50 more

Managedbean:

package tois.control;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import tois.DAO.ContaDAO;
import tois.entity.Conta;

@SessionScoped
@ManagedBean
public class ContaMB {

    private String auxUser = "";
    private String auxSenha = "";

    private Conta curConta = new Conta();


    public void setConta(Conta conta) {
        this.curConta = conta;
    }   

    public Conta getConta() {
        return curConta;
    }

    public String login() {
        String pagina = "login";
        curConta = ContaDAO.validar(auxUser, auxSenha);
        if (curConta != null) {
            pagina = "conta?faces-redirect=true";
        } else {
            curConta = new Conta();
            pagina = "login";
        }

        return pagina;
    }

    public String salvar(){
        ContaDAO.adicionar(curConta);
        return "login";
    }

    public String sair(){
        curConta = null;
        return "login";

    }

    public String getAuxUser() {
        return auxUser;
    }

    public void setAuxUser(String auxUser) {
        this.auxUser = auxUser;
    }

    public String getAuxSenha() {
        return auxSenha;
    }

    public void setAuxSenha(String auxSenha) {
        this.auxSenha = auxSenha;
    }

    public Conta getCurConta() {
        return curConta;
    }

    public void setCurConta(Conta curConta) {
        this.curConta = curConta;
    }


}

XHTML:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Cadastro - Banco Tois</title>
</h:head>
<h:body>
    <h1>Cadastro de Conta</h1>
    <p:separator responsive="true" />
    <h:form>

    <p:panelGrid columns="2" responsive="true">

        <p:outputLabel for="inputAgencia" value="Agencia:" />
        <p:inputText id="inputAgencia" value="#{contaMB.curConta.agencia}" readonly="true" />

        <p:outputLabel for="inputConta" value="Conta:" indicateRequired="true" />
        <p:inputText id="inputConta" value="#{contaMB.curConta.conta}" readonly="true" />

    </p:panelGrid>

    <p:separator responsive="true" />

    <p:panelGrid columns="3" responsive="true">

        <p:outputLabel for="inputNome" value="Nome:" />
        <p:inputText id="inputNome" value="#{contaMB.curConta.nome}" />
        <p:message for="inputNome" />

        <p:outputLabel for="inputCPF" value="CPF:" />
        <p:inputMask id="inputCPF" mask="999.999.999-99" value="#{contaMB.curConta.CPF}" />
        <p:message for="inputCPF" />

        <p:outputLabel for="inputRG" value="RG:" />
        <p:inputMask id="inputRG" mask="99.999.999-9" value="#{contaMB.curConta.RG}" />
        <p:message for="inputRG" />

    </p:panelGrid>

    <p:separator responsive="true" />

    <p:outputLabel value="Empregado:" />
    <p:selectOneRadio id="inputEmprego" value="#{contaMB.curConta.emprego}">
            <f:selectItem itemValue="S" itemLabel="Sim" />
            <f:selectItem itemValue="N" itemLabel="Não" />
        </p:selectOneRadio>
        <p:message for="inputTipoConta" />

        <p:outputLabel value="Tipo Conta:" />
        <p:selectOneRadio id="inputTipoConta" value="#{contaMB.curConta.tipoConta}">
            <f:selectItem itemValue="Conta Corrente" itemLabel="Conta Corrente" />
            <f:selectItem itemValue="Conta Poupança" itemLabel="Conta Poupança" />
        </p:selectOneRadio>
        <p:message for="inputTipoConta" />

    <p:separator responsive="true" />


    <p:panelGrid columns="3" responsive="true">

        <p:outputLabel for="inputSenha" value="Senha" />
            <p:password id="inputSenha" value="#{contaMB.curConta.senha}"
                feedback="true" inline="true" promptLabel="Digite sua senha"
                weakLabel="Senha fraca" goodLabel="Senha média"
                strongLabel="Senha forte" />
            <p:message for="inputSenha" />
        </p:panelGrid>

    <p:separator responsive="true" />

    <p:commandButton value="Salvar" action="#{contaMB.salvar}" update="@form" />
    <p:commandButton value="Cancelar" action="Login" immediate="true" />


    </h:form>
</h:body>
</html>
  • Probably some Hibernate dependencies are missing. Are you using Maven? Try to check that all classes are in the classpath.

2 answers

0

If you are using Hibernate-core & Hibernate-entitymanager in your pom.xml, they should have the same version.

   <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.9.Final</version>
    </dependency>


    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.9.Final</version>
    </dependency>

-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.