我需要帮助才能显示电子书Algaworks的咨询结果页面。欢迎任何帮助!
控制台(日志文件)
jul 25, 2016 10:42:45 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
ADVERTÊNCIA: #{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
javax.faces.FacesException: #{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UIViewAction.broadcast(UIViewAction.java:559)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
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:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
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: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:94)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 28 more
Caused by: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 29 more
jul 25, 2016 10:42:45 PM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073: javax.faces.FacesException obtido durante o processamento de INVOKE_APPLICATION 5: UIComponent-ClientId=, Message=#{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
jul 25, 2016 10:42:45 PM com.sun.faces.context.ExceptionHandlerImpl log
1100: #{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
javax.faces.FacesException: #{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
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.FacesException: #{consultaLancamentosBean.consultar}: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UIViewAction.broadcast(UIViewAction.java:559)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
... 24 more
Caused by: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:94)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 28 more
Caused by: javax.el.PropertyNotFoundException: /ConsultaLancamentos.xhtml @10,65 action="#{consultaLancamentosBean.consultar}": Target Unreachable, identifier 'consultaLancamentosBean' resolved to null
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 29 more
---> Persistence.xml(/ src / main / resources / META-INF):
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="FinanceiroPU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.janaina.financeiro.model.Pessoa</class>
<class>com.janaina.financeiro.model.Lancamento</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/financeiro" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="postgres" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
---&GT; ConsultaLacamentos.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Consulta de lançamentos</title>
</h:head>
<h:body>
<f:metadata>
<f:viewAction action="#{consultaLancamentosBean.consultar}" />
</f:metadata>
<h1>Consulta de lançamentos</h1>
<h:form id="frm">
<h:dataTable value="#{consultaLancamentosBean.lancamentos}"
var="lancamento" border="1" cellspacing="0" cellpadding="2">
<h:column>
<f:facet name="header">
<h:outputText value="Pessoa" />
</f:facet>
<h:outputText value="#{lancamento.pessoa.nome}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Descrição" />
</f:facet>
<h:outputText value="#{lancamento.descricao}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Tipo" />
</f:facet>
<h:outputText value="#{lancamento.tipo}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Valor" />
</f:facet>
<h:outputText value="#{lancamento.valor}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Data de vencimento" />
</f:facet>
<h:outputText value="#{lancamento.dataVencimento}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Data de pagamento" />
</f:facet>
<h:outputText value="#{lancamento.dataPagamento}" />
</h:column>
</h:dataTable>
</h:form>
</h:body>
</html>
---&GT; ConsultaLacamentosBean.java
package com.janaina.financeiro.controller;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.view.ViewScoped;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import com.janaina.financeiro.model.Lancamento;
import com.janaina.financeiro.util.JpaUtil;
@ManagedBean
@ViewScoped
public class ConsultaLancamentosBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<Lancamento> lancamentos;
public void consultar() {
EntityManager manager = JpaUtil.getEntityManager();
TypedQuery<Lancamento> query = manager.createQuery("from Lancamento", Lancamento.class);
this.lancamentos = query.getResultList();
manager.close();
}
public List<Lancamento> getLancamentos() {
return lancamentos;
}
}
---&GT; JpaUtil.java
package com.janaina.financeiro.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
//JpaUtil armazena a instância compartilhada de EntityManagerFactory em uma variável estática
//Qualquer código terá acesso fácil e rápido
//Sempre que for preciso uma EntityManager basta chamar:
//EntityManager manager = JpaUtil.getEntityManager();
public class JpaUtil {
private static EntityManagerFactory factory;
static {
factory = Persistence.createEntityManagerFactory("FinanceiroPU");
}
public static EntityManager getEntityManager() {
return factory.createEntityManager();
}
}
答案 0 :(得分:0)
我解决了这个问题!我意识到我的问题的原因是:
1)我在项目中使用Java JRE而不是JDK。为了解决这个问题,我做了以下工作:Rigth-点击Project&gt;性状&gt; Java构建路径&gt;库和GT;我正在使用的选定JRE&gt;编辑&gt;已安装的JRE&gt;搜索&GT; JDK路径(C:\ Program Files \ Java \ jdk1.8.0_101)。
2)然后我意识到我无法连接到PostgreSQL。然后我卸载了PostgreSQL并删除了Program Files中的目录,然后重新安装了!
3)最后:右键单击Project&gt;以&gt;运行行家&GT; Maven Clean然后Rigth-点击Project&gt;以&gt;运行行家&GT; Maven安装
上述步骤对我有用..我希望他们帮助别人!
我的(web.xml):
Shown
的persistence.xml:
import os
import zipfile
import csv
import glob
currentPath = r"K:\BsbProd\BSBCHS\BSB_4_Release"
for zip in glob.glob('{}/*.zip'.format(currentPath)):
zf = zipfile.ZipFile(os.path.join(currentPath, zip), 'r')
for each in [n for n in zf.namelist() if n.lower().endswith('.kap')]:
currentFile = zf.open(each).readlines()
writer = csv.writer(open(r"C:\Users\PalmerDa\Desktop\BSB2{}.csv".format(os.path.basename(each)), "wb"))
plys = [r for r in currentFile if r.startswith('PLY')]
for rr in plys:
col1, col2 = rr.split(",")[1:]
rows = float(col1), float(col2)
writer.writerow(rows)
if plys[0] != plys[-1]:
writer.writerow((float(plys[0].split(",")[1]),float(plys[0].split(",")[2])))