CA Service Management

  • 1.  String cannot be cast to java.util.Date

    Posted Oct 27, 2017 07:04 AM

    Hello,

    i'm having problem exporting the ADV and Report only if i add a "domain calculated field (Date type)" in the report.

    When i select the "Export" button i get the error:

    "java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date"

    The problem does not occur if the calculated field is in "string" format.

    Does anyone experienced the same type of problem?

    Thanks a lot in advance

    Regards

    Fulvio



  • 2.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 09:04 AM

    Hi Fulvio,

    Can you clarify for us if this is in BOXI or JASPER reporting, or another reporting engine of some sort?

    Let us know,

    Thanks

    Jon



  • 3.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 09:13 AM

    Hi Jon,

    i'm getting this problem in Jasper reporting.

    Thanks

    Fulvio



  • 4.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 09:58 AM

    Are you using Jasper Studio or is this an ad-hoc report in Jasper Server?

    What data source is being used?

    Jon



  • 5.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 10:09 AM

    I'm using an ad hoc report in Jasper Server and the problem is both for exporting ad Hoc view and report.

    thanks

    Regards

    Fulvio



  • 6.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 10:15 AM

    What data sources are you using?

    Did you create your own domain?



  • 7.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 10:27 AM

    I'm using an MS SQL Server Data Source(tibcosoftware.jdbc.sqlserver.SQLServerDriver) and the Domain was created by customer.

    This is a calculated field defined as Constant in Domain as result of an sql function it returns a Date Field.

    This is how the function has been write:


    CREATE FUNCTION [dbo].[FirstDay](@interval numeric, @datepart char(10))
    RETURNS date AS  
    BEGIN
        declare @Data date
        If (@datepart = 'M') BEGIN set @data=(select convert(date,DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+@interval, 0))) END
        If (@datepart = 'Y') BEGIN set @data=(select convert(date,DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE())+@interval, 0))) END
        If (@datepart = 'Q') BEGIN set @data=(select convert(date,DATEADD(Quarter, DATEDIFF(Quarter, 0, GETDATE())+@interval, 0))) END
        If (@datepart = 'D') BEGIN set @data=(select convert(date,DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE())+@interval, 0))) END
        RETURN @Data
    END

    Thanks

    Regards

    Fulvio



  • 8.  Re: String cannot be cast to java.util.Date
    Best Answer

    Posted Oct 27, 2017 10:35 AM

    Ok - so we store our dates in the database in UNIX (Epoch) time format, and not as a java-timestamp format.  The challenge will be that you would need to convert that to a standard timestamp in order to make sense of it.  I dont know of a way to do that myself and not sure if anyone out there has gotten it to work.   This is actually one of the reasons why we dont support using jasper directly against the MDB for Service Desk.   Service Desk has an object layer which handles the conversion of these things automatically.

    We are in the process of putting together some instructions on how to create a domain against our object layer for SDM.  It requires some manual changes to some files in Jasper for it to work properly, but it can be done.
    Let us know if this is something you would be interested in doing and either myself or another resource familiar with it can provide you some information.

    Thanks,

    Jon I.



  • 9.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 10:52 AM

    Hi Jon,

    yes i'm interested in because in this moment i cannot work on this, the domain created by customer is for ITAM and not Service Desk.

    thank you very much for help

    Regards

    Fulvio



  • 10.  Re: String cannot be cast to java.util.Date

    Posted Oct 27, 2017 10:58 AM

    Yes - its very difficult to do it against the MDB for Service Desk.  Let me reach out to the folks who are running with this and see if they can set up a time to talk to you.   Most likely it would be sometime next week.

    Stay Tuned!

    Jon I.