Unable to execute the script java.lang.NullPointerException

15 Apr '19, 11:09 PM
8,122 Views
No Forum Badges

Hi everyone!

 

I am trying to execute a script that receives as input the state of a checkbox and the oid of a table in order to change a field in the data base. Note that the change is not made in the script but the output is needed in order to make the change ater the cript is done running. 

Here is the code of the script:

 

#input String chkbox_entry

#input int oidBank

#output String chkbox_exit

 

import com.webratio.rtx.db.HibernateService

 

def chkbox_exit

def resultQuery = ""

def dbId = "db1"

def session = getDBSession(dbId)

 

 

//query to get the field i need 

 

def query = session.createSQLQuery("SELECT DBNAME.DBTABLE.ES_TARJETA FROM DBNAME.DBTABLE WHERE DBNAME.DBTABLE.OID = :oidBanco") 

query.setInteger("oidBanco", oidBanco)

 

resultQuery = query.uniqueResult()

 

//change the state accordingly and give it to chkbox_exit

if (chkbox_entry== "" && resultQuery =="S")  //means that the current state is S but they want N

       {

              chkbox_exit= "N"

       }

else

      {

               if (chkbox_entry== "" && resultQuery =="N")

                          {

                             chkbox_exit= "S"

                          }

           else

                         {

                                 if (chkbox_entry== "S")

                                       {

                                                chkbox_exit= "S"

                                      }

                               else

                                      {

                                                 chkbox_exit= "N"

                                     }

                     }

    }

return ["chkbox_exit": chkbox_exit]

 

Let me elaborate:

The state of the checkbox I receive as an input can be either S, N or "" (note that "" isnt null but empty). Why do I need the sql consult to retreive either S or N from the DB? That is exactly what I need to change. I am trying to update the state depending on what the user checks or doesnt check. If at first the DB shows N to the user and they uncheck it, I have to save it as S (Note that N and S correspond to No and Si in spanish).

 

Following debug, if the user decided to update the state from N to S (or viceversa), once the user hits Save and the data flows to the script, it enters to the script through the input String chkbox_entry as an String[] (0 elements) .  

 

In order to "save" (remeber i do not save anything here, I only "make the change" needed and send it to the DB from here) the new state I need to know the current state of DBNAME.DBTABLE.ES_TARJETA, that result is stored in resultQuery.

That is why I made the sql consult to the DB so that if the user checks the item (assuming the current state was N and wanted to change it to S), as input besides the OidBank which i use to get the current state of DBNAME.DBTABLE.ES_TARJETA from the query in order to change that string somewhere else in the project but sending the result as output to mak said change. Checking RTXError and RTX log files i get the same error: Unable to execute the script  java.lang.NullPointerException but i do not know what it meas and what to do.

 

If the user chooses not to change then it has to stay the same as it was (S or N respectively).

 

Please help!

 

Thank you.

 
x 0
Follow
Answer Answer at this question and get points!
No Forum Badges

If anyone cares...

I was able to do it using the script component, but not using the SQL consult I tried when getting NullPointerException. The solution is plain, simple and silly really, thought about it when I was driving home yesterdy after spending the whole day wondering, reading and trying to figure out how to make that SQL consult using the script work.

I guess I will remain in the dark on how to use that component properly. Its doumentation is good to start, but at the same time poor to say the least.

If you read this far... have a lovely day.

 
x 0
Answer at this question and get points!

Related questions

