Samuel-Oliveira / Java_NFe

Projeto Open Source Java - NFe, NFce
MIT License
576 stars 227 forks source link

Problema ao Consultar Status do Serviço ou enviar NF-e no estado de MG #194

Closed GustavoAlves1993 closed 4 years ago

GustavoAlves1993 commented 4 years ago

Bom dia Samuel, estou enfrentando uma dificuldade ao tentar consultar status do serviço ou ao enviar NF-e no estado de MG, uma curiosidade é que a NFC-e está sendo emitida normalmente, dei uma pesquisada e fiz alguns testes porém não obtive sucesso até o momento, segue log da biblioteca para analise:

[06/04/20-10:29:47][br.com.swconsultoria.nfe.Status][XML-ENVIO]: <?xml version=" 1.0" encoding="UTF-8"?>131STATUS

20/06/04 10:29:48 WARN dialect.StAXDialectDetector: Unable to determine dialect of the StAX implementation at jar:file:/C:/Onesys/ConneXOne/lib/java-nfe-4.00.12 .jar!/

ERVICO: https://nfe.fazenda.mg.gov.br/nfe2/services/NFeStatusServico4 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: I/O exception (org.apache. axis2.AxisFault) caught when processing request: Connection has been shutdown: j avax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: P KIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcep tion: unable to find valid certification path to requested target 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: Retrying request 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: I/O exception (org.apache. axis2.AxisFault) caught when processing request: Connection has been shutdown: j avax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: P KIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcep tion: unable to find valid certification path to requested target 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: Retrying request 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: I/O exception (org.apache. axis2.AxisFault) caught when processing request: Connection has been shutdown: j avax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: P KIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcep tion: unable to find valid certification path to requested target 20/06/04 10:29:49 INFO httpclient.HttpMethodDirector: Retrying request 20/06/04 10:29:49 INFO httpclient3.HTTPSenderImpl: Unable to sendViaPost to url[ https://nfe.fazenda.mg.gov.br/nfe2/services/NFeStatusServico4] org.apache.axis2.AxisFault: Connection has been shutdown: javax.net.ssl.SSLHands hakeException: sun.security.validator.ValidatorException: PKIX path building fai led: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMess ageFormatter.java:78) at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRe questEntity.java:85) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequ estBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodB ase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.j ava:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Htt pMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMe thodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav a:397) at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.execu teMethod(HTTPSenderImpl.java:872) at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendV iaPost(HTTPSenderImpl.java:212) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessa geWithCommons(CommonsHTTPTransportSender.java:403) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(Com monsHTTPTransportSender.java:234) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisO peration.java:399) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(Out InAxisOperation.java:225) at org.apache.axis2.client.OperationClient.execute(OperationClient.java: 150) at br.com.swconsultoria.nfe.wsdl.NFeStatusServico4.NFeStatusServico4Stub .nfeStatusServicoNF(NFeStatusServico4Stub.java:167) at br.com.swconsultoria.nfe.Status.statusServico(Status.java:80) at br.com.swconsultoria.nfe.Nfe.statusServico(Nfe.java:60) at br.com.odbo.ModuloNFe40.NFe_ConsultaStatus.NFeConsultaStatusServico.c onsultaStatusServico(NFeConsultaStatusServico.java:41) at br.com.odbo.ModuloNFe40.NFe_UI.ExibeInfosNFe$ChecaStatus.run(ExibeInf osNFe.java:200) at java.lang.Thread.run(Unknown Source) Caused by: com.ctc.wstx.exc.WstxIOException: Connection has been shutdown: javax .net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException : unable to find valid certification path to requested target at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:261) at org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWrite r.java:231) at org.apache.axiom.om.impl.MTOMXMLStreamWriter.close(MTOMXMLStreamWrite r.java:223) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod $org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom_omimpl intf_AxiomContainer$serializeAndConsume(AxiomContainerSupport.aj:324) at org.apache.axiom.om.impl.llom.OMElementImpl.serializeAndConsume(OMEle mentImpl.java:1) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMess ageFormatter.java:74) ... 22 more Caused by: javax.net.ssl.SSLException: Connection has been shutdown: javax.net.s sl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path b uilding failed: sun.security.provider.certpath.SunCertPathBuilderException: unab le to find valid certification path to requested target at sun.security.ssl.SSLSocketImpl.checkEOF(Unknown Source) at sun.security.ssl.SSLSocketImpl.checkWrite(Unknown Source) at sun.security.ssl.AppOutputStream.write(Unknown Source) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.flush(Unknown Source) at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutput Stream.java:191) at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:103) at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)

    at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:259)
    ... 27 more

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.Validator Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPath BuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) at sun.security.ssl.Handshaker.processLoop(Unknown Source) at sun.security.ssl.Handshaker.process_record(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source ) at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source) at sun.security.ssl.AppOutputStream.write(Unknown Source) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.flush(Unknown Source) at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutput Stream.java:191) at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:103) at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)

    at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:259)
    at org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWrite

