1

I have the following hierarchy

@MappedSuperclass
public class MensajeErrorBase{

@Enumerated(EnumType.STRING)
@Column(name = "SEVERIDAD", nullable = false, length = 50)
protected EnumSeveridadMensaje severidad;
//...
}

@Entity
@Table(name = "TRA_INGRE_IDENTI_MSJ")
public class IngresoPorIdentificarMsg extends MensajeErrorBase implements    Serializable, MensajeMonitoreo {

private static final long serialVersionUID = -8722933693750515329L;

@EmbeddedId
protected IngresoPorIdentificarMsgPK pk;
//...
}

and a transctional ejb where I perform crud operations. In another ejb named ServicioProceso I have the following method:

private <T extends MensajeErrorBase> void guardarMensajesError(Class<T> claseEntidad, Serializable pk, List<T> listaMensajes,
                DatoSesionAud dsa) {
            try {
                MensajeMonitoreo msjMonitoreo = (MensajeMonitoreo) claseEntidad.newInstance();
                if (msjMonitoreo.getClaseMsjParam() == null) {
                    throw new RuntimeException(excepcionNosePropago(ServicioProceso.class, "guardarMensajesError",
                            "No estan configurados los metodos que retornan las clases de parametros en la clase de Mensajes Base"));
                }
                for (MensajeErrorBase mensajeErrorBase : listaMensajes) {
                    msjMonitoreo = (MensajeMonitoreo) mensajeErrorBase;
                    msjMonitoreo.setClavePrimaria((Serializable) BeansUtil.deepClone(pk));
                    super.insertSecuencia(msjMonitoreo, dsa);
                    List<MensajeErrorParamBase> listaMensajesParam = ((MensajeMonitoreo) mensajeErrorBase).getParametros();
                    for (int i = 1; i <= listaMensajesParam.size(); i++) {
                        MensajeMonitoreoParam msjMonitoreoParam = (MensajeMonitoreoParam) listaMensajesParam.get(i - 1);
                        msjMonitoreoParam.setClavePrimaria((Serializable) BeansUtil.deepClone(msjMonitoreo.getPk()), i);
                        super.insert(msjMonitoreoParam, dsa);
                        List<MensajeErrorParamParamBase> listaMensajesParamParam =
                                ((MensajeMonitoreoParam) listaMensajesParam.get(i - 1)).getParametros();
                        for (int j = 1; j <= listaMensajesParamParam.size(); j++) {
                            MensajeMonitoreoParamParam msjMonitoreoParamParam =
                                    (MensajeMonitoreoParamParam) listaMensajesParamParam.get(j - 1);
                            msjMonitoreoParamParam.setClavePrimaria((Serializable) BeansUtil.deepClone(msjMonitoreoParam.getPk()), j);
                            super.insert(msjMonitoreoParamParam, dsa);
                        }
                    }
                    super.flush();
                }
            } catch (InstantiationException | IllegalAccessException e) {
                LoggerUtil.runtimeException(e, ServicioProceso.class);
                throw new RuntimeException(excepcionNosePropago(ServicioProceso.class, "guardarMensajesError", e));
            }
        }

where the line:

 super.insertSecuencia(msjMonitoreo, dsa);

calls that ejb that performs crud operations and sends the object msjMonitoreo with all data from the mapped superclass and the subclass setted. but in the flush call I get the following exception:

[4/5/17 10:52:05:995 ECT] 00000093 SystemOut     O [EL Warning]: 2017-04-05 10:52:05.994--UnitOfWork(-1281205041)--Thread(Thread[WebContainer : 3,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")

Error Code: 1400
Call: INSERT INTO TRA_INGRE_IDENTI_MSJ (ETIQUETA, RECURSO_MULTILENGUAJE, SEVERIDAD, COD_EMPRESA, SECUENCIA, NUM_LICENCIA, SEC_MENSAJE) VALUES (?, ?, ?, ?, ?, ?, ?)
        bind => [null, null, null, E-MPR, 1, 1, 4]
Query: InsertObjectQuery(IngresoPorIdentificarMsg[pk=IngresoPorIdentificarMsgPK[ numLicencia=1,codigoEmpresa=E-MPR,codigoProducto=1,secuenciaMensaje=4]])
[4/5/17 10:52:05:996 ECT] 00000093 BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "registrarMensajesError" on bean "BeanId(GestorG5#G5Core-ejb.jar#ServicioProceso, null)". Exception data: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")

Error Code: 1400
Call: INSERT INTO TRA_INGRE_IDENTI_MSJ (ETIQUETA, RECURSO_MULTILENGUAJE, SEVERIDAD, COD_EMPRESA, SECUENCIA, NUM_LICENCIA, SEC_MENSAJE) VALUES (?, ?, ?, ?, ?, ?, ?)
        bind => [null, null, null, E-MPR, 1, 1, 4]
Query: InsertObjectQuery(IngresoPorIdentificarMsg[pk=IngresoPorIdentificarMsgPK[ numLicencia=1,codigoEmpresa=E-MPR,codigoProducto=1,secuenciaMensaje=4]])
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:868)
        at com.ibm.ws.jpa.management.JPATxEmInvocation.flush(JPATxEmInvocation.java:255)
        at com.ibm.ws.jpa.management.JPAEntityManager.flush(JPAEntityManager.java:221)
        at com.gestorinc.gestor.crud.impl.CrudServiceImpl.flush(CrudServiceImpl.java:730)
        at com.gestorinc.g5.servicio.impl.general.ServicioProceso.guardarMensajesError(ServicioProceso.java:305)
        at com.gestorinc.g5.servicio.impl.general.ServicioProceso.registrarMensajesError(ServicioProceso.java:115)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:5730)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:568)
        at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callInterceptorsAndDecorators(OpenWebBeansEjbInterceptor.java:526)
        at org.apache.webbeans.ejb.common.interceptor.OpenWebBeansEjbInterceptor.callToOwbInterceptors(OpenWebBeansEjbInterceptor.java:200)
        at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
        at org.apache.webbeans.ejb.WSEJBInterceptor.callToOwbInterceptors(WSEJBInterceptor.java:136)
        at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:548)
        at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:229)
        at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:5621)
        at com.gestorinc.g5.servicio.impl.general.EJSLocalNSLServicioProceso_bf34d3b4.registrarMensajesError(EJSLocalNSLServicioProceso_bf34d3b4.java)
        at com.gestorinc.g5web.bean.bpm.TareasActividadesBandejaBean.ejecutarErrores(TareasActividadesBandejaBean.java:251)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at org.apache.webbeans.intercept.InterceptorHandler.invoke(InterceptorHandler.java:297)
        at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:98)
        at com.gestorinc.g5web.bean.bpm.TareasActividadesBandejaBean_$$_javassist_6.ejecutarErrores(TareasActividadesBandejaBean_$$_javassist_6.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
        at java.lang.reflect.Method.invoke(Method.java:620)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:268)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
        at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:78)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:360)
        at javax.faces.component.UICommand.broadcast(UICommand.java:103)
        at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:119)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
        at com.gestorinc.g5web.filter.FiltroAccesoAutenticado.doFilter(FiltroAccesoAutenticado.java:76)
        at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
        at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
        at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
        at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)
        at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
        at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("SANTANDER_DESA"."TRA_INGRE_IDENTI_MSJ"."SEVERIDAD")

