Wednesday, August 16, 2023

502 Bad Gateway


>PROBLEM

Attempt to access the site returns:

502 Bad Gateway


>SOLUTION

Scenario: there is a server interfacing with external requests like Nginx or Apache.

In such cases, the application behind the Nginx, Apache, etc. may have stopped working, returning no answer.

Go to the application's log and check its state.

Make sure that it is responsive.


>ENV

- x -


Tuesday, August 15, 2023

spring: spring boot: ERR_TOO_MANY_REDIRECTS


>PROBLEM


You try to access the site redirects to the default URL and the browser returns:

ERR_TOO_MANY_REDIRECTS




>SOLUTION

Edit your security class configuration that usually extends extends WebSecurityConfigurerAdapter.
Add the URL that fails.

@Configuration

@EnableWebSecurity

public class SpringSecConfig extends WebSecurityConfigurerAdapter {



@Override

protected void configure(HttpSecurity httpSecurity) throws Exception {

httpSecurity.cors().disable();

httpSecurity.headers().frameOptions().disable();

httpSecurity.csrf().disable()

.authorizeRequests()

.antMatchers("/", "THE MISSING URL HERE").permitAll()


//...

}


>ENV

Java
Spring/Spring Boot

java: spring boot: How to search project issues in the stack trace

 

>PROBLEM

The application throws a lot of exceptions and you get confused to understand the cause because there are so many compiler complaints.


>SOLUTION

Follow by the example below.
If you go to the first compiler's complaint, you'll be mislead.

To find the real cause, the one that triggered the others, begin from the bottom to the top of the stack trace (the yellow in the example). 
The issue was caused for a field notation error. On the database the field is denoted by "pass" and not "password". Check the images at the bottom.


2023-08-15 09:37:23 # [restartedMain] # ERROR # o.s.boot.SpringApplication # method: reportFailure # Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appController': Unsatisfied dependency expressed through field 'wsSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wsSvcImpl': Unsatisfied dependency expressed through field 'encryptionSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionSvc': Unsatisfied dependency expressed through field 'securitySvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securitySvc': Unsatisfied dependency expressed through field 'accControlSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accControlSvc': Unsatisfied dependency expressed through field 'accControlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wsSvcImpl': Unsatisfied dependency expressed through field 'encryptionSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionSvc': Unsatisfied dependency expressed through field 'securitySvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securitySvc': Unsatisfied dependency expressed through field 'accControlSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accControlSvc': Unsatisfied dependency expressed through field 'accControlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionSvc': Unsatisfied dependency expressed through field 'securitySvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securitySvc': Unsatisfied dependency expressed through field 'accControlSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accControlSvc': Unsatisfied dependency expressed through field 'accControlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securitySvc': Unsatisfied dependency expressed through field 'accControlSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accControlSvc': Unsatisfied dependency expressed through field 'accControlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accControlSvc': Unsatisfied dependency expressed through field 'accControlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accControlRepository' defined in com.drillback.setget5.model.repository.security.AccControlRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)! Reason: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract com.drillback.setget5.model.repository.security.AccControl com.drillback.setget5.model.repository.security.AccControlRepository.findByEmailAndMsg(java.lang.String,java.lang.String)!

Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: password of: com.drillback.setget5.model.repository.security.AccControl [from com.drillback.setget5.model.repository.security.AccControl ac where ac.email=:email and ac.password=:password]

Caused by: org.hibernate.QueryException: could not resolve property: password of: com.drillback.setget5.model.repository.security.AccControl [from com.drillback.setget5.model.repository.security.AccControl ac where ac.email=:email and ac.password=:password]

Caused by: org.hibernate.QueryException: could not resolve property: password of: com.drillback.setget5.model.repository.security.AccControl








>ENV

Java


eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...