r.java:231) at org.apache.axiom.om.impl.common.AxiomSerializableSupport.ajc$interMet hod$org_apache_axiom_om_impl_common_AxiomSerializableSupport$org_apache_axiom_om _impl_intf_AxiomSerializable$serialize(AxiomSerializableSupport.aj:50) at org.apache.axiom.om.impl.llom.OMSerializableImpl.serialize(OMSerializ ableImpl.java:1) at org.apache.axiom.om.impl.common.AxiomSerializableSupport.ajc$interMet hodDispatch1$org_apache_axiom_om_impl_common_AxiomSerializableSupport$org_apache _axiom_om_impl_intf_AxiomSerializable$serialize(AxiomSerializableSupport.aj) at org.apache.axiom.om.impl.common.AxiomSerializableSupport.ajc$interMet hod$org_apache_axiom_om_impl_common_AxiomSerializableSupport$org_apache_axiom_om _impl_intf_AxiomSerializable$serialize(AxiomSerializableSupport.aj:33) at org.apache.axiom.om.impl.llom.OMSerializableImpl.serialize(OMSerializ ableImpl.java:1) at br.com.swconsultoria.nfe.wsdl.NFeStatusServico4.NFeStatusServico4Stub $NfeDadosMsg.serialize(NFeStatusServico4Stub.java:953) at br.com.swconsultoria.nfe.wsdl.NFeStatusServico4.NFeStatusServico4Stub $NfeDadosMsg.serialize(NFeStatusServico4Stub.java:921) at org.apache.axis2.databinding.ADBDataSource.serialize(ADBDataSource.ja va:49) at org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer.s erializePushOMDataSource(StAXSerializer.java:53) at org.apache.axiom.om.impl.common.serializer.push.Serializer.serialize( Serializer.java:293) at org.apache.axiom.om.impl.common.AxiomSourcedElementSupport.ajc$interM ethod$org_apache_axiom_om_impl_common_AxiomSourcedElementSupport$org_apache_axio m_om_impl_intf_AxiomSourcedElement$internalSerialize(AxiomSourcedElementSupport. aj:434) at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize( OMSourcedElementImpl.java:1) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod $org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom_omimpl intf_AxiomContainer$serializeChildren(AxiomContainerSupport.aj:362) at org.apache.axiom.om.impl.llom.OMElementImpl.ajc$interMethodDispatch2$ org_apache_axiom_om_impl_common$serializeChildren(OMElementImpl.java:1) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod Dispatch1$org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom _om_impl_intf_AxiomContainer$serializeChildren(AxiomContainerSupport.aj) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$o rg_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf _AxiomElement$defaultInternalSerialize(AxiomElementSupport.aj:519) at org.apache.axiom.om.impl.llom.OMElementImpl.defaultInternalSerialize( OMElementImpl.java:1) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethodDi spatch1$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiomom impl_intf_AxiomElement$defaultInternalSerialize(AxiomElementSupport.aj) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$o rg_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf _AxiomElement$internalSerialize(AxiomElementSupport.aj:513) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMEleme ntImpl.java:1) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod $org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom_omimpl intf_AxiomContainer$serializeChildren(AxiomContainerSupport.aj:362) at org.apache.axiom.om.impl.llom.OMElementImpl.ajc$interMethodDispatch2$ org_apache_axiom_om_impl_common$serializeChildren(OMElementImpl.java:1) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod Dispatch1$org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom _om_impl_intf_AxiomContainer$serializeChildren(AxiomContainerSupport.aj) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$o rg_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf _AxiomElement$defaultInternalSerialize(AxiomElementSupport.aj:519) at org.apache.axiom.om.impl.llom.OMElementImpl.defaultInternalSerialize( OMElementImpl.java:1) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethodDi spatch1$org_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiomom impl_intf_AxiomElement$defaultInternalSerialize(AxiomElementSupport.aj) at org.apache.axiom.om.impl.common.AxiomElementSupport.ajc$interMethod$o rg_apache_axiom_om_impl_common_AxiomElementSupport$org_apache_axiom_om_impl_intf _AxiomElement$internalSerialize(AxiomElementSupport.aj:513) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SO APEnvelopeImpl.java:159) at org.apache.axiom.om.impl.common.AxiomContainerSupport.ajc$interMethod $org_apache_axiom_om_impl_common_AxiomContainerSupport$org_apache_axiom_omimpl intf_AxiomContainer$serializeAndConsume(AxiomContainerSupport.aj:319) ... 24 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali d certification path to requested target at sun.security.validator.PKIXValidator.doBuild(Unknown Source) at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) at sun.security.validator.Validator.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Sour ce) ... 68 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Sourc e) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) at java.security.cert.CertPathBuilder.build(Unknown Source) ... 74 more [06/04/20-10:29:49][br.com.odbo.ModuloNFe40.NFe_ConsultaStatus.NFeConsultaStatus Servico consultaStatusServico]null

