Error when calling catalog api

118 views
Skip to first unread message

Mohamad Mahdi Swaidan

unread,
Nov 6, 2023, 7:47:28 AM11/6/23
to Kill Bill users mailing-list
Hello,

Please I need help , I was trying to add a catalog from kaui but I got error : org.killbill.billing.catalog.DefaultProduct cannot be cast to org.killbill.billing.catalog.api.Plan

now I got the same error when trying to get the already created catalogs from Kaui and from the killbill api too

karan bansal

unread,
Nov 6, 2023, 11:37:59 AM11/6/23
to Kill Bill users mailing-list
Hi Mohamad,

This looks more like some issue with the cast operation. Could you please provide me more details like version of killbill, exact steps to reproduce, the api call, the catalog etc. that you are using.

Regards
Karan

Mohamad Mahdi Swaidan

unread,
Nov 7, 2023, 2:10:38 AM11/7/23
to Kill Bill users mailing-list
Hi Karan
Thank you for your reply
I am using  killbill:0.22.32, As I mentioned first I created a catalog to test stripes payment plugin and all was working.
The issue happened when I was trying to apply this: https://docs.killbill.io/latest/push_notifications
I reached the section : Make some configuration changes in a tenant so that Kill Bill pushes a notification on an event change. For example, add a new plan to a catalog. This will trigger a TENANT_CONFIG_CHANGE event.
So when I created a new catalog and click I got error , then after refreshing the page the existing catalog was gone from kaui , and when I try: curl -X GET "https://localhost:8080/1.0/kb/catalog" -H  "accept: application/json" -H  "authorization: Basic YWRtaW46cGFzc3dvcmQ=" -H  "X-Killbill-ApiKey: test" -H  "X-Killbill-ApiSecret: testtest"
I got the error : 500 { "className": "java.lang.ClassCastException", "code": null, "message": "org.killbill.billing.catalog.DefaultProduct cannot be cast to org.killbill.billing.catalog.api.Plan", "causeClassName": null, "causeMessage": null, "stackTrace": [] }
from the db I can see the old catalog there :
select * from catalog_override_plan_definition
killbill-> ;
 record_id | parent_plan_name |   effective_date    | is_active |    created_date     | created_by | tenant_record_id
-----------+------------------+---------------------+-----------+---------------------+------------+------------------
         1 | sports-monthly   | 2023-10-04 11:20:32 | t         | 2023-10-05 11:32:40 | demo       |                1
         2 | sports-monthly   | 2023-10-04 11:20:32 | t         | 2023-10-10 14:00:50 | demo       |                1
but not the new one I created.
Also I am getting the same error if trying to a catalog from kaui

karan bansal

unread,
Nov 7, 2023, 6:52:48 AM11/7/23
to Kill Bill users mailing-list
Hi Mohamad,

Thank you for explaining this. Please send me your existing catalog and the call that you used to add the plan to the catalog. 

For example, I am using the below call and it is working ok for me.

curl -X POST "http://localhost:8080/1.0/kb/catalog/simplePlan" -H "accept: application/json" -H "X-Killbill-CreatedBy: KB" -H "authorization: Basic YWRtaW46cGFzc3dvcmQ=" -H "X-Killbill-ApiKey: tomcattenantkey" -H "X-Killbill-ApiSecret: tomcattenantsecret" -H "Content-Type: application/json" -d "{ \"planId\": \"Plan_B\", \"productName\": \"ProdA\", \"productCategory\": \"BASE\", \"currency\": \"USD\", \"amount\": 50, \"billingPeriod\": \"MONTHLY\", \"trialLength\": 0, \"trialTimeUnit\": \"DAYS\"}"

Regards
Karan

Mohamad Mahdi Swaidan

unread,
Nov 7, 2023, 7:46:46 AM11/7/23
to Kill Bill users mailing-list
Hi ,
I was adding the catalog from kaui interface , not from the API , you can see the existing catalogs from the db above , but as I mentioned the api to get catalog is giving the error

karan bansal

unread,
Nov 7, 2023, 8:59:27 AM11/7/23
to Kill Bill users mailing-list
Hi Mohamad,

Could you query the table tenant_kvs for the particular tenant ( tenant_record_id ). You will find the xml catalog in the field tenant_value, the active catalog will be the one with is_active set to 1. 

Regards
Karan

Mohamad Mahdi Swaidan

unread,
Nov 7, 2023, 9:42:47 AM11/7/23
to Kill Bill users mailing-list
SELECT tenant_record_id, tenant_value, is_active
FROM killbillschema.tenant_kvs WHERE tenant_record_id = 1 AND is_active = true;

