apisix-java-plugin-runner
apisix-java-plugin-runner copied to clipboard
request help: receive undefined filter: xxxx, skip it
Issue description
custom filter is not applied.
error.log is as below picture.
I am trying to deploy to vm using apisix-docker + apisix-java-plugin-runner. This was done with reference to the below.
- https://apisix.apache.org/docs/apisix/2.15/getting-started/
- https://github.com/apache/apisix-java-plugin-runner/blob/release/0.3.0/docs/zh/quick-start.md
-Detail step-
-
(ubuntu) git clone -b release/apisix-2.15.0 https://github.com/apache/apisix-docker.git
-
(local) git clone -b release/0.3.0 https://github.com/apache/apisix-java-plugin-runner.git
-
write custom plugins in local(macos)
-
(local) cd /apache/apisix-java-plugin-runner-release-0.3.0' and './mvnw package
-
(local) cd dist and Add Dockerfile
-
Transfer the dist folder(apache-apisix-java-plugin-runner-0.3.0-bin.tar.gz, Dockerfile) to ubuntu
-
(ubuntu) cd dist and docker build -t apache/apisix:2.15.0-alpine-with-java-plugin .
-
(ubuntu) Change the apisix image in docker-compose.yml
-
(ubuntu) add the configure in config.yaml file
-
(ubuntu) chmod 777 -R example
-
(ubuntu) cd example and docker-compose up -d
-
(ubuntu) create route and upstream
curl "http://127.0.0.1:9080/apisix/admin/upstreams/99" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d ' { "type": "roundrobin", "nodes": { "10.70.190.49:80": 1 } }'
curl "http://127.0.0.1:9080/apisix/admin/routes/99" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d ' { "methods": ["GET"], "uri": "/managesnsdata/*", "upstream_id": "99", "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "DemoFilter", "value":"{\"validate_header\":\"token\",\"rejected_code\":\"403\"}" } ] } } }'
-
and then curl is called(with/without header value), the custom filter(DemoFilter) is not applied and it responds normally.
How can i apply a filter? plz, review my step and solve this problem... Thank you in advance @tzssangglass
Environment
apisix-docker release/apisix-2.15.0 apisix-java-plugin-runner release/0.3.0 (local, ubuntu) JDK 11 local is macos Ubuntu 20.04.3 LTS
If you are starting the source code directly and putting filters in the runner-plugin
, you need to change <artifactId>apisix-runner-plugin-sdk</artifactId>
to <artifactId>apisix-runner-plugin</artifactId>
in the pom.xml of the runner-core
try with
sed -i 's/apisix-runner-plugin-sdk/apisix-runner-plugin/' runner-core/pom.xml
try with
sed -i 's/apisix-runner-plugin-sdk/apisix-runner-plugin/' runner-core/pom.xml
@tzssangglass
thanks for the answer, but i'm still a beginner.
do you mean that change to sed -i 's/apisix-runner-plugin-sdk/apisix-runner-plugin/'
instead of second line in dockerfile of step5?
or
RUN sed -i "s/dl-cdn.alpinelinux/org/mirrors.aliyun.com/g" /etc/apk/repositories && sed -i 's/apisix-runner-plugin-sdk/apisix-runner-plugin/' runner-core/pom.xml && apk add --no-cache openjdk11-jre
sorry, i can't understand...
@tzssangglass And, is my step a general way to use apisix and java runner together? It cannot be clearly identified and understood with the current reference documentation...
https://github.com/apache/apisix-java-plugin-runner/blob/d5421c292ef0d0ea93fb484afef668d7e2fc8767/runner-core/pom.xml#L38
I mean turn <artifactId>apisix-runner-plugin-sdk</artifactId>
here into <artifactId>apisix-runner-plugin</artifactId>
why? Because you do:
- (local) git clone -b release/0.3.0 apache/apisix-java-plugin-runner.git
and you put your DemoFilter into runner-plugin
.
After you have done with turned <artifactId>apisix-runner-plugin-sdk</artifactId>
here into <artifactId>apisix-runner-plugin</artifactId>
, the jar that generated by ./mvnw package
would contain runner-plugin
(include your DemoFilter).
And, is my step a general way to use apisix and java runner together? It cannot be clearly identified and understood with the current reference documentation...
There is some documentation(ref: https://github.com/apache/apisix-java-plugin-runner/blob/main/docs/en/latest/installation-guide.md), but it's not newbie friendly enough. I'm going to spend time refactoring the documentation.
@tzssangglass Thanks for your help. I will change dependency according to your advice.
And i've already read the installation reference. It was easy to follow(1. create spring boot ~ 6. implementing filter). But I didn't know what to do after that(my question is == how do i combine it with apisix? can i just run the boot image? etc...) That's why I asked if my step was the general way(apisix + java runner) because I couldn't solve the question for the above. I want to clearly understand and learn how to use apisix + java runner.
And i've already read the installation reference. It was easy to follow(1. create spring boot ~ 6. implementing filter). But I didn't know what to do after that(my question is == how do i combine it with apisix? can i just run the boot image? etc...) That's why I asked if my step was the general way(apisix + java runner) because I couldn't solve the question for the above. I want to clearly understand and learn how to use apisix + java runner.
ref: https://medium.com/@ApacheAPISIX/how-to-write-an-apache-apisix-plugin-in-java-3fb7b75444fa
hope this would help you
read the installation reference. It was easy to follow(1. create spring boot ~ 6. implementing filter). But I didn't know what to do after that(my question is == how do i combine
hello,Have you solved this problem? How was it resolved? thanks!