Facing issues with vertx-web-openapi in vertx 4 release

412 views
Skip to first unread message

Nancy Gupta

unread,
Dec 29, 2020, 6:41:15 AM12/29/20
to vert.x
Hi Team,

We are in the process to upgrade our application to the recent vertx 4 release. I am using the vert-web-openapi now but when I am trying to run the service in Kubernetes, I am getting NullPointerException as the spec not being found in the path. After this I get an IllegalStateException as the close hook is null.
 
I am copying the spec file to Verticle Home that is /usr/verticles in my dockerfile.
The same setup is working fine with RouterFactory and OpenAPI3RouterFactory in vertx-web-api-contract library. 

Also, I noticed that with when using File Upload in vertx 4, the vertx Context is becoming null. This is also creating an issue for us.

It would be great if anyone can provide any solution.

Thanks.

Thomas SEGISMONT

unread,
Jan 4, 2021, 5:08:08 AM1/4/21
to vert.x
Hi,
Can you share a simple reproducer?
Thank you,
Thomas

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/64d9c488-827d-4dbd-b06f-7d666f765b9an%40googlegroups.com.
Message has been deleted
Message has been deleted

Nancy Gupta

unread,
Jan 6, 2021, 5:13:00 AM1/6/21
to vert.x
Hi Thomas,
Please find the github link :  
for a simple application which runs perfectly well when running as Java Application in local but when I create its docker image and deploy in Kubernetes, I get the below error:

Failed in deploying verticle 
java.lang.NullPointerException
at io.vertx.ext.web.openapi.impl.OpenAPIHolderImpl.loadOpenAPI(OpenAPIHolderImpl.java:77)
at io.vertx.ext.web.openapi.RouterBuilder.create(RouterBuilder.java:213)
at io.vertx.ext.web.openapi.RouterBuilder.create(RouterBuilder.java:187)
at io.vertx.falcon.TestHelloVerticle.start(TestHelloVerticle.java:17)
at io.vertx.core.AbstractVerticle.start(AbstractVerticle.java:106)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$5(DeploymentManager.java:196)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:59)
at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:40)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)

I have created a vertx 4 docker image locally which I am using to create the docker image for this application. Please find the dockerfile link below:


Commands used:
Creating vertx 4 docker image: docker build -t swde/vertx:4.0.0 .
Build the project: gradle clean build
Create Docker image for the project: docker build -t swde/test-service:1.0.0 .
Run in Kubernetes: kubectl run test-service --image=swde/test-service:1.0.0 --image-pull-policy="IfNotPresent"  --port=8082

Please let me know if any further details required.

Thanks,
Nancy

Nancy Gupta

unread,
Jan 6, 2021, 6:41:31 AM1/6/21
to vert.x
It works if I give the exact path to /usr/verticles for the Spec file, but the doubt is that why I need to specify the full path when the file is present in the classpath. If that is the case then we need to change the code everytime when docker image has to be created.  

Nancy Gupta

unread,
Jan 6, 2021, 8:27:43 AM1/6/21
to vert.x
Related to the file upload issue: In our application we are keeping some data in Vertx Context which we require in each call. If we have a file upload operation, in that scenario the current vertx context is different. So I am unable to get the data we are setting. 
For a simple re-producer, please find the link below:
I have two operations, welcome and file. While starting the verticle, I am adding an object in the vertx context, which I am able to get in Welcome Operation but not in File Operation.

Please provide a solution or a better way to do it. Same thing was working with vertx4-milestone4 version, but issue when using 4.0.0.

Thomas SEGISMONT

unread,
Jan 7, 2021, 5:37:57 AM1/7/21
to vert.x
I had a look at the reproducer. There must be some pieces missing, I can see neither how the app jar is added to the image nor the container is started on K8S

I can only guess but I believe the jar file is not in the current working directory of the process.

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Message has been deleted

Nancy Gupta

unread,
Jan 7, 2021, 6:25:13 AM1/7/21
to vert.x
Hi Thomas,

If you check the Dockerfile, there are these copy commands which is adding the app jar to the image:

COPY $VERTICLE_FILE $VERTICLE_HOME/

COPY src/main/resources/test.json $VERTICLE_HOME/ 

I am not sure if you are understanding the issue. Problem is not with deploying the verticle. That is working fine if I give the complete path as I mentioned in previous posts.

Also I had one more issue related to File Upload, for that even the issue can be replicated if you simply run it as a java program. It would be great if someone can provide any suggestion or solution, guess wont help.

Thanks,
Nancy 

Nancy Gupta

unread,
Jan 7, 2021, 6:47:18 AM1/7/21
to vert.x
  Let me explain the issue in little detail and also to note that this issue I am facing only with vertx 4.0.0

File Upload: 
When verticle starts, I am adding an object in the Vertx Context: 

