Rag...JN 🌌 🦡 👽 💰 🐊
Rag...JN 🌌 🦡 👽 💰 🐊
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 11/11/2024 in #java-help
Deploying my java app to VPS with Github actions and Dockerization
This is the deployment code I got from our existing project
name: build and deploy movie app service backend

on:
push:
branches:
- dev

jobs:
build-deploy:
name: build and deploy city-app-movie-backend
runs-on: ubuntu-22.04

steps:
- name: checkout code
uses: actions/checkout@v3

- name: setup jdk 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 21

- name: grant execute permission for gradlew
run: chmod +x ./gradlew

- name: build the app
run: ./gradlew clean build -x test

- name: login to docker hub
uses: docker/login-action@v1
with:
username: ragjn_the_goat
password: password

- name: push the docker image to docker hub
uses: docker/build-push-action@v4
with:
context: .
dockerfile: Dockerfile
push: true
tags: rag_jn_ep/city-app-movie-backend:latest

- name: Deploy on contabo
env:
SSH_PASS: rag_the_goat
run: |
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no [email protected] << EOF
#Stop the existing container
docker stop city-app-movie-backend || true
docker rm city-app-movie-backend || true
docker pull rag_jn_ep/city-app-movie-backend:latest
docker run --name city-app-movie-backend -d -p 8086:8086 -p 9002:9002 --network my-bridge-network \
--mount type=bind,source=/var/log/movie-service,target=/logs \
rag_jn_ep/city-app-movie-backend:latest
EOF
name: build and deploy movie app service backend

on:
push:
branches:
- dev

jobs:
build-deploy:
name: build and deploy city-app-movie-backend
runs-on: ubuntu-22.04

steps:
- name: checkout code
uses: actions/checkout@v3

- name: setup jdk 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 21

- name: grant execute permission for gradlew
run: chmod +x ./gradlew

- name: build the app
run: ./gradlew clean build -x test

- name: login to docker hub
uses: docker/login-action@v1
with:
username: ragjn_the_goat
password: password

- name: push the docker image to docker hub
uses: docker/build-push-action@v4
with:
context: .
dockerfile: Dockerfile
push: true
tags: rag_jn_ep/city-app-movie-backend:latest

