Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: User defined java expression problem

  1. #1
    Join Date
    Nov 2015
    Posts
    15

    Default User defined java expression problem

    Hi,

    I have got following problem: in my test transformation I defined java expression ( new java.text.SimpleDateFormat( "yyyy/MM/dd HH:mm:ss.SSS" ) ).parse( last_update.substring(0,23)) to convert data string like this '2016/04/13 21:48:35.000000000' to the date variable. When I run job (specified transformation is a part of this job) using kitchen all works fine, but when I run the same job using my program I have got following error

    2016/04/14 00:23:57 - User Defined Java Expression.0 - ERROR (version 6.0.1.0-386, build 1 from 2015-12-03 11.37.25 by buildguy) : Unexpected error
    2016/04/14 00:23:57 - User Defined Java Expression.0 - ERROR (version 6.0.1.0-386, build 1 from 2015-12-03 11.37.25 by buildguy) : org.pentaho.di.core.exception.KettleException:
    2016/04/14 00:23:57 - User Defined Java Expression.0 - org.pentaho.di.core.exception.KettleValueException:
    2016/04/14 00:23:57 - User Defined Java Expression.0 - java.lang.StringIndexOutOfBoundsException: String index out of range: 3
    2016/04/14 00:23:57 - User Defined Java Expression.0 - String index out of range: 3

    What's wrong? job and child transformations please see in attach

    Best regards,
    Mikhail
    Attached Files Attached Files

  2. #2
    Join Date
    May 2014
    Posts
    358

    Default

    Probably the timestamp comes in in a different format which is shorter, causing the substring to fail.
    I would recommend using the Select values step for string to date conversion, it is less error prone than Java.

  3. #3
    Join Date
    Nov 2015
    Posts
    15

    Default

    thank you for your answer,

    but according "write to log" step string data input is '2016/04/13 21:48:35.000000000'
    and your assumption (about shorter format) doesn't explain why kitchen executes this job successfully

  4. #4
    Join Date
    May 2014
    Posts
    358

    Default

    I meant maybe the string comes in a different format only when you run it through your program.

  5. #5
    Join Date
    Nov 2015
    Posts
    15

    Default

    if look at "write to log" step, it's impossible. Anyway I refused to use user defined java expression, instead I use set/get variables with an appropriate data conversion. It's solved my problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.