Problemas ao Gerar PDF de única linha de um datatable com Ireport no JavaWeb[RESOLVIDO]

Pessoal, estou com um problema ao tentar gerar um relatório no formato pdf utilizando um projeto java web com maven e o jasperReports/ireport. A principio seguir um video tutorial de um rapaz. https://www.youtube.com/watch?v=fEwB7JWa7DE
A principio meu erro era que o commandbutton não chamava o método para que pudesse ser gerado o relatório, depois notei que o command só chama o método se estiver “tudo ok” na pagina. Então em um certo fórum vi que “não é correto colocar um form dentro de outro” que no meu caso eu tinha. Eis que removi um form de dentro do outro, mas agora o dialog (para confirmação e que repassa as informações para a lista que posteriormente é utilizada para gerar o pdf de um unico objeto) não consegue receber as informações e caio em um nullpointer.
Agradeço quem puder me ajudar.
Estou repassando o código da página, o bean e a classe que gera o relatório.

Página

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template/Adm_Layout.xhtml">

    <ui:define name="content">
        <h1 class="aw-page-title">Portarias</h1>

        <p:growl id="growl"/>
<f:metadata>
        <f:viewAction action="#{MBportaria.listarTodasPortarias()}">  </f:viewAction>    
    </f:metadata>

    <p:messages  id="messages" autoUpdate="true" closable="true" showDetail="true" />
    <p:panelGrid columns="1"  layout="grid"  styleClass="panelgrid-noborder" >
        <h:form id="Portarias" >
            <p:dataTable var="portaria" value="#{MBportaria.listaPDFPortaria}" 
                         paginator="true" selectionMode="single" selection="#{MBportaria.portaria}" rowKey="#{portaria.pkPortaria}" >

                <f:facet name="header">
                    Portarias
                </f:facet>
                <p:ajax event="rowSelect" update=":Portarias" />

                <p:column headerText="Número" width="50" >
                    <p:outputLabel value="#{portaria.numeroPortaria}" />
                </p:column>

                <p:column headerText="Ementa" >
                    <p:outputLabel value="#{portaria.ementaPortaria}" />
                </p:column>

                <p:column headerText="Título do Projeto" >
                    <p:outputLabel value="#{portaria.tituloProjetoPortaria}" />
                </p:column>

                <p:column headerText="Projeto" >
                    <p:outputLabel value="#{portaria.projetoPortaria}" />
                </p:column>

                <p:column headerText="Professor Coordenador" >
                    <p:outputLabel value="#{portaria.professorCoordenador}" />
                </p:column>

                <p:column headerText="Professor Coordenador" >
                    <p:outputLabel value="#{portaria.siapeCoordenador}"/>
                </p:column>

                <p:column headerText="Vigêcia Início" >
                    <p:outputLabel value="#{portaria.inicioVigencia}" />
                </p:column>

                <p:column headerText="Vigêcia Fim" >
                    <p:outputLabel value="#{portaria.fimVigencia}" />
                </p:column>

                <p:column headerText="Status">
                    <p:outputLabel value="#{portaria.statusPortaria}"/>
                </p:column>

                <!--BOTÃO PARA gerar o pdf para uma unica linha da tabela :D -->     
                <p:column headerText="Ações" style="width: 120px; text-align: center;" >
                    <p:commandButton icon="ui-icon-print"  oncomplete="PF('portariaDialog').show()" update=":formPortaria" title="Gerar PDF">
                        <f:setPropertyActionListener value="#{portaria}" target="#{MBportaria.portaria}"/>
                    </p:commandButton>

                    <!--BOTÃO PARA EDIÇÃO-->
                    <p:commandButton icon="fa fa-pencil-square-o"  oncomplete="PF('portariaEditDialog').show()" update=":formEditPortaria" title="Editar">
                        <f:setPropertyActionListener value="#{portaria}" target="#{MBportaria.portaria}"/>
                    </p:commandButton>

                    <!--BOTÃO DE EXCLUSÃO-->
                    <p:commandButton icon="fa fa-trash-o" title="Deletar" action="#{MBportaria.deletarPortaria()}" update="@form, :Portarias, :growl"/>
                </p:column>
            </p:dataTable>
        </h:form>


        <!--DIALOG PARA GERAR O PDF-->
        <p:dialog widgetVar="portariaDialog" header="Gerar PDF" modal="true" dynamic="true" resizable="false" width="600">
            <h:form id="formPortaria">
                <p:panelGrid columns="2">
                    <p:outputLabel value="Numero Portaria"/>
                    <p:inputText value="#{portaria.numeroPortaria}" disabled="true"/>
                    <p:outputLabel value="Ementa Portaria"/>
                    <p:inputText value="#{portaria.ementaPortaria}" disabled="true"/>
                    <p:outputLabel value="Título"/>
                    <p:inputText value="#{portaria.tituloProjetoPortaria}" disabled="true"/>
                    <p:outputLabel value="Projeto"/>
                    <p:inputText value="#{portaria.projetoPortaria}" disabled="true"/>
                    <p:outputLabel value="Professor Coordenador"/>
                    <p:inputText value="#{portaria.professorCoordenador}" disabled="true"/>
                    <p:outputLabel value="Siape Prof. Coord."/>
                    <p:inputText value="#{portaria.siapeCoordenador}" disabled="true"/>
                    <p:outputLabel value="Vigência Inicio"/>
                    <p:inputText value="#{portaria.inicioVigencia}" disabled="true"/>
                    <p:outputLabel value="Vigência Fim"/>
                    <p:inputText value="#{portaria.fimVigencia}" disabled="true"/>
                    <p:outputLabel value="Status"/>
                    <p:inputText value="#{portaria.statusPortaria}" disabled="true"/>

                </p:panelGrid> 
                <p:fieldset>
                    <p:commandButton value="Imprimir"  ajax="false" action="#{MBportaria.imprimirUnicoItem()}" oncomplete="PF('portariaDialog').hide()"
                                     update="@form, :Portarias" onclick="this.form.target = '_blank'"/>
                    <p:commandButton value="Fechar" oncomplete="PF('portariaDialog').hide()" update="@form, :Portarias" />
                </p:fieldset>
            </h:form>
        </p:dialog>                     

        <!--DIALOG PARA EDIÇÃO-->
        <p:dialog widgetVar="portariaEditDialog" header="EDITAR PORTARIA" modal="true" dynamic="true" resizable="false" width="600">
            <h:form id="formEditPortaria">
                <p:panelGrid columns="2">
                    <p:outputLabel value="Numero Portaria"/>
                    <p:inputText value="#{portaria.numeroPortaria}"/>
                    <p:outputLabel value="Ementa Portaria"/>
                    <p:inputText value="#{portaria.ementaPortaria}" />
                    <p:outputLabel value="Título"/>
                    <p:inputText value="#{portaria.tituloProjetoPortaria}" />
                    <p:outputLabel value="Projeto"/>
                    <p:inputText value="#{portaria.projetoPortaria}" />
                    <p:outputLabel value="Professor Coordenador"/>
                    <p:inputText value="#{portaria.professorCoordenador}" />
                    <p:outputLabel value="Siape Prof. Coord."/>
                    <p:inputText value="#{portaria.siapeCoordenador}" />
                    <p:outputLabel value="Vigência Inicio"/>
                    <p:inputText value="#{portaria.inicioVigencia}" />
                    <p:outputLabel value="Vigência Fim"/>
                    <p:inputText value="#{portaria.fimVigencia}" />
                    <p:outputLabel value="Status"/>
                    <p:inputText value="#{portaria.statusPortaria}" />

                </p:panelGrid> 
                <p:fieldset>
                    <p:commandButton value="Editar"  ajax="false" action="#{MBportaria.editarPortaria()}" oncomplete="PF('portariaEditDialog').hide()"
                                     update="@form, :Portarias"/>
                    <p:commandButton value="Fechar" oncomplete="PF('portariaEditDialog').hide()" update="@form, :Portarias" />
                </p:fieldset>
            </h:form>
        </p:dialog>

    </p:panelGrid>