- name: Deploy on contabo
env:
SSH_PASS: rag_the_goat
run: |
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no [email protected] << EOF
#Stop the existing container
docker stop city-app-movie-backend || true
docker rm city-app-movie-backend || true
docker pull rag_jn_ep/city-app-movie-backend:latest
docker run --name city-app-movie-backend -d -p 8086:8086 -p 9002:9002 --network my-bridge-network \
--mount type=bind,source=/var/log/movie-service,target=/logs \
rag_jn_ep/city-app-movie-backend:latest
EOF
6 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 10/14/2024 in #java-help
PostGIS distance calculation gives in-accurate results
@Query(value = "SELECT ST_Distance(" +
"ST_SetSRID(ST_MakePoint(:userLng, :userLat), 4326), " +
"ST_SetSRID(ST_MakePoint(:hotelLng, :hotelLat), 4326)" +
") AS distance", nativeQuery = true)
Double hotelDistanceBetweenUser2(@Param("userLng") Double userLongitude,
@Param("userLat") Double userLatitude,
@Param("hotelLng") Double hotelLongitude,
@Param("hotelLat") Double hotelLatitude);
@Query(value = "SELECT ST_Distance(" +
"ST_SetSRID(ST_MakePoint(:userLng, :userLat), 4326), " +
"ST_SetSRID(ST_MakePoint(:hotelLng, :hotelLat), 4326)" +
") AS distance", nativeQuery = true)
Double hotelDistanceBetweenUser2(@Param("userLng") Double userLongitude,
@Param("userLat") Double userLatitude,
@Param("hotelLng") Double hotelLongitude,
@Param("hotelLat") Double hotelLatitude);
84 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 8/5/2024 in #java-help
JWT Authentication with SpringBoot
So it gives me a successful token, but when I use it for authorized pages, I get a 403, Access denied on the backend
167 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 7/11/2024 in #java-help
How do you understand this code, BinarySearch Delete
Is my guess correct?
9 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 7/10/2024 in #java-help
Is there any way to fix this Binary Search Algorithm?
I am trying to make a binary search but it has problems
12 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 7/9/2024 in #java-help
Same Tree LeetCode
What am I doing wrong here
21 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 6/11/2024 in #java-help
Can anyone fact check to understand my code's time complexity which was genearated by AI
6 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 6/6/2024 in #java-help
Binary search experimental way
62 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 5/19/2024 in #java-help
JUnit, can I create an EntityManager or even a session without running the server?
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
public class OrderTest {
@PersistenceContext(unitName = "WebPU")
private EntityManager em;

@BeforeAll
public static void setUpClass() {

}
@Test
public boolean testOrderCreation() {
List<Destination> destinationList = em.createQuery("SELECT dt FROM Destination dt WHERE dt.id=:id", Destination.class)
.setParameter("id", 1).getResultList();
Destination destination = destinationList.get(0);
if (destinationList.size() != 1) {
return false;
}
List<Product> productList = em.createQuery("SELECT pdt FROM Product pdt WHERE pdt.id=:id", Product.class)
.setParameter("id", 1).getResultList();

if (productList.size() != 1) {
return false;
}
Product product = productList.get(0);

Orders order = new Orders();
order.setProductId(product);
order.setDestination(destination);
order.setQty(10);
order.setCreatedAt(LocalDateTime.now());
order.setExpectedDate(LocalDateTime.now().plusDays(5));
order.setOrderStatus("not_shipped");
em.persist(order);
return true;
}
}
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
public class OrderTest {
@PersistenceContext(unitName = "WebPU")
private EntityManager em;

@BeforeAll
public static void setUpClass() {

}
@Test
public boolean testOrderCreation() {
List<Destination> destinationList = em.createQuery("SELECT dt FROM Destination dt WHERE dt.id=:id", Destination.class)
.setParameter("id", 1).getResultList();
Destination destination = destinationList.get(0);
if (destinationList.size() != 1) {
return false;
}
List<Product> productList = em.createQuery("SELECT pdt FROM Product pdt WHERE pdt.id=:id", Product.class)
.setParameter("id", 1).getResultList();

if (productList.size() != 1) {
return false;
}
Product product = productList.get(0);

Orders order = new Orders();
order.setProductId(product);
order.setDestination(destination);
order.setQty(10);
order.setCreatedAt(LocalDateTime.now());
order.setExpectedDate(LocalDateTime.now().plusDays(5));
order.setOrderStatus("not_shipped");
em.persist(order);
return true;
}
}
42 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 5/14/2024 in #java-help
Can't build the project "Artifacts builder: Archive doesn't contain files so it won't be created"
Artifacts builder: Archive 'F:/web_multi_module_2/final_project/jta-app/ear/target/ear-1.0.ear!/com.jiat-ejb-1.0.jar' doesn't contain files so it won't be created
Artifacts builder: Archive 'F:/web_multi_module_2/final_project/jta-app/ear/target/ear-1.0.ear!/com.jiat-ejb-1.0.jar' doesn't contain files so it won't be created
15 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 5/6/2024 in #java-help
Couldn't understand what this para on interceptor lifecyle callback
No description
12 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 4/24/2024 in #java-help
What to do, the steps, the guides on configuring the Glassfish server with MySQL Dataresource
No description
34 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 3/18/2024 in #java-help
Compile error web module (war), cannot find symbol but the other class didn't show any error
No description
87 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 3/11/2024 in #java-help
Trying to set an object into a EJB Bean array from a remote app.
I am trying to set a object to an stateful EJB which has an array. If I do this in the Web container in a servlet it works fine but when I try do the same in the remote application I am getting an marshalling error Let me put the codes and more details
19 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 3/10/2024 in #java-help
Request to the servlet not working after changing project groupid in multi module project
So I received my lecturer's app and it runs without any problem But when I changed the group id from "com.jiat" to "com.rag" The Servlet in the web module throws 404
38 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 2/24/2024 in #java-help
Please explain what is this project is about (Multi Module Java Project)?
I have no idea what's going on here with the ejb, cor, web and stuff and the purpose of this project.
120 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 2/6/2024 in #java-help
How to live update chat screen when a new chat is entered to the ChatHistory context (Static list)
In the Swing application
58 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 2/4/2024 in #java-help
Do I have a possibility to use Flyweight Pattern for this scenario
So I have a order management system CustomerOrder will have multiple food items and a Customer
39 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 1/28/2024 in #java-help
Interpreter Design pattern
This is what I came up with so far it has issues and wrongly used
213 replies
JCHJava Community | Help. Code. Learn.
Created by Rag...JN 🌌 🦡 👽 💰 🐊 on 1/7/2024 in #java-help
Mediator Pattern Code How does this code actually built because it's not actually straight forward
So I am following this code example for mediator pattern https://refactoring.guru/design-patterns/mediator/java/example
32 replies