NEWS T1 25 Troubleshooting Sterling Map

Integration News

Troubleshooting: Sterling Map with replaceAll user exit gives a java.lang.NoSuchMethod exception

Problem

When running a map that has a user exit rule with a replaceAll function, the translator issues this error message:

java.lang.NoSuchMethodException: java.lang.NoSuchMethodException: java.lang.String.<init>(null)

 

Cause

The data that was used for the replaceALL function was empty.

The characters after the 1803 above refer to the element TDLINE in the map, which is this case is empty.

The translator report shows that in Block 26, which is the example data line above, so we know this is the data used which caused the error:

Section: INPUT       Severity: ERROR

       SyntaxSpecific: false       Syntax: -1        Code: 170 Extended Rule Error

       Info:

              10002: Block Count

              26

Diagnosing The Problem

If you search for the error message, this is what was returned:

The error message java.lang.NoSuchMethodException: java.lang.String.<init>(null) indicates that you’re trying to create a String object using a constructor that takes a null argument, but such a constructor doesn’t exist.

Here’s why this might be happening and how to fix it:

Common Causes:

  • Passingnull to a String constructor: You might be explicitly passing null as an argument to a String
  • Indirectnull argument: A variable you’re using to create the String might be 

How to Fix:

  • Check for null:
  • Before creating the String object, check if the variable you’re using is null.
  • Handle null values:
  • If the variable is null, you can either:
    • Use a default value: Assign a default value (e.g., an empty string) if the variable is 
    • Throw an exception:If the variable should never be null, throw an exception to handle the error condition.

Resolving The Problem

As stated in the Diagnose section, we will  have to check before creating the String object that the variable we’re using is null.

We will then need to change the extended rule as follows,

object ob;

If exist(#TDLINE) then

 Begin

  ob= new(«java.lang.String»,#TDLINE);

  #TDLINE = ob.replaceALL(«[^^A-Za-z0-9\\s]» , » «);

 End

 

 

This link shows more about using the replaceALL function: 
Replacing-characters-string-value-replaceall-javalangstring-user-exit

 

Haga clic en el siguiente botón para descargar este boletín en formato Pdf.

B2B Solutions ES
Resumen de privacidad

Esta web utiliza cookies para que podamos ofrecerte la mejor experiencia de usuario posible. La información de las cookies se almacena en tu navegador y realiza funciones tales como reconocerte cuando vuelves a nuestra web o ayudar a nuestro equipo a comprender qué secciones de la web encuentras más interesantes y útiles.