</ui:define>

</ui:composition>

Bean

package com.ufpa.scontroleportaria.bean;

import com.ufpa.scontroleportaria.model.Portaria;
import com.ufpa.scontroleportaria.controller.PortariaList;
import com.ufpa.scontroleportaria.relatorio.GerarPDFPortaria;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author andreismiths
 */
@ManagedBean(name = "MBportaria")
@ViewScoped
public class MBportaria extends AbstractBean implements Serializable {

    private Portaria portaria;
    private PortariaList objListPortaria;
    private List<Portaria> listaPDFPortaria = new ArrayList<Portaria>();

    public void cadastrarPortaria() {
        try {
            getDaoGenerico().save(portaria);
            getObjMessage().info("Cadastro efetuado!", "Portaria cadastrada com sucesso!");
        } catch (Exception e) {
            getObjMessage().warn("Cadastro não efetuado!", "O cadastro não foi realizado");
        }

    }

    public void editarPortaria() {
        try {

            getDaoGenerico().update(portaria);
            getObjMessage().info("Portaria Atualizada!", "Com sucesso!");
            listarTodasPortarias();
        } catch (Exception e) {
            getObjMessage().warn("ERRO na Atualização Efetuada!", "Erro na atualização!");
        }

    }

    public void deletarPortaria() {
        try {
            getDaoGenerico().remove(portaria);
            getObjMessage().info("Portaria Excluída!", "Com sucesso!");
            listarTodasPortarias();
        } catch (Exception e) {
            getObjMessage().warn("ERRO na Exclusão Efetuada!", "Erro na Exclusão!");
        }

    }

    public void listarTodasPortarias() {
        try {
            listaPDFPortaria = getDaoGenerico().list("SELECT p FROM Portaria p");
            getObjMessage().info("Exibindo Portarias", "Todas as Portarias estão sendo listadas!");
        } catch (Exception e) {
            getObjMessage().warn("Lista Inexistente", "Adicione Itens realizando um Novo Cadastro");
        }

    }
    //gera pdf de todas as portarias do banco 

    public void gerarPDF() {
        GerarPDFPortaria gerarPDFPortaria = new GerarPDFPortaria();
        gerarPDFPortaria.getRelatorio(listaPDFPortaria);
    }
//gera pdf de uma portaria apenas, uma unica linha
    public void imprimirUnicoItem() {
        System.out.println("1111111111");
        GerarPDFPortaria gerarPDFPortaria = new GerarPDFPortaria();
        System.out.println("2222222222");
        List<Portaria> item = new ArrayList<>();
        System.out.println("3333333333");
        item.add(portaria);
        System.out.println("4444444444");
        gerarPDFPortaria.getRelatorio(item);
        System.out.println("5555555555");
    }

    public Portaria getPortaria() {
        if (portaria == null) {
            portaria = new Portaria();
        }
        return portaria;
    }

    public void setPortaria(Portaria portaria) {
        this.portaria = portaria;
    }

    public PortariaList getObjListPortaria() {
        if (objListPortaria == null) {
            objListPortaria = new PortariaList();
        }
        return objListPortaria;
    }

    public List<Portaria> getListaPDFPortaria() {
        return listaPDFPortaria;
    }

    public void setListaPDFPortaria(List<Portaria> listaPDFPortaria) {
        this.listaPDFPortaria = listaPDFPortaria;
    }

}

Classe que gera o relatório

package com.ufpa.scontroleportaria.relatorio;


import com.ufpa.scontroleportaria.model.Portaria;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;

/**
 *
 * @author andreismiths
 */
public class GerarPDFPortaria {
    
    private HttpServletResponse response;
    private FacesContext context;
    private ByteArrayOutputStream baos;
    private InputStream stream;
    private Connection con;

    public void gerarPDFPortaria() {
        System.out.println("Entrou no GerarPortaria");
        this.context = FacesContext.getCurrentInstance();
        this.response = (HttpServletResponse) context.getExternalContext().getResponse();
    }
    
    /*
    defina um parametro: List<Objeto> lista, se usar JavaBean DataSource
    */
    public void getRelatorio(List<Portaria> listaPDFPortaria){
        System.out.println("Entrou no GetRelatorio");
        stream = this.getClass().getResourceAsStream("/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper");
        System.out.println("Passou do Stream");
        Map<String, Object> params = new HashMap<String, Object>();
        System.out.println("Passou do Map<string, object>");
        baos = new ByteArrayOutputStream();
        System.out.println("Passou do baos");
        try {
            System.out.println("Entrou no try");
            JasperReport report = (JasperReport) JRLoader.loadObject(stream);
            System.out.println("Passou do JasperReport");
            /*Para usar JavaBeanDataSource defina: new JRBeanCollectionDataSource(lista)
            mude a string do getResourceAsStream("/report/reportPessoaJavaBeanDS.jasper")
            */
            JasperPrint print = JasperFillManager.fillReport(report, params, new JRBeanCollectionDataSource(listaPDFPortaria));
            System.out.println("Passou do JasperPrint nova Lista");
            JasperExportManager.exportReportToPdfStream(print, baos);
            System.out.println("Passou do exportar para pdf");
            response.reset();
            System.out.println("Passou do reset");
            response.setContentType("application/pdf");
            System.out.println("Passou do content type");
            response.setContentLength(baos.size());
            System.out.println("Passou do content length");
            response.setHeader("Content-disposition", "inline; filename=Portaria.pdf");
            System.out.println("Passou do setheader");
            response.getOutputStream().write(baos.toByteArray());
            response.getOutputStream().flush();
            response.getOutputStream().close();
            
            context.responseComplete();
            fecharConexao();
            
        } catch (JRException ex) {
            System.out.println("Entrou no catch  1");
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            System.out.println("Entrou no catch  2");
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
    }    
    
    public Connection getConexao(){        
        try {            
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/SControlePortaria?zeroDateTimeBehavior=convertToNull", "root", "root");
            return con;
            
        } catch (SQLException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return con;
    }
    
    public void fecharConexao(){
        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

LOG do Servidor (Esses “prints” eu coloquei para verificar até qual parte do método está passando)

Informações:   1111111111
Informações:   2222222222
Informações:   3333333333
Informações:   4444444444
Informações:   Entrou no GetRelatorio
Informações:   Passou do Stream
Informações:   Passou do Map<string, object>
Informações:   Passou do baos
Informações:   Entrou no try
Advertência:   #{MBportaria.imprimirUnicoItem()}: java.lang.NullPointerException
javax.faces.FacesException: #{MBportaria.imprimirUnicoItem()}: java.lang.NullPointerException
	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: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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	... 35 more
Caused by: java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2338)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2351)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2822)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:57)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:277)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:262)
	at com.ufpa.scontroleportaria.relatorio.GerarPDFPortaria.getRelatorio(GerarPDFPortaria.java:62)
	at com.ufpa.scontroleportaria.bean.MBportaria.imprimirUnicoItem(MBportaria.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	... 36 more

Advertência:   StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2338)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2351)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2822)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:57)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:277)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:262)
	at com.ufpa.scontroleportaria.relatorio.GerarPDFPortaria.getRelatorio(GerarPDFPortaria.java:62)
	at com.ufpa.scontroleportaria.bean.MBportaria.imprimirUnicoItem(MBportaria.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)

Qualquer informação necessária a mais, podem pedir. Agradeço caso alguém possa e queira me ajudar.

O NPE esta sendo causado pelo “stream” que esta null, provavelmente o caminho do relatório esta errado.

1 curtida

Agradeço pela resposta amigo, mas verifiquei o caminho e estava realmente errado, mas o erro persiste.
o caminho correto é: /com/ufpa/scontroleportaria/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper
mas o erro está da mesma forma null.
como relatei acima, eu tinha um form dentro do outro, no caso era o form do dialog para confirmação das informações a serem impressas e pelo fato do erro no command eu removi o form de dentro do form que exibe, então esse dialog passou a não receber mais as informações do form que exibe. Acredito que o problema esteja mais crítico esteja aí. Vou lhe repassar o link do projeto que está no git para o caso de você querer rodar.
https://github.com/andreismiths/SControlePortaria
PS: Desculpe pela demora, eu imaginei que o site disparava um email quando alguém respondesse.

Baixei o seu projeto:
Tire todos os form de dentro do dialog.
Vá na opção ‘Propriedades’ do teu relatório e mude o valor de Groovy para Java ou coloque os .jar do groovy no seu pom.xml

1 curtida

Obrigado pela resposta, mas um questionamento tenho eu, caso eu remova os forms, perco algumas funcionalidades do command e eu teria de usar apenas o button que não fornece certas funcionalidades que estou usando no command.

Quais funcionalidades?

Estas
ajax="false" action="#{MBportaria.editarPortaria()}" oncomplete="PF('portariaEditDialog').hide()"

o action e o oncomplete voce nao perde, eles fazem parte do component e seram executados com ou sem o form.
O ajax eu ja nao sei.