arimolo commented 4 years ago

Mesmo problema aqui. Conseguiu solução?

GustavoAlves1993 commented 4 years ago

Até o presente momento ainda não

arimolo commented 4 years ago

@Samuel-Oliveira consegue dar um help, por favor?

Samuel-Oliveira commented 4 years ago

Bom dia, isso já foi corrigido a uma semana! Usem a versão SANPSHOT do maven. Caso usem external jar : https://drive.google.com/file/d/1YFXip83HH3O0f_jwbLPxwoV4Sl2-jv6r/view?usp=sharing

arimolo commented 4 years ago

@Samuel-Oliveira, bom dia. Na minha aplicação já estou usando:

     <dependency>
        <groupId>br.com.swconsultoria</groupId>
        <artifactId>java-nfe</artifactId>
        <version>4.00.14-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>br.com.swconsultoria</groupId>
        <artifactId>java_certificado</artifactId>
        <version>2.3</version>
    </dependency>

Mas permaneço com o problema (somente para chaves de MG, iniciadas em 31):

2020-06-08 10:42:34 INFO o.a.a.t.h.i.h.HTTPSenderImpl - Unable to sendViaPost to url[https://nfe.fazenda.mg.gov.br/nfe2/services/NFeConsultaProtocolo4] org.apache.axis2.AxisFault: Connection or outbound has closed at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:78) at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:85) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.executeMethod(HTTPSenderImpl.java:872) at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:212) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150) at br.com.swconsultoria.nfe.wsdl.NFeConsultaProtocolo.NFeConsultaProtocolo4Stub.nfeConsultaNF(NFeConsultaProtocolo4Stub.java:167) at br.com.swconsultoria.nfe.ConsultaXml.consultaXml(ConsultaXml.java:63) at br.com.swconsultoria.nfe.Nfe.consultaXml(Nfe.java:74)

arimolo commented 4 years ago

@GustavoAlves1993, no seu caso, você também já está rodando com a versão 4.00.14-SNAPSHOT?

Samuel-Oliveira commented 4 years ago

Tudo Bom @arimolo ? 1º Não use as importações separadas, Java Certificado ja esta dentro do NFe, e não precisa ser importada separadamente. 2º Vc usa alguma outra biblioteca minha? CTe? MDFe? Todas elas possuem Cacert e precisam ser atualizadas para funcionar.

Todos que usam a versão SNAPSHOT resolveu o problema. então verifique cache, ou se vc informa outros arquivos de CACERT.

GustavoAlves1993 commented 4 years ago

@arimolo não, eu estava usando a versão 4.00.12 quando deu o problema, atualizei para versão 4.00.13 e o problema continuou. Vou usar agora a versão 4.00.14-SNAPSHOT e passo um feedback

arimolo commented 4 years ago

@Samuel-Oliveira, foi batata!! Estava usando a sua lib CTe com versão mais antiga. Você é o cara!! Muito obrigado!!

Samuel-Oliveira commented 4 years ago

@GustavoAlves1993 Só confirma e fecha o Issue por favor! Abraços!

Samuel-Oliveira commented 4 years ago

Fechado por não ter resposta,

GustavoAlves1993 commented 4 years ago

@Samuel-Oliveira desculpe a demora no feedback porém só consegui testar hoje, deu tudo certo após a atualização da biblioteca, obrigado.

Abraços