I’m encountering a Null Pointer Exception (NPE) when trying to delete a subscription for a monetized API in WSO2 API Manager 4.4.0. The issue does not occur for non-monetized APIs. The error occurs in the APIConsumerImpl.removeSubscription() method, specifically when trying to invoke tier.getTierPlan() on a null tier object.
Here’s the error I see in the UI:
Error occurred when deleting subscription
Request URL: https://linuxmachine:9443/api/am/devportal/v3/subscriptions/7efe7ca0-df76-4ea6-87c8-cea1fb4888c7
Request Method: DELETE
Response: {
"code": 500,
"message": "Internal server error",
"description": "The server encountered an internal error. Please contact administrator.",
"moreInfo": "",
"error": []
}
And here’s the relevant error log from the WSO2 server:
[2025-02-20 15:57:30,199] ERROR - GlobalThrowableMapper An unknown exception has been captured by the global exception mapper.
java.lang.NullPointerException: Cannot invoke ".wso2.carbon.apimgt.api.model.Tier.getTierPlan()" because "tier" is null
at .wso2.carbon.apimgt.impl.APIConsumerImpl.removeSubscription_aroundBody64(APIConsumerImpl.java:1383)
at .wso2.carbon.apimgt.impl.APIConsumerImpl.removeSubscription(APIConsumerImpl.java:1) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.UserAwareAPIConsumer.removeSubscription_aroundBody6(UserAwareAPIConsumer.java:83) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.UserAwareAPIConsumer.removeSubscription(UserAwareAPIConsumer.java:1) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.APIConsumerImpl.removeSubscription_aroundBody68(APIConsumerImpl.java:1457) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.APIConsumerImpl.removeSubscription(APIConsumerImpl.java:1) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.UserAwareAPIConsumer.removeSubscription_aroundBody8(UserAwareAPIConsumer.java:88) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.impl.UserAwareAPIConsumer.removeSubscription(UserAwareAPIConsumer.java:1) ~[.wso2.carbon.apimgt.impl_9.30.67.jar:?]
at .wso2.carbon.apimgt.rest.api.store.v1.impl.SubscriptionsApiServiceImpl.subscriptionsSubscriptionIdDelete(SubscriptionsApiServiceImpl.java:534) ~[?:?]
at .wso2.carbon.apimgt.rest.api.store.v1.SubscriptionsApi.subscriptionsSubscriptionIdDelete(SubscriptionsApi.java:131) ~[?:?]
...
- What I Tried:
- Set up a fresh installation of WSO2 API Manager 4.4.0 on a Linux machine.
- Created a monetized API (enabled monetization for the API).
- Subscribed to the API.
- Attempted to delete the subscription.
- What I Expected:
- The subscription should be deleted successfully, as it works for non-monetized APIs.
- What Actually Happened:
- The deletion fails with a 500 Internal Server Error and a Null Pointer Exception in the logs.
Additional Information
Environment:
- WSO2 API Manager Version: 4.4.0
- Operating System: Linux
- Database: Oracle (fresh installation)
- Deployment: Docker container