Saeed Muhaisen
Saeed Muhaisen
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 5/2/2025 in #java-help
Springboot Migration Automation
Is there a way to generate an SQL file for all changes that happens to my entities each time i start my app such that i can copy/paste this sql file into my production and manually alter my tables after i finish working on a feature in springboot that would change some entities?
96 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 7/22/2024 in #java-help
Springboot GenerationType.UUID not working
@Table(name = "Product")
public class Product {

@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
@Table(name = "Product")
public class Product {

@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
On create drop the sql field becomes:
id uuid not null primary key,
id uuid not null primary key,
upon inserting a row without specifying my Id field i get the error:
[23502] ERROR: null value in column "id" of relation "product" violates not-null constraint
[23502] ERROR: null value in column "id" of relation "product" violates not-null constraint
14 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 7/19/2024 in #java-help
Database import issue
No description
4 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 7/14/2024 in #java-help
Spring boot - Detached entity passed to persist
In my UserRequest entity i have the following:
public class UserRequest {

@OneToOne(cascade = CascadeType.ALL) //i tried persist
@JoinColumn(name = "user_id")
private User user;
public class UserRequest {

@OneToOne(cascade = CascadeType.ALL) //i tried persist
@JoinColumn(name = "user_id")
private User user;
and in User i have the following:
public class User implements UserDetails {

@OneToOne(mappedBy = "user") //i tried without connecting it at all
private UserRequest userRequest;
public class User implements UserDetails {

@OneToOne(mappedBy = "user") //i tried without connecting it at all
private UserRequest userRequest;
when i try to save or update User through saving UserReqeust entity i get error: detached entity passed to persist, how can i fix it through connecting the classes correctly?
36 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 7/8/2024 in #java-help
Docker issue with Spring boot 3.2.2 and PostgreSQL on AWS
I have been running into issues figuring out how to dockerize my image and upload it to aws. Here is my dockerfile:
# Stage 1: Build the application
FROM maven:3.8.4-openjdk-17 AS build

WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean install

# Stage 2: Run the application
FROM openjdk:21
WORKDIR /app
COPY --from=build /app/target/HarmonyTracker-BE-0.0.1-SNAPSHOT.jar ./demo-aws.jar
COPY src/main/resources/application.properties /app/application.properties
COPY src/main/resources/keys/AuthKey_Z3XCBR246A.p8 /app/keys/AuthKey_Z3XCBR246A.p8
EXPOSE 8080
CMD ["java", "-jar", "demo-aws.jar"]
# Stage 1: Build the application
FROM maven:3.8.4-openjdk-17 AS build

WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean install

# Stage 2: Run the application
FROM openjdk:21
WORKDIR /app
COPY --from=build /app/target/HarmonyTracker-BE-0.0.1-SNAPSHOT.jar ./demo-aws.jar
COPY src/main/resources/application.properties /app/application.properties
COPY src/main/resources/keys/AuthKey_Z3XCBR246A.p8 /app/keys/AuthKey_Z3XCBR246A.p8
EXPOSE 8080
CMD ["java", "-jar", "demo-aws.jar"]
This is my docker-compose:
version: '3.8'
services:
db:
image: postgres
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"

app:
build: .
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/postgres
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: 123456
depends_on:
- db
version: '3.8'
services:
db:
image: postgres
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"

app:
build: .
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/postgres
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: 123456
depends_on:
- db
when composing or building i get errors in postgres connection attempt failed.
in pom.xml:
in pom.xml:
<properties> <java.version>17</java.version> </properties>
and:
and:
xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> ``` I ran to so much issues because i was on java 21 and mvn had errors, but at this point i cannot figure it out at all Any help would be truly appreciated. Errors i get when running the container are usually postgres connection issue and tomcat server not starting issues, i am sure i am making a mistake in connecting the app to postgres but idk what i am missing
9 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 4/3/2024 in #java-help
Opinion on Database Schema
No description
101 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 1/26/2024 in #java-help
Security Question for Spring boot
No description
34 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 1/21/2024 in #java-help
[GENERAL Q] Spring boot Authenticating Apple user credentials
I am working on React native for front end, i managed to do Apple Sign in button, and after correctly logging in i receive a response of credentials containing the following:
{
"authorizationCode": "....",
"email": null,
"fullName": {"familyName": null, "givenName": null, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},
"identityToken":"....",
"realUserStatus": 1,
"state": null,
"user": "...."}
{
"authorizationCode": "....",
"email": null,
"fullName": {"familyName": null, "givenName": null, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},
"identityToken":"....",
"realUserStatus": 1,
"state": null,
"user": "...."}
I send these information to my backend which is in Spring boot Now i would like to ask, generally what am i supposed to do with this information and how can i validate it so that i can send a response with my access_token and refresh_token back to the client? I am completly lost on this
4 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 1/21/2024 in #java-help
[GENERAL Q] Spring boot Authenticating Apple user credentials
I am working on React native for front end, i managed to do Apple Sign in button, and after correctly logging in i receive a response of credentials containning the following:
{
"authorizationCode": "....",
"email": null,
"fullName": {"familyName": null, "givenName": null, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},
"identityToken":"....",
"realUserStatus": 1,
"state": null,
"user": "...."}
{
"authorizationCode": "....",
"email": null,
"fullName": {"familyName": null, "givenName": null, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},
"identityToken":"....",
"realUserStatus": 1,
"state": null,
"user": "...."}
I send these information to my backend which is in Spring boot Now i would like to ask, generally what am i supposed to do with this information and how can i validate it so that i can send a response with my access_token and refresh_token back to the client? I am completly lost on this
4 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 5/29/2023 in #java-help
I cannot use spring boot application on AWS EC2
Basically i have a running application on localhost, when i try to run my application on Aws ec2 , it gives me errors and i cannot understand why. I uploaded the full error file but here is what is i think causing the issue:
70 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 5/24/2023 in #java-help
dependency suddenly stopped working
public static void printBlockChain(){
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("Index","Hashcode","User","Transaction","Time");
for (Block block : blockChain.getBlocks()) {
at.addRule();
at.addRow(block.getIndex(),block.getHash(),block.getTransactions()[0],block.getTransactions()[1],block.getTransactions()[2]);
}
at.addRule();
String rend= at.render();
System.out.println(rend);
}
public static void printBlockChain(){
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("Index","Hashcode","User","Transaction","Time");
for (Block block : blockChain.getBlocks()) {
at.addRule();
at.addRow(block.getIndex(),block.getHash(),block.getTransactions()[0],block.getTransactions()[1],block.getTransactions()[2]);
}
at.addRule();
String rend= at.render();
System.out.println(rend);
}
I use this AsciiTable dependency, the import no longer function i get this error:
java: package de.vandermeer.asciitable does not exist
java: package de.vandermeer.asciitable does not exist
and
java: cannot find symbol
symbol: class AsciiTable
location: class org.CS446.Controller
java: cannot find symbol
symbol: class AsciiTable
location: class org.CS446.Controller
22 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 5/17/2023 in #java-help
Socket input stream keeps closing or EOF Exception
ServerSocket serverSocket = new ServerSocket(1234);
Socket socket = serverSocket.accept();
try {

System.out.println("Client connected.");

ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
while(true){
RequestObject receivedObject = (RequestObject) inputStream.readObject();
if (receivedObject.type == 1) {
applicationPublicKey = receivedObject.publicKey;
RequestObject responseObject = new RequestObject();
responseObject.setPublicKey(myPair.getPublic());
outputStream.writeObject(responseObject);
} else if (receivedObject.type == 2) {
String msg = decrypt(receivedObject.getText().getBytes(), myPair.getPrivate());
System.out.println("Encrypted msg: " + receivedObject);
System.out.println("Decrypted msg: " + msg);
}
}
}catch (Exception e){
e.printStackTrace();
}
ServerSocket serverSocket = new ServerSocket(1234);
Socket socket = serverSocket.accept();
try {

System.out.println("Client connected.");

ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
while(true){
RequestObject receivedObject = (RequestObject) inputStream.readObject();
if (receivedObject.type == 1) {
applicationPublicKey = receivedObject.publicKey;
RequestObject responseObject = new RequestObject();
responseObject.setPublicKey(myPair.getPublic());
outputStream.writeObject(responseObject);
} else if (receivedObject.type == 2) {
String msg = decrypt(receivedObject.getText().getBytes(), myPair.getPrivate());
System.out.println("Encrypted msg: " + receivedObject);
System.out.println("Decrypted msg: " + msg);
}
}
}catch (Exception e){
e.printStackTrace();
}
This is a chunk of my Server class, i want the input stream to keep listening to the socket if other requests are called. But it keeps giving me error with the stacktrace:
java.io.EOFException
at java.base/java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:3244)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1708)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:538)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:496)
at Server.main(Server.java:29)
java.io.EOFException
at java.base/java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:3244)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1708)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:538)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:496)
at Server.main(Server.java:29)
Line 29 in server is :
RequestObject receivedObject = (RequestObject) inputStream.readObject();
RequestObject receivedObject = (RequestObject) inputStream.readObject();
38 replies
JCHJava Community | Help. Code. Learn.
Created by Saeed Muhaisen on 12/21/2022 in #java-help
Weird issue that gets solved with println
No description
17 replies