Segue a imagem comprovando o que eu disse anteriormente.

Você deve continuar usando o p:commandButton. nao precisa trocar

Não, mas segundo o que estudei o commandbutton precisa ficar dentro de um form, mas você pediu para que eu o retirasse.

Retira-se o form de dentro do p:dialog.

Veja que dentro do seu p:panelGrid voce ja possui um form e o seu dialog esta dentro desse panelGrid.

Form dentro de form da erro.

Caso voce venha a tirar esse esse dialog para dentro da PaginaInicial.xhtml ou Adm_layout.xhtml. voce precisara colocar o form novamente, visto que ele sera um composition separado.

Entendi, fiz o que você falou, deixei um único form que fecha antes do meu panelGrid. e também alterei o jasper do relatório para java na sua propriedade.
sobre o form dentro do form eu soube há um erro antes deste, pois o meu command n chamava a função, então verifiquei que tinha algo de errado e eram os forms um dentro do outro.
então alterei, mas as informações da datatable não estão sendo transmitidas para o dialog, por isso o nullpointer.

Estou com erro pois ao clicar no botão para abrir o dialog ele não carrega as informações da linha do datatable que exibe.

na primeira imagem eu clico para abrir o dialog para confirmar as informações


nesta segunda eu já tenho o dialog aberto mas que deveria ter carregado as informações da linha em que eu cliquei no botao (consegui fazer isso mas com um form dentro de outro, mas o commandbutton não chamava o action)

na terceira imagem é o resultado da função que gera o pdf (imprimir) que deveria gerar o pdf com as informações daquela linha

eu já atualizei o código no git com as alterações que você pediu para que eu fizesse

aqui está o log do servidor

Informações:   1111111111
Informações:   2222222222
Informações:   3333333333
Informações:   4444444444
Informações:   Entrou no GetRelatorio
Informações:   Passou do Stream
Informações:   Passou do Map<string, object>
Informações:   Passou do baos
Informações:   Entrou no try
Advertência:   #{MBportaria.imprimirUnicoItem()}: java.lang.NullPointerException
javax.faces.FacesException: #{MBportaria.imprimirUnicoItem()}: java.lang.NullPointerException
	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: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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	... 35 more
Caused by: java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2338)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2351)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2822)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:57)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:277)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:262)
	at com.ufpa.scontroleportaria.relatorio.GerarPDFPortaria.getRelatorioUmaLinha(GerarPDFPortaria.java:62)
	at com.ufpa.scontroleportaria.bean.MBportaria.imprimirUnicoItem(MBportaria.java:83)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	... 36 more

Advertência:   StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2338)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2351)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2822)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:57)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:277)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:262)
	at com.ufpa.scontroleportaria.relatorio.GerarPDFPortaria.getRelatorioUmaLinha(GerarPDFPortaria.java:62)
	at com.ufpa.scontroleportaria.bean.MBportaria.imprimirUnicoItem(MBportaria.java:83)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)

Agradeço novamente pelo seu empenho em me ajudar a resolver o problema. :grinning:

@campelo.m consegui resolver uma parte do meu problema que envolvia selecionar uma linha há alguns dias, mas só tive tempo para postar a solução hoje.
Ainda estou com erro na linha
this.getClass().getResourceAsStream("/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper");
do relatório pois o jasper não está conseguindo encontrar o caminho do arquivo e retorna nullpointer (já tentei todos os caminhos possíveis diversas vezes e nada).

segue o código funcionando da minha tela

<h:form id="formlistaportaria">

        <p:dataTable var="portaria" value="#{MBportaria.listaPortaria}">
            <f:facet name="header">
                Portarias
            </f:facet>
            <p:ajax event="rowSelect" update="formlistaportaria"/>
            <p:column headerText="PK">
                <p:outputLabel value="#{portaria.pkPortaria}"/>
            </p:column>
            <p:column headerText="Número">
                <p:outputLabel value="#{portaria.numeroPortaria}"/>
            </p:column>
            <p:column headerText="Ementa">
                <p:outputLabel value="#{portaria.ementaPortaria}"/>
            </p:column>
            <p:column headerText="Título do Projeto">
                <p:outputLabel value="#{portaria.tituloProjetoPortaria}"/>
            </p:column>
            <p:column headerText="Projeto">
                <p:outputLabel value="#{portaria.projetoPortaria}"/>
            </p:column>
            <p:column headerText="Professor Coordenador">
                <p:outputLabel value="#{portaria.professorCoordenador}"/>
            </p:column>
            <p:column headerText="Siape Coordenador">
                <p:outputLabel value="#{portaria.siapeCoordenador}"/>
            </p:column>
            <p:column headerText="Início Vigência">
                <p:outputLabel value="#{portaria.inicioVigencia}"/>
            </p:column>
            <p:column headerText="Fim Vigência">
                <p:outputLabel value="#{portaria.fimVigencia}"/>
            </p:column>
            <p:column headerText="Colaborador 1">
                <p:outputLabel value="#{portaria.colaborador1}"/>
            </p:column>
            <p:column headerText="Siape Colab. 1">
                <p:outputLabel value="#{portaria.siapeColaborador1}"/>
            </p:column>

            <p:column headerText="Ações" style="width: 170px; text-align: center;">
                <p:commandButton icon="fa fa-bug" ajax="false" onclick="this.form.target = '_blank'"
                                 action="#{MBportaria.imprimirTodas()}" title="PDF Todas"/>

                <p:commandButton icon="ui-icon-print" oncomplete="PF('pdfdialogportaria').show()" 
                                 update=":formlistaportaria:formpdfdialogportaria" title="PDF Única">
                    <f:setPropertyActionListener value="#{portaria}" target="#{MBportaria.selecionadaPortaria}"/>
                </p:commandButton>

                <p:commandButton icon="fa fa-pencil-square-o" oncomplete="PF('edicaodialogportaria').show()"
                                 update=":formlistaportaria:formedicaodialogportaria" title="Editar">
                    <f:setPropertyActionListener value="#{portaria}" target="#{MBportaria.selecionadaEditPortaria}"/>
                </p:commandButton>
                <!--BOTÃO DE EXCLUSÃO A ALTERAR PARA O CONFIRM DIALOG E TESTAR ANTES DE IMPLEMENTAR-->
                <p:commandButton icon="fa fa-trash-o" oncomplete="PF('confirmdialogexcluirportaria').show()" 
                                 update=":formlistaportaria:confirmdialogexcluirportaria" title="Excluir">
                    <f:setPropertyActionListener target="#{MBportaria.selecionadaExcluirPortaria}" value="#{portaria}"/>
                </p:commandButton>
            </p:column>
        </p:dataTable>

        <p:dialog widgetVar="pdfdialogportaria" header="Gerar PDF" modal="true" showEffect="fade" hideEffect="explode" dynamic="true" resizable="false" width="600" >
            <p:outputPanel id="formpdfdialogportaria" style="text-align: center;">
                <p:panelGrid columns="2" rendered="#{not empty MBportaria.selecionadaPortaria}">
                    <p:outputLabel value="PK"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.pkPortaria}" disabled="true"/>
                    <p:outputLabel value="Número"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.numeroPortaria}" disabled="true"/>
                    <p:outputLabel value="Ementa Portaria"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.ementaPortaria}" disabled="true"/>
                    <p:outputLabel value="Título"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.tituloProjetoPortaria}" disabled="true"/>
                    <p:outputLabel value="Projeto"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.projetoPortaria}" disabled="true" />
                    <p:outputLabel value="Coordenador"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.professorCoordenador}" disabled="true"/>
                    <p:outputLabel value="Siape Coordenador"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.siapeCoordenador}" disabled="true"/>
                    <p:outputLabel value="Início"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.inicioVigencia}" disabled="true"/>
                    <p:outputLabel value="Fim"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.fimVigencia}" disabled="true"/>   
                    <p:outputLabel value="Colaborador 1"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.colaborador1}" disabled="true"/>
                    <p:outputLabel value="Siape Colab. 1"/>
                    <p:inputText value="#{MBportaria.selecionadaPortaria.siapeColaborador1}" disabled="true"/>
                </p:panelGrid>
            </p:outputPanel>
            <p:fieldset>
                <p:commandButton value="PDF" ajax="false" action="#{MBportaria.pdfTodas()}"
                                 oncomplete="PF('pdfdialogportaria').hide()" update=":formlistaportaria"
                                 onclick="this.form.target = '_blank'"/>
                <p:commandButton value="Fechar" oncomplete="PF('pdfdialogportaria').hide()" update=":formlistaportaria"/>
            </p:fieldset>
        </p:dialog>

        <p:dialog widgetVar="edicaodialogportaria" header="Editar Portaria" showEffect="fade" hideEffect="explode" modal="true" dynamic="true" resizable="false" width="600">
            <p:outputPanel id="formedicaodialogportaria" style="text-align: center;">
                <p:panelGrid columns="2" rendered="#{not empty MBportaria.selecionadaEditPortaria}">
                    <p:outputLabel value="PK"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.pkPortaria}" disabled="true"/>
                    <p:outputLabel value="Número"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.numeroPortaria}" />
                    <p:outputLabel value="Ementa Portaria"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.ementaPortaria}" />
                    <p:outputLabel value="Título"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.tituloProjetoPortaria}" />
                    <p:outputLabel value="Projeto"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.projetoPortaria}" />
                    <p:outputLabel value="Coordenador"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.professorCoordenador}" />
                    <p:outputLabel value="Siape Coordenador"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.siapeCoordenador}" />
                    <p:outputLabel value="Início"/>
                    <p:calendar value="#{MBportaria.selecionadaEditPortaria.inicioVigencia}"
                    maxlength="10" locale="pt" pattern="dd-mm-yyyy" />
                    <p:outputLabel value="Fim"/>
                    <p:calendar value="#{MBportaria.selecionadaEditPortaria.fimVigencia}"
                                maxlength="10" locale="pt" timeZone="GMT-3" pattern="dd-mm-yyyy" /> 
                    <p:outputLabel value="Colaborador 1"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.colaborador1}" />
                    <p:outputLabel value="Siape Colab. 1"/>
                    <p:inputText value="#{MBportaria.selecionadaEditPortaria.siapeColaborador1}" />
                </p:panelGrid>
            </p:outputPanel>
            <p:fieldset>
                <p:commandButton value="Editar Portaria" ajax="false" action="#{MBportaria.editarPortaria()}"
                                 oncomplete="PF('edicaodialogportaria').hide()" update=":formlistaportaria"/>
                <p:commandButton value="Fechar" oncomplete="PF('edicaodialogportaria').hide()" update=":formlistaportaria"/>
            </p:fieldset>
        </p:dialog>
        
        <p:confirmDialog id="confirmdialogexcluirportaria" message="Você gostaria de excluir a portaria de número #{MBportaria.selecionadaExcluirPortaria.numeroPortaria}?"
                         header="Excluir Portaria" severity="alert" widgetVar="confirmdialogexcluirportaria" showEffect="fade" hideEffect="explode">
            <p:commandButton value="Sim" oncomplete="PF('confirmdialogexcluirportaria').hide()" action="#{MBportaria.deletarPortaria()}"
                             icon="ui-icon-check" update=":formlistaportaria"/>
            <p:commandButton value="Não" onclick="PF('confirmdialogexcluirportaria').hide()" icon="ui-icon-close"/>
        </p:confirmDialog>

    </h:form>