When I debug all fields are setted with de corresponding value. debug shows that all fields are setted. My server is running on WebSphere Application Server (Full) 8.5.5.0. but when I deploy into a Liberty WebSphere it works ok

  • `@Column(name = "SEVERIDAD", nullable = false, length = 50)` I see `nullable=false` then you can not set that field empty – Rajith Pemabandu Apr 05 '17 at 16:27
  • that field is not empty. When `this.getEntityManager().persist(obj);`. So I persist a list of items and when the flush ocurrs, then I get the error of null values. Thanks for your answer. – Marcel Puentes Rojas Apr 05 '17 at 16:48
  • The column `SEVERIDAD` is `NULL` while inserting in the database: `bind => [null, null, null, E-MPR, 1, 1, 4]` (its third variable). So this should be your staring point debugging the code... – Marmite Bomber Apr 05 '17 at 17:04
  • No it is not Null previous to insert operation it has all fields (from mapped superclass an from subclass) with it values. I confirm that when debuging. thanks. When I debug all fields are setted with de corresponding value. Debug shows that all fields are setted: https://i.stack.imgur.com/pwMRp.png – Marcel Puentes Rojas Apr 05 '17 at 17:44
  • While you may have set the values in the object, it might not be the instance that is managed by JPA, so that those changes are not picked up. I'm not sure why you would show the guardarMensajesError method instead of the insertSecuencia method that you say is handling setting the values and hopefully shows how you are putting this object into JPA. – Chris Apr 05 '17 at 18:11
  • Hello @Chris the method insertSecuencia generate some auditory data and then calls `this.getEntityManager().persist(entidad);` where `entidad` is de object to persist. When this call is made `entidad` contains all data ok. but when the entity manager execute de flush operation then the error happens. in my ´persistence.xml` file I have de corresponding line for the subclass: `com.gestorinc.gestor.modelo.transaccion.IngresoPorIdentificarMsg` My server is running on WebSphere Application Server (Full) 8.5.5.0. but when I deploy into a Liberty WebSphere it works ok – Marcel Puentes Rojas Apr 05 '17 at 19:13
  • sounds like something to do with flushing a different entityManager context than the one you used to call persist(entidad) on. Are there any references to this subclass that you might be setting that cause some other context to get a partial view of it? Any reason that the entityManagers might not be the same throughout your various methods? You can try calling em.flush() after your persist call to see what happens – Chris Apr 05 '17 at 19:44
  • Well @Chris I check several times but nothing found. both EJBs use the same persistence unit and the same EntityManager. – Marcel Puentes Rojas Apr 05 '17 at 19:50

2 Answers2

1

It wasn't the double persistence.xml its was a Glassfish Bug:

https://github.com/javaee/glassfish/issues/16164

I had to disable weaving:

<properties>
  <!-- Documentation https://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm says its 'eclipse.weaving', but examples say its 'eclipselink.weaving'. Great. -->
  <property name="eclipselink.weaving" value="false"/>
  <property name="eclipse.weaving" value="false"/>
</properties>
towi
  • 21,587
  • 28
  • 106
  • 187
0

I still don´t know what happen but I found the problem: I hava two persistence.xml una in a library packaged in my ear app and another in an ejb module. So I deleted the one on de ejb module an placed it persistence unit in the same file at the library. and works fine. I still don't know why it works fine on a liberty server and fails on a IBM WAS 8.5. thanks all for your help.