problem with Persistence BDR- BDOR

0

Hello, I have the following error message:

 java.lang.NullPointerException
    at TestGestors.tanca(TestGestors.java:350)
    at TestGestors.classEnds(TestGestors.java:90)

Does anyone know what it can mean? The program is very extensive and I do not want to have to collapse this .. someone gives me a help or tells me that it can be ..

thanks!

---- edito

line 350:

  private void tanca(){  //tanquem l'EntityManager
        em.close();
        emf.close();
    }
    
asked by Montse Mkd 20.03.2018 в 13:21
source

1 answer

1

NullPointerException: is an exception of java that indicates that an object is without an object , worth the redundancy.

Case 1: (Object not initialized) That is, an object has been created but not initialized, in java an object is initialized with the reserved word new , followed by the name of the object that is you want to instantiate.

Example:

import java.util.ArrayList;
public class TestNullException {
    public static void main (String [] Args) {
        ArrayList<Integer> Numeros;
        Integer suma = 0;
        for (Integer numero : Numeros) {//error de java.lang.NullPointerException, por no iniciar Numeros con new ArrayList<Integer>(),
            suma = suma + numero;
        }
        System.out.println ("El sumatorio actual es: " + suma);    
    }     
}

case 2: (Object deleted) That is, at some point the object was initialized and instantiated, but it was deleted, that is, it was pointed to null.

Example:

import java.util.ArrayList;
public class TestNullException {
    class EjemploNull{
        String nombre;
        EjemploNull(String nombre){
            this.nombre=nombre;
        }
        public static String GetNombre(){
            return this.nombre
        }   
    }
    public static void main (String [] Args) {
        EjemploNull nom=new EjemploNull("Juan");
        ...
        ...//mucho codigo utilizando nom sin problemas
        ...
        nom=null;//por algun motivo lo pusiste en null, tal vez sin querer
        ...// mas codigo sin darte cuenta del error
        String nuevo_nombre=nom.GetNombre();//error de java.lang.NullPointerException
        ...//el resto del codigo

    }     
}

I think the second case can replicate your problem.

I hope some of this will help you.

    
answered by 20.03.2018 / 14:26
source