How to Dockerize Jmeter (Distributed testing with Docker and Jmeter) - java

I am using the jmeter 5.2 and the plugin 1.4.0. I am trying to dockerize the my automations in jmeter. But i take an error like following;
Error in rconfigure() method java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: org.apache.jmeter.assertions.JSONPathAssertion (no security manager: RMI class loader disabled)
My Docker-compose file;
version: '3.3'
services:
master:
build: ..
command: master
tty: true
ports:
- "60000"
volumes:
- "./test/:/jmeter/sample/"
networks:
- jmeter-network
server:
image: pedrocesarti/jmeter-docker:latest
command: server
tty: true
ports:
- "50000"
- "1099"
networks:
- jmeter-network
depends_on:
- master
networks:
jmeter-network:
I've tried a lot of solutions but i cannot resolve this problem. Could you help me please? Thanks.

Looking into Dockerfile for pedrocesarti/jmeter-docker
ENV JMETER_VERSION ${JMETER_VERSION:-3.3}
and your test seems to be using JSON Assertion which is available since JMeter 4.0
So you need to replace the JMETER_VERSION variable with version 4.0 or higher and your script should start working as expected.

Related

unable to start Apache NiFi UI

I have created a container for Apache NiFi using a docker-compose file. When I run the docker-compose up command I get the following error when the nifi container is run:
2022-10-19 14:59:34,234 WARN [main] org.apache.nifi.web.server.JettyServer Failed to start the web server... shutting down.
nifi_container_persistent | java.io.IOException: Function not implemented
What exactly is the java.io.IOexception function? Where can I make the required change to that I can fix this error?
Here is the docker compose file for nifi with custom bridge network "my_network":
nifi:
hostname: mynifi
container_name: nifi_container_persistent
image: 'apache/nifi:1.16.1' # latest image as of 2021-11-09.
restart: on-failure
ports:
- '8091:8080'
environment:
- NIFI_WEB_HTTP_PORT=8080
- NIFI_CLUSTER_IS_NODE=true
- NIFI_CLUSTER_NODE_PROTOCOL_PORT=8082
- NIFI_ZK_CONNECT_STRING=myzookeeper:2181
- NIFI_ELECTION_MAX_WAIT=30 sec
- NIFI_SENSITIVE_PROPS_KEY='12345678901234567890A'
healthcheck:
test: "${DOCKER_HEALTHCHECK_TEST:-curl localhost:8091/nifi/}"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 5
volumes:
- ./nifi/database_repository:/opt/nifi/nifi-current/database_repository
- ./nifi/flowfile_repository:/opt/nifi/nifi-current/flowfile_repository
- ./nifi/content_repository:/opt/nifi/nifi-current/content_repository
- ./nifi/provenance_repository:/opt/nifi/nifi-current/provenance_repository
- ./nifi/state:/opt/nifi/nifi-current/state
- ./nifi/logs:/opt/nifi/nifi-current/logs
# uncomment the next line after copying the /conf directory from the container to your local directory to persist NiFi flows
#- ./nifi/conf:/opt/nifi/nifi-current/conf
networks:
- my_network
please help

503 error code for Springboot container connecting to mongo container using docker-compose

I am trying to connect my spring-boot application(REST endpoints) running in a Tomcat container with a mongo container. I am using docker-compose to link both the containers. The application was working perfectly fine. It just stopped working suddenly.
Following is my code:
Dockerfile:
FROM tomcat:9.0.13
WORKDIR /usr/local/tomcat/webapps
#COPY pom.xml .
#RUN ["mvn", "clean", "install"]
COPY /target/TestProfileManager.war .
docker-compose.yml:
version: '3'
services:
app:
container_name: VF-BACKEND
restart: always
build: .
ports:
- "8083:8080" #VF Webservice
depends_on:
- mongo
links:
- mongo
mongo:
container_name: VF-MONGO
image: mongo:4.0.2
ports:
- "27018:27017"
volumes:
- /data/vfdb:/data/db
application.properties
spring.data.mongodb.uri=mongodb://mongo:27018/tsp
If I run the application from the IDE as a standalone application, the endpoints do return the response. Only during container communication, I am getting 503. I could not find any post that answers my question.
Thanks for the help. Since, the code was working before, not pasting the classes. Let me know if I should share them as well.
It should be mongodb://mongo:27017, in service to service communication you do not need to use publish port.
It is important to note the distinction between HOST_PORT and
CONTAINER_PORT. the HOST_PORT is 27018 and the container port is
27017 . Networked service-to-service communication use the
CONTAINER_PORT
compose-networking

Creating docker container for java jersey app

I've been stuck on this for a good bit now and can't find the solution anywhere. I'm writing a java rest service using jersey framework, maven as a package manager hosted on a apache tomcat.
The project works perfectly fine locally. I want to dockerize the application and really struggling. I have the tomcat container up and running and when I go to the root of my application I can see the simple hello text I have. So when I go to http://xxx:8888/npmanager/ at this point I'm seeing what I expect.
Now when I try to hit any of my endpoints i.e https://xxx:8888/npmanager/api/XXX I get a 500 error:
warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for field: private org.glassfish.jersey.server.wadl.WadlApplicationContext org.glassfish.jersey.server.wadl.internal.WadlResource.wadlContext
Dockefile:
FROM tomcat:8.5.38
ADD ./target/npmanager.war /usr/local/tomcat/webapps/
CMD chmod +x /usr/local/tomcat/bin/catalina.sh
CMD ["catalina.sh", "run"]
docker-compose.yml
version: '3'
services:
tomcat-dev:
build: .
environment:
TOMCAT_USERNAME: root
TOMCAT_PASSWORD: root
ports:
- "8888:8080"
mysql-dev:
image: mysql:8.0.2
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: npmanager
volumes:
- /mysql-data:/var/lib/mysql
ports:
- "3308:3306"