Estou atrás da solução ainda, caso queira olhar o projeto, o mais recente já foi comitado no github. Obrigado pela ajuda.

Abaixo segue o link que me ajudou bastante a entender o que havia de errado.
https://www.primefaces.org/showcase/ui/data/datatable/selection.xhtml

O problema agora eh apenas o NullPointer? onde esta os relatorios? na pasta resource?

Isso, basicamente ele não encontra o arquivo.
O caminho dos relatório é este está organizado desta forma:
/SControlePortaria/src/main/java/com/ufpa/scontroleportaria/report/

Passe os arquivos do report para dentro da pasta resource. (Tenho essa preferencia de organização)
depois faça:

this.getClass().getClassLoader().getResourceAsStream("/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper");

ou deixe do jeito que esta e altere o caminho para:

"com/ufpa/scontroleportaria/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper"

estou recebendo o mesmo erro na mesma linha.

Advertência:   #{MBportaria.pdfTodas()}: java.lang.NullPointerException
javax.faces.FacesException: #{MBportaria.pdfTodas()}: java.lang.NullPointerException
	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: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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	... 35 more
Caused by: java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2606)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2622)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:58)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:248)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233)
	at com.ufpa.scontroleportaria.relatorio.PdfTodasPortarias.todasPortarias(PdfTodasPortarias.java:50)
	at com.ufpa.scontroleportaria.bean.MBportaria.pdfTodas(MBportaria.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	... 36 more

Advertência:   StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
	at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2606)
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2622)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
	at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.<init>(ContextClassLoaderObjectInputStream.java:58)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:248)
	at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233)
	at com.ufpa.scontroleportaria.relatorio.PdfTodasPortarias.todasPortarias(PdfTodasPortarias.java:50)
	at com.ufpa.scontroleportaria.bean.MBportaria.pdfTodas(MBportaria.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at javax.el.ELUtil.invokeMethod(ELUtil.java:332)
	at javax.el.BeanELResolver.invoke(BeanELResolver.java:537)
	at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
	at com.sun.el.parser.AstValue.invoke(AstValue.java:283)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	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:658)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)

