javadockerkubernetesdapr

DaprClientBuilder throws fatal error on SpringBoot app running on Kubernetes


I have two SpringBoot applications as part of Docker image running on Kubernetes (microk8s). I am trying to make an application invoke a HTTP service on a second application via DaprClient. The application deployment looks good, Dapr dashboard show healthy and shows two registered applications. When I finally invoke the service on first application internally it is supposed to invoke the second application via DaprClient but it fails during "DaprClient daprClient = (new DaprClientBuilder()).build();" line. Been stuck at this problem for a while now and I do not know what else to try. I have cross verified the ports but the error is well before calling the client.invoke. Much appreciated if any can point me in the right direction.

Below are the deployment.yaml of the first application1(orderservice):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ordersystem
  labels:
    app: ordersystem
spec:
  selector:
    matchLabels:
      app: ordersystem
  template:
    metadata:
      labels:
        app: ordersystem
      annotations:
        dapr.io/enabled: "true"
        dapr.io/app-id: "ordersystem"
        dapr.io/app-port: "8082"
    spec:
      containers:
      - name: ordersystem
        image: localhost:5000/ordersystem:latest
        ports:
        - containerPort: 8082

Below is the java snippet which is being attempted and the error is after the message ""About to initialize daprClient" and before "Dapr client init worked," so it must be during init.

@Override
    public List<OrderJoinDTO> findAllOrdersDetails() {
        
        List<OrderJoinDTO> orderDTO = (List<OrderJoinDTO>) ordersRepo.findAllOrdersDetails();
        
        for(OrderJoinDTO order: orderDTO) {
            System.out.println("Fething productInfo from DAPR app products for orderId: "+order.getOrderId()+" with productId: "+order.getProductsId());
            
            try {
                System.out.println("About to initialize daprClient,  please wait");
                DaprClient daprClient = (new DaprClientBuilder()).build();
                // invoke a 'GET' method (HTTP) skipping serialization: \say with a Mono<byte[]> return type
                
                System.out.println("Dapr client init worked, proceeding to invoking");
                Products response = daprClient.invokeMethod("products", "findByProductsId/"+order.getProductsId(), null, HttpExtension.GET, Products.class).block();
                
                System.out.println("Retrived from DAPR: "+response.toString());
                order.setPname(response.getPname());
                order.setDescription(response.getDescription());
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
         return orderDTO;
    }

And the error I see on the kubernetes console.

2022-11-08 09:46:33.619  INFO 1 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
Hibernate: select orders0_.orderId as col_0_0_, users1_.userName as col_1_0_, users1_.address as col_2_0_, users1_.email as col_3_0_, userpaymen2_.paymentType as col_4_0_, orders_pro3_.productsId as col_5_0_ from Orders orders0_ cross join Users users1_ cross join UserPayments userpaymen2_ cross join Orders_Products_MAP orders_pro3_ where orders0_.userId=users1_.userId and orders0_.paymentId=userpaymen2_.paymentId and orders0_.orderId=orders_pro3_.orderId
Fething productInfo from DAPR app products for orderId: 1 with productId: 1
About to initialize daprClient,  please wait
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000003efe, pid=1, tid=0x00007f0eb58cbb10
#
# JRE version: OpenJDK Runtime Environment (8.0_212-b04) (build 1.8.0_212-b04)
# Java VM: OpenJDK 64-Bit Server VM (25.212-b04 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.12.0
# Distribution: Custom build (Sat May  4 17:33:35 UTC 2019)
# Problematic frame:
# C  0x0000000000003efe
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# //hs_err_pid1.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://icedtea.classpath.org/bugzilla
#

Solution

  • Finally!!! found the solution here : (JVM crash with grpc-java 1.42.x and alpine docker image)

    The solution is to add below two lines on Dockerfile after which jvm stopped throwing fatal error.

    RUN apk add gcompat
    ENV LD_PRELOAD=/lib/libgcompat.so.0
    

    Probable cause explained here: https://github.com/grpc/grpc-java/issues/8751#issuecomment-995222358