Java Community | Help. Code. Learn.

JCH

Java Community | Help. Code. Learn.

With more than 20,000 members, join one of the biggest and most active Java Communities on Discord! ☕

Join

java-help

❓︱qotw-answers

Drawing SVG paths in javafx css

any idea why is it still filled? it shouldnt be according to the rendered svg
No description

Exception Handling in Spring

Hey i am getting 500 response code instead of 404 even after handling the exception ```package com.ShelfSpace.ShelfSpace.exception; public class ResourceNotFoundException extends RuntimeException {...

RequestParam / User Not Found

Hello again guys, I'd like to render my data user on a template with the GET method. I made sure my page was created and my datas are persisted in my db. I tried to render my data through the email user as it's shown below and I want my URL to be like this : http://localhost:8080/[email protected] ( which works perfectly if I write this in my browser bar ) but when I want to access to my profile it return me a USer nto found, because Spring boot sees it as null...

Suggest kotlin/java backend framework

I tried ktor, but its documentation is... too difficult I didnt found how to set up cookies, auto documentation and stuff Or im just too dumb for it 😦...

Why/how is displayMap null

I have a class here and it seems like nothing in the constructor is running except the super() call. None of the prints run and when repaint is called it throws an error for displayMap being null. What is wrong?

Issue with multimodule project

I'm trying to publish my project to maven central, but I get this error. ``` Execution failed for task ':api:publishMavenPublicationToMavenCentralRepository'.
Failed to publish publication 'maven' to repository 'mavenCentral' Invalid publication 'maven': multiple artifacts with the identical extension and classifier ('jar', 'javadoc')....

Render dynamic dayas / Status 400

Hello guys, I'm trying to render dynamically my datas from my entity ( the datas are well persisted, there's no problem in the database side ) with thymeleaf an user page once he's authenticated but I have the famous
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jul 24 16:43:43 CEST 2024
There was an unexpected error (type=Bad Request, status=400).
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jul 24 16:43:43 CEST 2024
There was an unexpected error (type=Bad Request, status=400).
...

best way to insert JSON object into DB table?

hey guys. i want to construct a json in my java code and insert it into a DB table. can i just use json in a string and replace needed values?

how to check if record exists in DB table?

hey guys. can smb help me out? in my repo class i have this:
@Query(value = "select count(1) from my_tablewhere transaction_id= :transactionId",nativeQuery = true)
boolean existsByTransactionId(@Param("transactionId") String transactionId);
@Query(value = "select count(1) from my_tablewhere transaction_id= :transactionId",nativeQuery = true)
boolean existsByTransactionId(@Param("transactionId") String transactionId);
...

service deletes DB records, but i still get `No results were returned by the query`

hey guys. can smb help me out? i have this service: ```java public void createPaymentpaymentReversal(PaymentDTO paymentReversalRequest) throws NoEarlierPaymentException { Optional<Payment> earlierPayment=paymentRepository.findByTransactionId(paymentReversalRequest.getTransactionId()); ...

apache Mina sshd

If anyone had expierence with Apache Mina and setting up a ssh server please tell me. I got an issue where my client session are mixxed up if there’s more than 1 of them… (the 2nd user becomes the first) Tell me guys I am tired of posting the code...

How do I use UserDetailsService properly? Where do I define it exactly?

I was going through spring security's docs and found this ```java @Configuration @EnableWebSecurity...

Spring app doesn't read environmental variables from .env

I have .env file in my project root folder along with pom.xml. Contents: ``` APP_PASSWORD=my-app-password DATABASE_PASSWORD=Tomasm21-xi DATABASE_USERNAME=Tomasm21...

RestApi Access Problem

When i try to access the Rest Api from postman then i got the html of login i even permit the enpoint of api ```@RestController @RequestMapping("/api/Student") @CrossOrigin(origins = "http://localhost:3000") public class RestApplication { ...

Spring Boot Security / Request = 500

Hello guys, I'm a beginner here who's trying Spring Boot security. I'm trying to sign in with the httpSecurity but when I do my sign-in request, SPring boot redirects me to the famous ```Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback....

why use Optional<MyClass> if you cant call any methods that MyClass has?

hey guys. can smb explain to me what wrong? im trying to retrieve an object from DB: Optional<Payment> earlierPayment=paymentRepository.findByTransactionIdAndAmount(paymentConfirmationRequest.getTransactionId(), paymentConfirmationRequest.getAmount());. and for some reason i cant call any getters that my Payment entity has. does it mean that id need to change the return type of findByTransactionIdAndAmount from Optional<Payment> to just Payment? and then id loose the advantage Optional gives me. that doesnt make any sense 😦 any help? thanks...

how to convert long to int

hi fellas. i was wondering i you could help me. in postgre db i have a field order_time. its data type is int4. there are a couple of records, where order_time is 1536936174. so i have a couple of questions: 1. i was wondering how to set this field value, when im doing insert in my Java code? 2. why the date is stored in a column that has datatype of int4? why not date or datetime? 3. in java code i see that my entity is private Long orderTime, so does that mean theres a mistake in the code and i need to use Long in the database too? or do i use int in my Java code? ...

Mocking fails for some reason

```java @SpringBootTest @TestPropertySource(locations = "classpath:application-test.properties") @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) class UserServiceTests {...

dependency isnt injected into my service

hey guys. can smb help me out. i have a service ```java @Service @Slf4j public class MyService {...

Failing test under misterious circumstances

https://github.com/KoblizekXD/notecz-backend/blob/4a70434b5c139b2d6bf5c6953fbf49a92cebded5/src/test/java/lol/koblizek/notecz/api/user/UserServiceTests.java#L49 this test seems to be failing, altough when i try to run UserRepositoryTests and test the validation, it correctly throws an exception, but here the saveAndFlush just returns null......