there are more than 1 record with is_active true , the one with xml in the tenant_value is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<catalog>
    <effectiveDate>2023-10-04T11:20:32Z</effectiveDate>
    <catalogName>DEFAULT</catalogName>
    <recurringBillingMode>IN_ADVANCE</recurringBillingMode>
    <currencies>
        <currency>USD</currency>
    </currencies>
    <units/>
    <products>
        <product name="Sports" prettyName="Sports">
            <category>BASE</category>
            <included/>
            <available/>
            <limits/>
        </product>
        <product name="test" prettyName="test">
            <category>BASE</category>
            <included/>
            <available/>
            <limits/>
        </product>
    </products>
    <rules>
        <changePolicy>
            <changePolicyCase>
                <policy>IMMEDIATE</policy>
            </changePolicyCase>
        </changePolicy>
        <changeAlignment>
            <changeAlignmentCase>
                <alignment>START_OF_BUNDLE</alignment>
            </changeAlignmentCase>
        </changeAlignment>
        <cancelPolicy>
            <cancelPolicyCase>
                <policy>IMMEDIATE</policy>
            </cancelPolicyCase>
        </cancelPolicy>
        <createAlignment>
            <createAlignmentCase>
                <alignment>START_OF_BUNDLE</alignment>
            </createAlignmentCase>
        </createAlignment>
        <billingAlignment>
            <billingAlignmentCase>
                <alignment>ACCOUNT</alignment>
            </billingAlignmentCase>
        </billingAlignment>
        <priceList>
            <priceListCase>
                <toPriceList>DEFAULT</toPriceList>
            </priceListCase>
        </priceList>
    </rules>
    <plans>
        <plan name="sports-monthly" prettyName="sports-monthly">
            <product>Sports</product>
            <recurringBillingMode>IN_ADVANCE</recurringBillingMode>
            <initialPhases/>
            <finalPhase type="EVERGREEN">
                <duration>
                    <unit>UNLIMITED</unit>
                    <number>-1</number>
                </duration>
                <recurring>
                    <billingPeriod>MONTHLY</billingPeriod>
                    <recurringPrice>
                        <price>
                            <currency>USD</currency>
                            <value>10</value>
                        </price>
                    </recurringPrice>
                </recurring>
                <usages/>
            </finalPhase>
            <plansAllowedInBundle>-1</plansAllowedInBundle>
        </plan>
        <plan name="test1" prettyName="test1">
            <product>test</product>
            <recurringBillingMode>IN_ADVANCE</recurringBillingMode>
            <initialPhases/>
            <finalPhase type="EVERGREEN">
                <duration>
                    <unit>UNLIMITED</unit>
                    <number>-1</number>
                </duration>
                <recurring>
                    <billingPeriod>MONTHLY</billingPeriod>
                    <recurringPrice>
                        <price>
                            <currency>USD</currency>
                            <value>10</value>
                        </price>
                    </recurringPrice>
                </recurring>
                <usages/>
            </finalPhase>
            <plansAllowedInBundle>-1</plansAllowedInBundle>
        </plan>
    </plans>
    <priceLists>
        <defaultPriceList name="DEFAULT" prettyName="DEFAULT">
            <plans>
                <plan>sports-monthly</plan>
                <plan>test</plan>
                <plan>test1</plan>
            </plans>
        </defaultPriceList>
    </priceLists>
</catalog>

karan bansal

unread,
Nov 7, 2023, 11:27:16 AM11/7/23
to Kill Bill users mailing-list
Hi Mohamad,

The issue with this catalog is that you are specifying the plan name as test ( right at the end ), that is actually a product name, which makes the catalog invalid. 

You will need to use the API to delete the catalog, then invalidate the tenant cache, and then reupload the correct catalog.

Regards
Karan

Shaun Forgie

unread,
Nov 7, 2023, 2:34:18 PM11/7/23
to karan bansal, Kill Bill users mailing-list
HI Karan,

So the catalog name and the product name can not be the same value. Is this a check included in the catalog validator currently?

Rgs
Shaun

--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/killbilling-users/0f1b1f46-2c7d-48cf-baab-6e14b7d8310an%40googlegroups.com.


--
Shaun Forgie [Principal] - Method Maker Ltd
57a McIntyre Rd, Manukau 2022, Auckland, New Zealand
Mobile +64 21 666 910

Mohamad Mahdi Swaidan

unread,
Nov 8, 2023, 2:23:25 AM11/8/23
to Kill Bill users mailing-list
Hi Karan ,
Thank you , I see that now , I did what you suggested and all looks good now .
But i am worried what caused this to happen , I am pretty sure that the plan name was sports-monthly and it was already working fine.

karan bansal

unread,
Nov 8, 2023, 6:30:26 AM11/8/23
to Kill Bill users mailing-list
Hi Shaun,

Not the catalog name, it was the plan name. Below is the part from the catalo. There is already a product named test defined in the catalog, so when it was  included as the plan name, the system showed the error about not being able to cast product to plan. As of now, this check is not included, will look into adding the validation. 

 <priceLists>
        <defaultPriceList name="DEFAULT" prettyName="DEFAULT">
            <plans>
                <plan>sports-monthly</plan>
                <plan>test</plan>
                <plan>test1</plan>
            </plans>
        </defaultPriceList>
    </priceLists>

Regards
Karan

karan bansal

unread,
Nov 8, 2023, 6:32:37 AM11/8/23
to Kill Bill users mailing-list
Hi Mohamad,

You mentioned that you tried to add a plan, may be that is where it happened. I will try and reproduce it at our end too.

Regards
Karan

Mohamad Mahdi Swaidan

unread,
Nov 13, 2023, 3:17:49 AM11/13/23
to Kill Bill users mailing-list
Hello , I meant I was trying to add a catalog , I guess using the same name for product and plan in the same catalog causes the issue.

karan bansal

unread,
Nov 13, 2023, 10:58:47 AM11/13/23
to Kill Bill users mailing-list
Hi Mohamad,

No worries, we will be adding some validation around this.

Regards
Karan

Reply all
Reply to author
Forward
Message has been deleted
0 new messages