404 on generated app page 500 error with WebRatio BPM 502 proxy error-generate and run add html Adding and deleting from the database Add logging capability to a Groovy script (unit) Add select all to Checkable List Admin area disabled aggiornamento fallito a causa di un errore interno Agregar boton de cambio de contraseña en el login Ajax and FCK Editor (WebRatio 5.x) AJAX events problem to external JavaScript Ajax onchange and jQuery 2.x (with migrate plugin) incompatible Alimentar graficas con base de datos Any sample deployment Atributos Condicionales heredados Attribute comparison in a selector unit Automatic file upload [beginner] - How to store and browse data collected with BPM app? Build Project. Only files for compilation .class Business object data Cancellare campi e tabelle dal database Cannot add a Database in the Domain Model Cannot connect to MySQL Cannot insert an entity in the database Cannot invoke method putAll() on null object Cannot invoke method selectSingleNode() on null object Can't generate and run database or start tomcat server! Can't run any aplication Change uplod directory and protect anauthorized access to files Code is exceeding the 65535 bytes limit error on JBOSS Como mostrar una imagen en una lista o en la componente detalles? Como recuperar todos los atributos de una relacion N:N y insertar registros? Compare with the current time Component computation com.webratio.struts.exceptions.WRSecurityException: Invalid request target host Conexion a Oracle 12g Connection refused. connect to Cloud Content module page variable won't assign. Convert data in a Calculated attribute Convert selector component result to single value Creación DB Apache Derby - Modelado BPMN Criptare dati sensibili nel database Database connection, Host and Port number Database password encrypting Database properties Database resource consumption Database Tables Creation After Remote Deploy Data flow from a page which is not visible anymore DB in Data Service Project Debug configuration Deploy de proyecto en HTTPS Deploy in Cloud Amazon Beanstalk with Postgres Dynamic data type Empty record mistakenly saved error activating student account Error deploying WAR against to JBOSS Error updating metadata process Error when updating to WR 7.2.3 EverLasting error "The TCP/IP connection to the host has failed. Connection refused" Execute truncate sql query file analysis then update MySQL database Filtros Caracteres Especiales Find Model Problemas Foriegn key relationship Format currency From BPM to WebProject - BUILD FAILED Generate and run locally on webratio professional edition. Generation errors on ajax enabled page with many components, ajax links and selective refresh "Generation Error" with Generate and Run Get size of Multi Form with Pictures Object Array getting data from database Getting the absolute path of a RTXBLOBData Groovy and Database Groovy script numer after an error Guardar Saltos de LINEA HelloWorld Unit sample code Help with math unit. Debug mode says error as result code Hide a form if condition if true Hide form until a flow is triggered Hiding landmarks (or flows) when the user is logged in Hierarchy component How can I add a credit card payment gateway or integrate paypal in my web app logic? How can i add html into a page? How can I import a view in the Domain Model as an attribute of an Entity? how can i open a pdf file using download dialog How database or datamodel migration? How I can receive the primary key value after adding into database from OK Port. How to block empty string in Database How to calculate dates between start and end point? how to delete this error? How to disble derby database? How to fix Network error(status 0) How to get a wr:AjaxURL tag working How to Retreive data from Multi Selection Field Array How to show certain values derived from relations in the domain model? i can't install mobile version on windows I can't install Webratio on my Desktop (Ubuntu 13.04 x64) I can't run any application with WebRatio (Table/View 'APP.POST' does not exist) Image in List field Importing JAR Libraries into Script Unit Importing jar library Insert data into database Installation with java 1.8 Installazione Macosx invio mail fallito Is it possible to create a derived relationship between databases? JAR importing java.lang.NullPointerException java virtual machine error JDBC4 Postgresql Driver JDBC connection with mysql on mac Job not start correctly JSP/DO issues on Tomcat 5.5 (Ubuntu) Login Error Logs in page mandatory control code parameter is missing Mapping database of the entity '...' is unspecified Mensaje: the selection cannot be launched and there are no recent launches Merge the result of 2 (or more) flows Missing plugin emulation support error Missing units when importing project [MOBILE] Can't synchronize domain model with beck end DB [MOBILE] Script doesn't work! Modify generated code / inject own HTML, Javascript code into existing generted code. Mostrar datos de diferentes tablas/ show dates from diferentes entities MS SQL server jdbc file multi selections field problem Multi Selects didn't work in update page MySQL Driver jdbc Next Activity Note property - Error synchronizing with web project No access to protected site view with Login No Apache Derby driver found No Database on Cloud account No database on my cloud account Page Home - First time the Project Web begins Passing JSON Object to Model Personalizzare lo stile di un progetto PostgreSQL Predefined values in database Problema al generar y ejecutar proyecto Problem accessing MySQL with WebRatio 6 Problema generazione codice Problema Grafo da una lista gerarchica Problema ¨HTTP Status 404" Problemas con el Operations View Delete Problem: Compile Failed problemi installazione su Mac sistema operativo OSX El Capitan problem on first deploy with webratio Problem saving multi selection from input Problems to connect Sql Server DB from Webratio Problems with Database Metadata Problem syncing reports Problem to run an Application Problem with application runnung Problem with execution of webratio Problem with fields with accents used in attribute condition Problem with ireport Problem with query unit! Problem with stored procedure Problem with the deletion of more than 50.000 records in a table Project cannot be opened with WebRatio Community Platform publish web service for storing information in PostgreSQL DB following XSD Resource query a database Refresh and Synchronize DB Problems Relaciones Removing the User-Group-Module tagles Retrieve a value and add some value to it reverse engineering, problema con le relazioni di default Sample web application Schedule a Job when adding a record to the database script component Script eseguito alla User Login Script Unit e Mysql ScritpUnit and JSON data Setting Upload directory Share database connection Showing items that have a relation with an entity Shuffling Script Solve "Generation Error" with Generate and Run option Standard confirm dialog replacement Statistics Component for WebRatio > 7.2.0 Status ProcessInstance and activityInstance in spanish Student reserved area, download error Sybase JConnect 4 JAR replace Sync DataService Project with Mobile Project Table 'freeapp43.profesion' doesn't exist Tarea de servicio no me evalua el valor Tomcat external session store and WebRatio webapp. Trying to Synchronize Domain Model "Unable to close sub-context ..." Unable to compute the controller URL(s) for applicationUnable to compute the controller URL(s) for application having status PROVISIONING Unable to connect to Internet Unable to find Cloud free function Unable to get ExpenseReport example work in WebRation Personl 7.2.2 Unable to instantiate a new application instance Unable to update the web project Unable to use Visual Debug Unknow property on Dynaclass after generation Unspecified BPM Engine Database Update mutiple records with the same value Updating attributes of an entity upload file and the move it to other location User Login Timestamp Username come chiave Using own User and Group tables WebRatio 6.1.2: Groovy Version / Versione Groovy Webratio Add-ons no permite login Web Ratio Add-ons shop not working Web ratio data model WEBRATIO LINUX AT EXECUTION TIME WebRatio - list results of joined tables Web Ratio Mobile and Foreign Key WebRatio Mobile on Linux using wrong network interface. Web Ratio Mobile plateform Macos Sierra Web Ratio Mobile - Remote data mapping problem WebRatio no imports all attributes (fields) of a table When execute my web application I have this error: returned a null bean Where is the ACME demo data stored?! White report XPCOM Error