-6

How to resolver NullPointer in getSubstanciasEsquemasAbertos:

public Set<SubstanciaEsquemaAbertoSoroterapia> getSubstanciasEsquemasAbertos() {

    Set<SubstanciaEsquemaAbertoSoroterapia> substancias = new LinkedHashSet<SubstanciaEsquemaAbertoSoroterapia>();

    for (EsquemaAbertoSoroterapia esquema : getEsquemasAbertosOrdenados()) {
        substancias.addAll(esquema.getSubstanciasOrdenadas());

    }
    return substancias;
}

Stack trace:

Caused by: org.apache.tapestry.runtime.ComponentEventException [at context:prontuario/prescricao/CriacaoPrescricao.tml, line 936, column 61]
at org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1021)
at org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerEvent(ComponentPageElementImpl.java:934)
at org.apache.tapestry.internal.structure.InternalComponentResourcesImpl.triggerEvent(InternalComponentResourcesImpl.java:154)
at org.apache.tapestry.corelib.components.Form.onAction(Form.java:388)
at org.apache.tapestry.corelib.components.Form.dispatchComponentEvent(Form.java)
at org.apache.tapestry.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:851)
at org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1004)
... 79 more

Caused by: java.lang.NullPointerException at br.gov.mg.fhemig.sighfase2.entidade.prontuario.prescricao.ItemPrescricaoSoroterapia.getSubstanciasEsquemasAbertos(ItemPrescricaoSoroterapia.java:442) at br.gov.mg.fhemig.sighfase2.web.pages.prontuario.prescricao.CriacaoPrescricao.sucesso(CriacaoPrescricao.java:1480) at br.gov.mg.fhemig.sighfase2.web.pages.prontuario.prescricao.CriacaoPrescricao.dispatchComponentEvent(CriacaoPrescricao.java) at org.apache.tapestry.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:843) at org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1004) ... 85 more

4

1 回答 1

2

It's possible that either getEsquemasAbertosOrdenados() or one of the esquema.getSubstanciasOrdenadas() is returning null. It's hard to tell without looking at the actual stack trace, you should post it as part of the question.

于 2013-04-04T22:14:14.113 回答