com.mongodb.MongoSocketOpenException: Exception opening socket(MongoDB, Docker)

I try to starting my application(Spring Boot + Spring Cloud + Eureka + MongoDB) with using docker image, but i can't get connection to MongoDB.
Exception:
exception "com.mongodb.MongoSocketOpenException: Exception opening socket."
I starting my application with execute command: docker-compose up --build
Docker log:
com.mongodb. MongoSocket0penException: Exception opening socket at com.mongodb. connection. SocketStream.open(SocketStream.java: 63) ~|mongo-java-driver-3.2.2.jar!/:naj
at com. monsoob: connection. berettaberverwontortser/ersonito-kunnablearancerainitservertonitolnava:1203-dionso-java-driver*3?2.2.jarl/:nal
at : java. lang. Thread.run (Thread. java: 745) Lna:1.8.0_111]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect (Native Method) ~ [na: 1.8.0_1111 at java.net.AbstractPlainSocketImp1.doConnect (AbstractplainSocketImpl.java:350) ~ [na: 1.8.0_111]
at java.net.AbstractPlainSocketImp1.connectToAddress(AbstractPlainSocketImp1.java:206)~[na:1.8.0_1111
at java.net .AbstractPlainSocketImp1.connect (AbstractPlain5ocket Imp],java:188) ~[na:1.8.0_111]
at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:392) ~|na:1.8.0_111] java.net Socket. connect (Socket, java: 589) ~[na:1.8:0-111]
at com.mongodb.connection. SocketStreamHelper.initialize(SocketStreamHelper. java: 50) ~ [mongo-java-driver-3.2.2.ar!/:na] at com. mongodb. connection. SocketStream.open(SocketStream. java:58) ~ [mongo-java-driver-3.2.2.jar!/:na]
3 common frames omitted
application.yml:
# Spring properties
spring:
application:
name: car-service
data:
mongodb.host: localhost
mongodb.port: 32769
mongodb.uri: mongodb://localhost/test
mongo.repositories.enabled: true
# Discovery Server Access
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
# HTTP Server (Tomcat) Port
server:
port: 2220
error:
whitelabel:
enabled: false
docker-compose.yml:
eureka:
build: ./eureka-discovery-service
ports:
- "8761:8761"
mongodb:
image: mongo:3.0.4
ports:
- "32769:32769"
postgresql:
image: postgres:9.6.1
ports:
- "32770:32770"
gateway-service:
build: ./gateway-service
ports:
- "9090:9090"
links:
- eureka
environment:
SPRING_APPLICATION_NAME: gateway-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
airplane-service:
build: ./airplane-service
ports:
- "2222:2222"
links:
- eureka
- postgresql
environment:
SPRING_APPLICATION_NAME: airplane-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
SPRING_DATASOURCE_POSTGRESQL_URL: jdbc:postgresql://localhost:32770/postgres
car-service:
build: ./car-service
ports:
- "2220:2220"
links:
- eureka
- mongodb
environment:
SPRING_APPLICATION_NAME: car-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
SPRING_DATA_MONGODB_URI: mongodb://localhost:32769/test
machine-service:
build: ./machine-service
ports:
- "2224:2224"
links:
- eureka
environment:
SPRING_APPLICATION_NAME: machine-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
Why I have exception opening a socket? How to fix this problem?
You are setting mongodb host in property file as localhost. In a container localhost address itself, but your mongodb is not in that container(car-service) which car-service run in. While you are using docker compose, you can address a container with its name. In your case it is mongodb.
to clarify #barbakini's answer, to define it in applications.yaml use:
spring.data.mongodb.host: mongodb
Your mongoDB service is not UP ,
Check the status by following command
sudo service mongodb status
sudo service mongodb start
Hope it should work, there could be several reasons as well ,
like the configuration you defined in your application for mongodb service is incorrect such as port .
Try to add
network_mode: host
and remove
links: ....
for all services, that want to connect with mongo or eureka or postgresql, inside your docker-compose.yml.
By doing so you will connect to docker localhost.

Issue linking containers in Docker using Docker-compose

I'm using Docker to get my micro services architecture ready.
I'm facing some problem trying to link one container with another using docker-compose.
Basically I have a container for a postgressql image, and the a java micro service developed with spring boot that should connect to the database container.
So I'm setting a link in docker-compose.yml and referencing the db container ip as 'db' using :
- "JAVA_OPTS=-Dpostgres.host=db"
However I'm getting the following error starting the microservice with docker:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'postgress.host' in value "jdbc:postgresql://${postgress.host}:5432/docker"
So basically this placeholder cannot be resolved, but normally docker-composed should take care of setting this system variable to point to the db container IP address right?
What I'm doing wrong?
Below the files involved:
docker-compose.yml:
version: "2"
services:
microservices:
build: ./microservices
container_name: microservices
links:
- db
- consul
environment:
- "JAVA_OPTS=-Dpostgres.host=db"
consul:
image: consul
container_name: consul
ports:
- "8500:8500"
db:
image: postgres
container_name: local-postgres9.6
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: docker
POSTGRES_USER: docker
application.yml of the microservice:
server:
port: 8081
project:
jdbc:
url: jdbc:postgresql://${postgres.host}:5432/docker
driver: org.postgresql.Driver
username: docker
password: docker
Try ${db.host}, according to the documentation:
Containers for the linked service will be reachable at a hostname
identical to the alias, or the service name if no alias was specified.

Categories