cancel
Showing results for 
Search instead for 
Did you mean: 

BaseRollbackException returned when sending object with empty property to SOAP service

Former Member
0 Kudos

I'm working with NetWeaver Studio 7.3 SP 18 PAT0003, I have developed a JPA project with a web service generated from an EBJ (version 3.0) with an operation for inserting into my database.

My operation in my SOAP service receives a DTO that is later parsed to an entity class to be inserted into the database, the table definition was made with a Java Dictionary project and has nullable columns. When I send a DTO to my service with all of the properties, the insert is made without a problem, but if I send the DTO with an empty string in any of the nullable properties, I get the following error response when testing with SoapUI:


<SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <SOAP-ENV:Body>

      <SOAP-ENV:Fault>

         <faultcode>SOAP-ENV:Server</faultcode>

         <faultstring>javax.ejb.EJBException: nested exception is: com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletion of ( JTA Transaction : 121963 ).</faultstring>

         <detail>

            <yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException xmlns:yq1="http://sap-j2ee-engine/client-runtime-error">javax.ejb.EJBException: nested exception is: com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletion of ( JTA Transaction : 121963 ).</yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException>

         </detail>

      </SOAP-ENV:Fault>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

My DTO class looks like this:


import java.io.Serializable;

import java.util.Date;

public class BpmProcessRequestDto implements Serializable{

  private static final long serialVersionUID = 1L;

  private String _procesoId_;

  private String cliente;

  private String _clienteId_;

  private Date _creadoEn_;

  private String _creadoPor_;

  private String estatus;

  private Date _modificadoEn_;

  private String _modificadoPor_;

  private String _motivoProceso_;

  private String proceso;

  private String responsable;

  private String _responsableId_;

  private String solicitante;

  private String _solicitanteId_;

  private String subproceso;

  private String sucursal;

  private String tarea;

  private String factura;

/* Getters and Setters omitted for ease of reading*/

}

This is mapped to an entity class that looks like this:


import java.io.Serializable;

import javax.persistence.*;

import java.sql.Timestamp;

import java.util.Date;

@Entity

@Table(name="Z_PROCESSES_BPM")

public class ZBpmProcess implements Serializable {

  private static final long serialVersionUID = 1L;

  @Id

  @Column(name="PROCESO_ID")

  private String _procesoId_;

  private String cliente;

  @Column(name="CLIENTE_ID")

  private String _clienteId_;

    @Temporal( TemporalType.TIMESTAMP)

  @Column(name="CREADO_EN")

  private Timestamp _creadoEn_;

  @Column(name="CREADO_POR")

  private String _creadoPor_;

  private String estatus;

    @Temporal( TemporalType.TIMESTAMP)

  @Column(name="MODIFICADO_EN")

  private Timestamp _modificadoEn_;

  @Column(name="MODIFICADO_POR", nullable = true)

  private String _modificadoPor_;

  @Column(name="MOTIVO_PROCESO")

  private String _motivoProceso_;

  private String proceso;

  private String responsable;

  @Column(name="RESPONSABLE_ID")

  private String _responsableId_;

  private String solicitante;

  @Column(name="SOLICITANTE_ID")

  private String _solicitanteId_;

  private String subproceso;

  private String sucursal;

  private String factura;

  @Column(nullable = true)

  private String tarea;

    public ZBpmProcess() {

    }

/* Getters and Setters omitted for ease of reading*/

}

I have a try-catch on my endpoint method:


   public String insert(BpmProcessRequestDto processBpm){

    String response = "";

    try{

        ZBpmProcess entry = entityManager.find(ZBpmProcess.class, processBpm.get_procesoId_());

        if(entry == null){

        processBpm.set_creadoEn_(new Date());

        processBpm.set_modificadoEn_(processBpm.get_creadoEn_());

        entry = BpmProcessParser.parseRequestToEntity(processBpm);

        try{

                entityManager.persist(entry);

        }catch(Exception e){

            return response = "Error in Try Catch " + track + " " + e.getMessage();

        }

        } else {

        entry.set_modificadoEn_(new Timestamp(new Date().getTime()));

        entityManager.merge(entry);

        }

        response = "1";

    }catch(Exception e){

    return response = "Error in Try Catch " + e.getMessage();

    }

    return response;

    }

As you can see, I try to handle any exception that migh be thrown, but the exception I'm getting returned is not the one I'm catching in this try-catch clause, so it seems the the service is having trouble when receiving the request and mapping it to my DTO, if that is not the case, then the exception might be handled on the persist method for the EntityManager object.

I have no way to debug this since the application server doesn't allow debugging and I don't have credentials for enabling it, so I am going blind on my especulations.

What could be the possible cause for this problem? Am I missing something? Are there JPA annotations that could help me workaround this?

Accepted Solutions (1)

Accepted Solutions (1)

christian_santej
Active Participant
0 Kudos

Hi,

Just to be sure - do you have the possibility to access the log viewer of the netweaver system?

if so - you would be able to perform printf / log - debugging:

  1. Define a logging location in your endpoint class: protected static final com.sap.tc.logging.Location _location = com.sap.tc.logging.Location.getLocation(MyEndPointClass.class);
  2. At least in your catch(...){} parts perform some logging: _location.tracethrowabletT(Severity.ERROR,"my custom log message",e);

Also - change the catching object from Exception to Throwable. Maybe the thrown Exception is not of type Exception.

Regards,

Christian

Former Member
0 Kudos

Unfortunately I have no access to the log viewer.

On the second option I tried but the exception was being catched by another try-catch inside the persist method of the EntityManager.

In the end I found out that the empty string was being the problem, by replacing them with null for the nullable properties I was able to save the entry, which is odd, empty space should be a valid value for a nullable varchar column. For the not-nullable column I can justify a no empty space rule, since those columns should contain a value, but it is odd.

I don't know if this limitation is something db dependant or if it is something that can be defined in some configuration.

Answers (0)