public class TestHelloVerticle extends AbstractVerticle {

private HttpServer server;

@Override

public void start() {

vertx.getOrCreateContext().put("TestKey", new JsonObject().put("key1", "value1"));  


when I have any other operation other than File Upload, I am able to get this value from the vertx context:

public class WelcomeHandler implements Handler<RoutingContext> {


@Override

public void handle(RoutingContext routingContext) {

System.out.println(routingContext.vertx().getOrCreateContext());

JsonObject json = routingContext.vertx().getOrCreateContext().get("TestKey");

System.out.println(json.encodePrettily());

routingContext.response().end("Welcome");


}

But in File Handler, when I upload the file, the current context is different, and I am not getting that object:


public class FileHandler implements Handler<RoutingContext> {


@Override

public void handle(RoutingContext routingContext) {

if (routingContext.fileUploads() != null && !routingContext.fileUploads().isEmpty()) {

System.out.println(Vertx.currentContext());

JsonObject json1 = Vertx.currentContext().get("TestKey");

System.out.println(json1);

System.out.println(routingContext.vertx().getOrCreateContext());

JsonObject json2 = routingContext.vertx().getOrCreateContext().get("TestKey");

System.out.println(json2);

FileUpload fileUpload = routingContext.fileUploads().iterator().next();

routingContext.response().end("Testing File Upload");

}

}

}  


Here I am getting null. This was not the behaviour with previous versions. I have been using vertx4-milestone4 version. Please suggest a solution for this.

Thomas SEGISMONT

unread,
Jan 7, 2021, 9:39:50 AM1/7/21
to vert.x
Le jeu. 7 janv. 2021 à 12:25, Nancy Gupta <nancyg...@gmail.com> a écrit :
Hi Thomas,

If you check the Dockerfile, there are these copy commands which is adding the app jar to the image:

COPY $VERTICLE_FILE $VERTICLE_HOME/

COPY src/main/resources/test.json $VERTICLE_HOME/ 

That's why I asked
 

I am not sure if you are understanding the issue. Problem is not with deploying the verticle. That is working fine if I give the complete path as I mentioned in previous posts.

I understood the issue. You have a problem with loading the OpenAPI file, only when you run the app to k8s.
Given the info present in the reproducer are not sufficient to reproduce myself, I can only guess. And my guess is the file is not present in the current working directory of the JVM process.
 

Also I had one more issue related to File Upload, for that even the issue can be replicated if you simply run it as a java program. It would be great if someone can provide any suggestion or solution, guess wont help.

Lack of information to reproduce won't help either.
 

Nancy Gupta

unread,
Jan 7, 2021, 9:53:47 AM1/7/21
to vert.x
The dockerfile for the app is located at :


# Extend vert.x image

FROM swde/vertx:4.0.0

ENV VERTICLE_NAME io.vertx.falcon.TestHelloVerticle

ENV VERTICLE_FILE build/libs/vertx4-poc-1.0.0-SNAPSHOT.jar

# Set the location of the verticles

ENV VERTICLE_HOME /usr/verticles

EXPOSE 8082

# Copy your verticle to the container

COPY $VERTICLE_FILE $VERTICLE_HOME/

COPY src/main/resources/test.json $VERTICLE_HOME/

ADD build/distributions/vertx4-poc-1.0.0-SNAPSHOT.tar $VERTICLE_HOME

RUN cp $VERTICLE_HOME/vertx4-poc-1.0.0-SNAPSHOT/lib/* $VERTX_HOME/lib && \

rm -rf $VERTICLE_HOME/vertx4-poc-1.0.0-SNAPSHOT


# Launch the verticle

WORKDIR $VERTICLE_HOME

ENTRYPOINT ["sh", "-c"]

CMD ["exec vertx run $VERTICLE_NAME -cp $VERTICLE_HOME/*"]  


Here if you see I am extending swde/vertx4 image. The dockerfile for this vertx 4 image is at https://github.com/nancygupta91/vertx4-poc/blob/main/vert.x%20docker-4.0.0/Dockerfile what I also mentioned in the previous posts as well.

Secondly, for the file upload, what else you require in the re-producer ? Its just that when I am doing a file upload operation the vertx context associated with the handler is different. I want to have the same context. There are two handlers in the re-producer. There are print statements. In the previous post, I have explained that as well.

Thomas SEGISMONT

unread,
Jan 7, 2021, 12:02:29 PM1/7/21
to vert.x
I was able to build the two images and reproduce locally. I filed this: https://github.com/vert-x3/vertx-web/issues/1838
The fix will be present in 4.0.1.

I haven't looked into the File upload yet and will come back to you later.



Thomas SEGISMONT

unread,
Jan 8, 2021, 10:35:07 AM1/8/21
to vert.x
The file upload issue: https://github.com/eclipse-vertx/vert.x/issues/3739
It will be fixed in 4.0.1 as well

Thank you for reporting these issues.

Side note: is there any reason why in the container you run the application with the CLI? For Java applications, it might be simpler to:

- either package an executable uber JAR (with Maven Shade Plugin or Vert.x Maven Plugin) and run it inside the container
- create a layaered image with Google Jib

Nancy Gupta

unread,
Jan 11, 2021, 2:28:49 AM1/11/21
to vert.x
May I know when is 4.0.1 planned to be released? 
Also is there any workaround in 4.0.0 for this issue?


As per our architecture standards, we are not supposed to use fat jars, hence we are using light weights jars with vertx base image and CLI 
​and we are not aware of the 2nd option with layered image with google Jib.

Thanks,
Nancy

Thomas SEGISMONT

unread,
Jan 11, 2021, 4:07:11 AM1/11/21
to vert.x
Le lun. 11 janv. 2021 à 08:28, Nancy Gupta <nancyg...@gmail.com> a écrit :
May I know when is 4.0.1 planned to be released? 

There is no planned date yet. Most probably within a few weeks.
 
Also is there any workaround in 4.0.0 for this issue?

For the NPE, you could provide an absolute file path to the OpenAPI file instead of a relative one.
For the upload issue, I'm not sure there's an easy workaround.



As per our architecture standards, we are not supposed to use fat jars, hence we are using light weights jars with vertx base image and CLI 
and we are not aware of the 2nd option with layered image with google Jib.

Reply all
Reply to author
Forward
0 new messages