Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.net.MalformedURLException: For input string: "${env.PORT.TRAFFIC}" during apim api export #332

Closed
denache19 opened this issue Nov 30, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@denache19
Copy link

APIM-CLI version

1.13.2

API-Management version

7.7.0.20211130

Bug description

When referencing in the backend base urls environment variables defined in envSettings.props file the following is raised during export.

2022-11-30 11:44:51,985 [APISpecificationFactory] DEBUG: Can't handle API specification with class: com.axway.apim.api.apiSpecification.Swagger2xSpecification
2022-11-30 11:44:52,021 [APIManagerAPIAdapter] ERROR: Error setting remote host for API based on backendBasePath: http://${env.HOSTNAME}:${env.PORT.TRAFFIC}/healthcheck
java.net.MalformedURLException: For input string: "${env.PORT.TRAFFIC}"
at java.net.URL.(URL.java:645)
at java.net.URL.(URL.java:508)
at java.net.URL.(URL.java:457)
at com.axway.apim.adapter.apis.APIManagerAPIAdapter.addRemoteHost(APIManagerAPIAdapter.java:303)
at com.axway.apim.adapter.apis.APIManagerAPIAdapter.getAPIs(APIManagerAPIAdapter.java:101)
at com.axway.apim.APIExportApp.execute(APIExportApp.java:212)
at com.axway.apim.APIExportApp.exportAPI(APIExportApp.java:87)
at com.axway.apim.APIExportApp.exportAPI(APIExportApp.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.axway.apim.cli.APIManagerCLI.run(APIManagerCLI.java:132)
at com.axway.apim.cli.APIManagerCLI.main(APIManagerCLI.java:76)
Caused by: java.lang.NumberFormatException: For input string: "${env.PORT.TRAFFIC}"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:569)
at java.lang.Integer.parseInt(Integer.java:615)
at java.net.URLStreamHandler.parseURL(URLStreamHandler.java:222)
at java.net.URL.(URL.java:640)
... 13 more

Steps to reproduce

  1. Create a sample API or modify an api to have for the backend the "Base URL" to use environmentalized fields (being present/provided within ../groups/group-X/instance-Y/envSettings.props) :

Example Base URL: http://${env.HOSTNAME}:${env.PORT.TRAFFIC} , where env.HOSTNAME=IP_APIGW_HOST
Resource path: /resourcepath

  1. Virtualized the api and within the Frontend definition, for Outbound section -->Backend you should have

http://${env.HOSTNAME}:${env.PORT.TRAFFIC}/resourcepath

  1. Attempt the export ./apim.sh -h apigw -port 8075 -u user -p pass -s api get "testapi" -o json
    Attached the relevant log output.

Remark: If I remove in the frontend definition for Outbound the port, "${env.PORT.TRAFFIC}", below error will not be present.

Could it be validation on the variable type (ex:integer as it's a port) but because it gets a string it raises this ?

Relevant log output

2022-11-30 16:05:07,204 [APIManagerAPIAdapter] ERROR: Error setting remote host for API based on backendBasePath: http://${env.HOSTNAME}:${env.PORT.TRAFFIC}
java.net.MalformedURLException: For input string: "${env.PORT.TRAFFIC}"
        at java.net.URL.<init>(URL.java:645)
        at java.net.URL.<init>(URL.java:508)
        at java.net.URL.<init>(URL.java:457)
        at com.axway.apim.adapter.apis.APIManagerAPIAdapter.addRemoteHost(APIManagerAPIAdapter.java:303)
        at com.axway.apim.adapter.apis.APIManagerAPIAdapter.getAPIs(APIManagerAPIAdapter.java:101)
        at com.axway.apim.APIExportApp.execute(APIExportApp.java:212)
        at com.axway.apim.APIExportApp.exportAPI(APIExportApp.java:87)
        at com.axway.apim.APIExportApp.exportAPI(APIExportApp.java:78)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.axway.apim.cli.APIManagerCLI.run(APIManagerCLI.java:132)
        at com.axway.apim.cli.APIManagerCLI.main(APIManagerCLI.java:76)
Caused by: java.lang.NumberFormatException: For input string: "${env.PORT.TRAFFIC}"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:569)
        at java.lang.Integer.parseInt(Integer.java:615)
        at java.net.URLStreamHandler.parseURL(URLStreamHandler.java:222)
        at java.net.URL.<init>(URL.java:640)
        ... 13 more
@denache19 denache19 added the bug Something isn't working label Nov 30, 2022
@rathnapandi rathnapandi added enhancement New feature or request and removed bug Something isn't working labels Nov 30, 2022
rathnapandi added a commit that referenced this issue Feb 3, 2023
- Remove support for apim 7.6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants