0 Replies Latest reply on Oct 4, 2013 12:39 PM by Reginaldo L. Russinholi

    Javassist throws NullPointerException when constructor calls another method

    Reginaldo L. Russinholi Newbie

      Hi everyone,

       

      I'm facing the following problem.

       

      I have a multi-thread application to run batch processes, and if I run a process segregated in 2 threads it works fine, but when I run it segregated in 10 threads I get a NullPointerException from Javassist:

       

      Caused by: java.lang.NullPointerException
              at javassist.util.proxy.RuntimeSupport$DefaultMethodHandler.invoke(RuntimeSupport.java:37)
              at org.my.model.PapelContratoColetivo_$$_javassist_63.setTipoSubGrupo(PapelContratoColetivo_$$_javassist_63.java)
              at org.my.model.PapelContratoColetivo.<init>(PapelContratoColetivo.java:58)
              at org.my.model.PapelContratoColetivo_$$_javassist_63.<init>(PapelContratoColetivo_$$_javassist_63.java:1)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

       

       

      Looking at PapelContratoColetivo constructor:

      public PapelContratoColetivo() {

         setTipoSubGrupo(TipoSubGrupo.COLETIVO);

      }

       

      but, this method 'setTipoSubGrupo' is method annotated with @Transient , so just to test I've changed the constructor to set the 'tipoSubGrupo' property without call this method.

       

      public PapelContratoColetivo() {

         this.tipoSubGrupo = TipoSubGrupo.COLETIVO;

      }

       

      Now it works independent on how many threads a I have.

       

      My questions are:

       

      Does anyone know why this problem occurs only when I have more than 2 threads? And why did it work after I've changed the property attribution?