Fiz o teste aqui no projeto e assim funciona:

@campelo.m aqui não está funcionando :frowning:

Abaixo está meu código:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ufpa.scontroleportaria.relatorio;

import com.ufpa.scontroleportaria.model.Portaria;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;

/**
 *
 * @author andreismiths
 */
public class GerarPDFPortaria {

    private HttpServletResponse response;
    private FacesContext context;
    private ByteArrayOutputStream baos;
    private InputStream stream;
    private Connection con;

    public GerarPDFPortaria() {
        this.context = FacesContext.getCurrentInstance();
        this.response = (HttpServletResponse) context.getExternalContext().getResponse();
    }

    /*
    defina um parametro: List<Objeto> lista, se usar JavaBean DataSource
     */
    public void getRelatorioUmaLinha(List<Portaria> lista) {
        stream = this.getClass().getClassLoader().getResourceAsStream("/com/ufpa/scontroleportaria/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper");

///home/andreismiths/NetBeansProjects/SControlePortariaTCC/SControlePortaria/src/main/java/com/ufpa/scontroleportaria/report/PortariaPDF_scontroleportaria_19_Maio_2017.jasper
        Map<String, Object> params = new HashMap<String, Object>();
        baos = new ByteArrayOutputStream();
        try {
            JasperReport report = (JasperReport) JRLoader.loadObject(stream);
            /*Para usar JavaBeanDataSource defina: new JRBeanCollectionDataSource(lista)
            mude a string do getResourceAsStream("/report/reportPessoaJavaBeanDS.jasper")
             */
            JasperPrint print = JasperFillManager.fillReport(report, params, new JRBeanCollectionDataSource(lista));
            JasperExportManager.exportReportToPdfStream(print, baos);
            response.reset();
            response.setContentType("application/pdf");
            response.setContentLength(baos.size());
            response.setHeader("Content-disposition", "inline; filename=Portaria.pdf");
            response.getOutputStream().write(baos.toByteArray());
            response.getOutputStream().flush();
            response.getOutputStream().close();

            context.responseComplete();
            fecharConexao();

        } catch (JRException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void getRelatorioTodas() {
        stream = this.getClass().getResourceAsStream("/report/pdfportariatodas.jasper");
        Map<String, Object> params = new HashMap<String, Object>();
        baos = new ByteArrayOutputStream();
        try {

            JasperReport report = (JasperReport) JRLoader.loadObject(stream);

            /*Para usar JavaBeanDataSource defina: new JRBeanCollectionDataSource(lista)
            mude a string do getResourceAsStream("/report/reportPessoaJavaBeanDS.jasper")
             */
            JasperPrint print = JasperFillManager.fillReport(report, params, getConexao());
            JasperExportManager.exportReportToPdfStream(print, baos);

            response.reset();
            response.setContentType("application/pdf");
            response.setContentLength(baos.size());
            response.setHeader("Content-disposition", "inline; filename=Portaria.pdf");
            response.getOutputStream().write(baos.toByteArray());
            response.getOutputStream().flush();
            response.getOutputStream().close();

            context.responseComplete();
            fecharConexao();

        } catch (JRException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Connection getConexao() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/SControlePortaria?zeroDateTimeBehavior=convertToNull", "root", "root");
            return con;

        } catch (SQLException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }

        return con;
    }

    public void fecharConexao() {
        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(GerarPDFPortaria.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}