Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 21 13:44
    spring-projects-issues labeled #31143
  • May 21 13:41
    hpoettker opened #31143
  • May 21 08:23
    oleksandr-skoryi edited #31142
  • May 21 08:19
    spring-projects-issues labeled #31142
  • May 21 08:18
    oleksandr-skoryi opened #31142
  • May 21 07:28
    rodrigoserracoelho commented #14611
  • May 21 06:19
    spring-projects-issues labeled #31141
  • May 21 06:18
    eddumelendez edited #31141
  • May 21 06:14
    eddumelendez opened #31141
  • May 21 06:04
    spring-projects-issues labeled #31140
  • May 21 06:04
    eddumelendez opened #31140
  • May 21 05:39
    spring-projects-issues labeled #31139
  • May 21 05:37
    eddumelendez opened #31139
  • May 21 02:44
    spring-projects-issues labeled #31138
  • May 21 02:44
    leshalv opened #31138
  • May 20 21:08
    philwebb commented #31133
  • May 20 20:20
    rodrigoserracoelho commented #14611
  • May 20 19:50
    wilkinsona unlabeled #31134
  • May 20 19:50
    wilkinsona labeled #31134
  • May 20 19:50
    wilkinsona unlabeled #31134
Raúl Pampliega Mayoral
@RaulPampliegaMayoral
image.png
it seems that is loading first the file config and then the classpath one. What i want to do is to load the classpath config first and then the other one (beacuse maybe i want to override some config)
Attoumane
@akuma8

Hi booters,
I have a strange behavior with properties overriding in application.yml during a @SpringBootTest test.
In application.yml I defined a:

spring:
  task:
    execution:
      pool:
        core-size: 30  
        max-size: 60

And in application-test.yml:

spring:
  task:
    execution:
      pool:
        core-size: 1
        max-size: 1
      thread-name-prefix: "test-task"

My test class:

@SpringBootTest
@SpringIntegrationTest
@ActiveProfiles("test")
class TestClass {
     ....
}

I noticed that all background threads from ThreadPoolTaskExecutor are prefixed with task- and there are multiple threads not only one.
I had to define this one:

@TestConfiguration
static class TestConfig implements BeanPostProcessor {

        @Bean
        public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
            ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
            taskExecutor.setMaxPoolSize(1);
            taskExecutor.setCorePoolSize(1);
            taskExecutor.setThreadNamePrefix("test-task");
            return taskExecutor;
        }
}

to override the one provided by default.
I noticed that strange behavior when I added this BeanFactoryPostProcessor bean in my application:

   @Bean // note that I depend on ThreadPoolTaskExecutor here 
    public static BeanFactoryPostProcessor channelsBeanRegistration(ThreadPoolTaskExecutor threadPoolTaskExecutor) {

       return (ConfigurableListableBeanFactory beanFactory) ->  {
            DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;

           CHANNEL_NAMES.forEach(channelName -> {
                if (channelName.equals(ERROR_CHANNEL)) {
                    defaultListableBeanFactory.removeBeanDefinition(ERROR_CHANNEL);
                }
                BeanDefinition beanDefinition = new RootBeanDefinition(PublishSubscribeChannel.class,
                        () -> new PublishSubscribeChannel(threadPoolTaskExecutor));
                defaultListableBeanFactory.registerBeanDefinition(channelName, beanDefinition);
            });
        };
    }

Am I doing something wrong?
Thanks

3 replies
Ludovic Bertin
@neoludo
Hi, I'd like to test that Spring context initialization fails in a certain situation... HOW can I achieve that ? I've tried without success TestExecutionListener...
3 replies
vyshnavi-adusumelli
@vyshnavi-adusumelli
Hi All, I am not able to get any metrics after the spring boot version upgrade from 2.3.3.RELEASE to 2.5.13.
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.5.13</version>
      </dependency>
      <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-core</artifactId>
        <version>1.8.5</version>
      </dependency>
      <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-graphite</artifactId>
        <version>1.8.5</version>
      </dependency>
      <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
        <version>1.8.5</version>
      </dependency>
      <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-jmx</artifactId>
        <version>1.8.5</version>
      </dependency>
1 reply
Dave
@DaveBP_gitlab

HI all :)
I don't know if this is the correct place for a question like this. But I'm more or less a spring-newbie
After several toxic coder-threads, I'll try it here.

Just to be safe—is this an area for coding-questions?

1 reply
Damien
@chomatdam
Hi everyone,
I have a question about how to enforce a logging standard coming from a library (overriding the default log back Spring configuration) but "back off" if the library's user is specifying one.
We can see on this gist (StackOverflow link included in the gist) someone with the same requirements with a detailed comment on why he approached it that way: https://gist.github.com/cykl/c052a3f9c64d58a56e383319be2a8d52
What would be the recommendation from the Spring team?
Dave
@DaveBP_gitlab

Okay, THank you @wilkinsona

Okay, following problem:
I have a more or less stand-alone software which works as a service (more or less a discord bot, but doesn't matter here)
I implemented the JPA stuff in my project.
Long story short.
All works fine.
Table will create in my database
Spring starts - all works fine....
But if I try to save something via saveSurvey.save() I'll get a nullPointerException.
The service is autowired - it works fine
The repository is null - autowired does not work.

Does someone have an Idea why?
Sorry.. Maybe it's a config issue. Have no idea and tried several things i read in several blogs / forums.

Here code snippets:

I added following before my Main

@SpringBootApplication

I added following in my main:

ConfigurableApplicationContext context = SpringApplication.run(Runner.class, args);

I have a separate config class:

@Configuration
@EntityScan(basePackages = {"de.devngs.jeeves.database.mysql.entity"} )
@EnableJpaRepositories(basePackages = {"de.devngs.jeeves.database.mysql.repository"})
public class MySqlConfig {
}

my Service

public interface SurveyService {
    List<Survey> findAll();
    Optional<Survey> findSurveyById(UUID id);
    Survey saveSurvey(Survey survey);
    void deleteSurveyById(UUID id);
    void deleteSurvey(Survey Survey);
}

my Service impl

@Service
public class SurveyServiceImpl implements SurveyService {

    @Autowired
    private SurveyRepository surveyRepository;

    @Override
    public List<Survey> findAll() {
        return surveyRepository.findAll();
    }

    @Override
    public Optional<Survey> findSurveyById(UUID id) {
        return surveyRepository.findSurveyById(id);
    }

    @Override
    public Survey saveSurvey(Survey survey) {
        surveyRepository.save(survey);
        return survey;
    }

    @Override
    public void deleteSurveyById(UUID id) {
        Optional<Survey> survey = surveyRepository.findSurveyById(id);
        survey.ifPresent(value -> surveyRepository.delete(value));
    }

    @Override
    public void deleteSurvey(Survey Survey) {
        surveyRepository.delete(Survey);
    }
}

My repo

@Repository
public interface SurveyRepository extends JpaRepository<Survey, String> {
    Optional<Survey> findSurveyById(UUID id);
}

my entity

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Entity(name = "survey")
@Table(name = "survey")
public class Survey {
    @Id
    @Type(type = "uuid-char")
    @Column(name = "id", updatable = false, nullable = false, length = 36)
    private UUID id;
    private String survey;
    private String options;

    public Survey(String survey, String options){
        this.id = UUID.randomUUID();
        this.survey = survey;
        this.options = options;
    }
}

my Config

spring:
  jpa:
    properties:
      hibernate:
        show_sql: false
        use_sql_comments: true
    open-in-view: true
    hibernate:
      ddl-auto: "update"
    database-platform: "org.hibernate.dialect.MySQL5Dialect"
  datasource:
    url: "jdbc:mysql://localhost:3306/jeeves"
    driver-class-name: "com.mysql.cj.jdbc.Driver"
    username: "..."
    password: "..."
11 replies
Dave
@DaveBP_gitlab
grafik.png
grafik.png
@jnizet
The autowired repository is null.
Tried to remove the "@Autowired" Service and replace it with a new instance of ServiceImpl
But the repository within the serviceImpl is still empty
Andreas Höhmann
@ahoehma
hello guys, please help me to understand "gracefull-shutdown" ... when I start my springboot app in eclipse via "boot dashboard" I have to enable "jmx" to see gracefull-shutdown "in action" 1. start 2. stop ... then the app shows "Commencing graceful shutdown. Waiting for active requests to complete", also other beans like "springboot-admin" show me that scenario "org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar$SpringApplicationAdmin:159 - Application shutdown requested." ... also my own code can react to "ContextClosedEvent event" ... everything is fine ... BUT :D ... when I run my app without jmx enabled the dashboard stop shutdown the app immediately ... "server.shutdown: graceful" is just ignored. The same effect that gracefull shutdown is not really working or seems so ... I have in AWS beanstalk environment. How can I enable the support to gracefull-shutdown when I start my app with simply "java -jar" from cmdline ... how can I simulate that "SIGTERM" under windows. Or is there something more to know here? What have JMX to do with that. kind regards.
1 reply
hubertlapsa
@hubertlapsa
Hi everyone, I have problem with ouath2 client in spring application. As I can see, migration from deprecated client require WebClient: https://github.com/spring-projects/spring-security/wiki/OAuth-2.0-Migration-Guide. Is there any way to handle request and response for logging? I tried to use Jetty Http Client but it doesn't include support for setting read and write timeout. i tried to use too Netty Http Client, but but I did not find an option to log request and response. Is there any other way to log request and response using webclient with support for read and write connection timeout?
4javier
@4javier

When setting up multiple datasources I encounter the common

Parameter 0 of method productsEntityManagerFactory in petmenu.config.ProductsDataSourceConfiguration required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.

I know it's solved marking one of the DataSource methods as @Primary, but I cannot understand why.
I'd expect that one to be a solution for conflict of multiple wiring candidate beans, not for the lack of one.
Moreover, considering that the same EntityManagerFactoryBuilder, that looks like generated somehow from the @Primary annotated datasource, is used for the rest of the datasources' configuration too, how can this not be a problem?
If the builder is not actually bound to a single DataSource, why it's not provided by SpringBoot as default?

7 replies
Martin Bonnin
@martinbonnin
Is there an example of a spring native project that adds all classes with a given annotation as reflection roots?
1 reply
Michal Domagala
@michaldo
Why "Static imports should not be used in production code" ?
4 replies
Pietro Galassi
@pietrogalassi
It seems that SpringBoot have closed context but not called any of the shutdown-hook. Thet after like 30 seconds a new context has been created. Any idea on how it that possible ?
Pietro Galassi
@pietrogalassi
Those 3 lines of log shows that there is a 30sec blackout and the context restarts:
2022-05-10 15:18:16,561 INFO - org.apache.kafka.clients.consumer.internals.AbstractCoordinator - HOST:algo-calculator-24-n7mjk - TN: - api: - messageKey: - [Consumer clientId=consumer-11, groupId=algo-calculator] (Re-)joining group
2022-05-10 15:18:49,991 INFO - org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - HOST:algo-calculator-24-n7mjk - TN: - api: - messageKey: - Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfigurationEnhancerBySpringCGLIBEnhancerBySpringCGLIB587eb2b5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-05-10 15:18:51,324 INFO - org.springframework.boot.SpringApplication - HOST:algo-calculator-24-n7mjk - TN: - api: - messageKey: - No active profile set, falling back to default profiles: default
7 replies
Tyler Reid
@twreid
When using Webclient Reactive. I am trying to add a generic filter to do an onErrorMap(Exception.class, handleErrorHere) in a filter, but right after the bodyToMono call on the client I want to specifically handle a 404 and do something specific for each client instead of global and generic like in the filter so I was curious what order the onError chain would be called? Specifically wanting to know if I do that catch all in the filter will it happen before my specific 404 one after bodyToMono
AlexandraNp
@AlexandraNp

Please allow me this noob question. Why doesn't this Spel work if fooBean2 doesn't exist ?

@Bean
public Foo foo( @Value("#{fooBean2 ?: fooBean1}") Foo foo ) {
    return new Bar(foo);
}

I'm getting :

org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'fooBean2' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?

1 reply
James Howe
@OrangeDog
HibernateJpaDialect has setJdbcExceptionTranslator - how do you supply something for that with Boot config?
James Howe
@OrangeDog
Unlike JdbcTemplates, which init one from their DataSource if not set, it's always null
James Howe
@OrangeDog
This is the best way I can find so far...
@Autowired
void configureJpaExceptionTranslator(LocalEntityManagerFactoryBean bean) {
    JpaDialect dialect = Objects.requireNonNull(bean.getJpaVendorAdapter()).getJpaDialect();
    if (dialect instanceof HibernateJpaDialect) {
        SQLExceptionTranslator translator = new SQLErrorCodeSQLExceptionTranslator(bean.getDataSource());
        ((HibernateJpaDialect) dialect).setJdbcExceptionTranslator(translator);
    }
}
Andy Wilkinson
@wilkinsona
@OrangeDog You can define your own HibernateJpaVendorAdapter bean and customize its HibernateJpaDialect
DoraRajappan
@DoraRajappan
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.trgr.cobalt.dataroom.datatransfer.config.DataTransferBeanConfiguration]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'nameStringTokenizerImpl' for bean class [com.trgr.cobalt.dataroom.cache.common.NameStringTokenizerImpl] conflicts with existing, non-compatible bean definition of same name and class [com.trgr.cobalt.dataroom.contacts.name.NameStringTokenizerImpl]
15 replies
Packages are different still its conflicts
Knut Schleßelmann
@kschlesselmann
Hi! Currently we try to traverse an API which gives us next links to further result pages. If you simply feed this URI to WebClient it's generating a lot of metric dimensions since this URI is no template. Any suggestions how we should handle such cases?
9 replies
Lovro Pandžić
@lpandzic
Hello,
question regarding relation between spring boot and spring cloud projects - are releases coordinated?
I'm trying to prepare teams in my company to be ready to upgrade to 2.7.0 when it's out and one feedback I got is that Spring Cloud usually doesn't work with latest release of Spring Boot and that there's a delay in support - I wanted to check is this true and can something be done about it?
2 replies
Lars Grefer
@larsgrefer
Hi everyone,
I stumbled upon a problem, while migrating a legacy spring web application to spring boot.
I'm trying to use an embedded tomcat with war layout and want to just @ImportResource("WEB-INF/applicationContext.xml") the old spring config on my @SpringBootApplication main class.
But WEB-INF/applicationContext.xml is resolved as classpath resource (and therefore not found) instead of beeing resovled as servlet context resource.
The "problem" seems to be in org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext#getResourceByPath. The call to getServletContext() there returns null, when the resource is resolved. Do you have an idea on how to get this working?
5 replies
aditya parikh
@adityaparikh_twitter
Is this the right channel to ask questions about Spring GraphQl?
I have
.contextWrite(ctx -> ctx.put(ApplicationConstants.TenantKey, tenantKey));
in the root object call.
and that gets correctly populated when I pass @Argument String tenantKey as a parameter of the method annotated with @QueryMapping.
How do I propagate ReactorContext to the nested object fetcher?
The one annotated with @SchemaMapping
DoraRajappan
@DoraRajappan
Can we have both application-context.xml and @Configuration class in same web application? If application-context is mentioned in web.xml and if we still have @Configuration class in same web application will both be exeuted at deployment? If so has the execution got a precedence order?
6 replies
DoraRajappan
@DoraRajappan
Seems most web application have both @Configuration class and an application-context having <context:component-scan/>
Unless we add @ComponentScan with @Configuration in configuration class duplicate beans dont arise.
DoraRajappan
@DoraRajappan
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.store.bulk.config.DataRoomStoreBulkBeanConfiguration': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.common.config.DataRoomCommonWebConfiguration': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataRoomRequestMappingHandlerAdapter': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.web.DataRoomSourceAuthenticationWebArgumentResolver': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProvider': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenService': After spring hibernate upgrade to 5.x getting the exception ....Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenServiceSecureToken': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.token.securetoken.SecureTokenServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfileServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfilePersistorImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfileRepositoryImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalSessionFactory' defined in com.trgr.cobalt.dataroom.datasource.config.global.GlobalDataSourceConfiguration: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister
DoraRajappan
@DoraRajappan
After spring hibernate upgrade to 5.x getting the above exception
DoraRajappan
@DoraRajappan
But globalSessionFactory gets injected perfectly fine from another web application using same dependency of dataroom.datasource
So its a configuration problem of the store bulk web application after spring hibernate upgrade
Andy Wilkinson
@wilkinsona
@DoraRajappan Please respect the purpose of this room. It's specifically for Spring Boot users. To be considerate of the 10k people who are here, please keep your questions on topic. As I said above, if you have a pure Spring Framework question, Stack Overflow is the best place to ask.
DoraRajappan
@DoraRajappan
Sure...thanks!...👍
Sushant Parkhi
@sushantparkhi

Hi, I am currently trying to make ECDSA related ciphers to work with TLS 1.2 in Spring Cloud Gateway (Spring Boot Parent 2.6.7 and Spring Cloud 2021.0.2). Here's the snippet of WebServerFactoryCustomizer

    @Bean
    public WebServerFactoryCustomizer<NettyReactiveWebServerFactory> customizer() {
        return factory -> factory.addServerCustomizers(httpServer -> httpServer.secure(sslContextSpec -> {
            try {
                Ssl ssl = factory.getSsl();
                KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
                char[] keyStorePassword = ssl.getKeyStorePassword().toCharArray();
                keyStore.load(resourceLoader.getResource(ssl.getKeyStore()).getInputStream(), keyStorePassword);
                KeyManagerFactory keyManagerFactory = OpenSslCachingX509KeyManagerFactory
                        .getInstance(KeyManagerFactory.getDefaultAlgorithm());
                keyManagerFactory.init(keyStore, keyStorePassword);
                Http11SslContextSpec http11SslContextSpec = Http11SslContextSpec.forServer(keyManagerFactory)
                        .configure(sslContextBuilder -> {
                            sslContextBuilder.sslProvider(SslProvider.OPENSSL);
                            sslContextBuilder.ciphers(Arrays.asList(ssl.getCiphers()));
                            sslContextBuilder.protocols(ssl.getEnabledProtocols());
                            sslContextBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
                            sslContextBuilder.clientAuth(ClientAuth.REQUIRE);
                        });
                sslContextSpec.sslContext(http11SslContextSpec)
                        .handlerConfigurator(sslHandler -> {
                            sslHandler.setCloseNotifyReadTimeout(18000, TimeUnit.MILLISECONDS);
                            sslHandler.setHandshakeTimeout(19000, TimeUnit.MILLISECONDS);
                            SSLParameters sslParameters = sslHandler.engine().getSSLParameters();
                            sslParameters.setUseCipherSuitesOrder(false);
                            sslHandler.engine().setSSLParameters(sslParameters);
                        });
            } catch (UnrecoverableKeyException | IOException | CertificateException | KeyStoreException |
                     NoSuchAlgorithmException e) {
                throw new RuntimeException(e);
            }
        }));
    }

But when I try to connect using openssl s_client with ECDHE-ECDSA-AES128-GCM-SHA256 cipher the server returns an error with no shared ciphers, but I do have it in the configuration as

server.ssl.ciphers=TLS_RSA_WITH_AES_128_GCM_SHA256,\
  TLS_RSA_WITH_AES_256_GCM_SHA384, \
  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,\
  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,\
  TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
server.ssl.enabled-protocols=TLSv1.2

This behavior was observed when I upgraded versions from Spring Boot 2.3.3.RELEASE and Spring Cloud Hoxton.SR7. Any advice/suggestions would be of great help on fixing or correctly configuring it.

2 replies
sarowar
@eipi1
Is there any properties equivalent to server.tomcat.accept-count or server.tomcat.max-connections for netty/webflux?
I've got a web flux REST API that's accepting more requests than it can process and falling into cascading delay/failure. I'm hoping setting a limit to accept queue & max-connection will solve the problem.
Thanks in advance.
2 replies
DoraRajappan
@DoraRajappan

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.store.bulk.config.DataRoomStoreBulkBeanConfiguration': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.common.config.DataRoomCommonWebConfiguration': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataRoomRequestMappingHandlerAdapter': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.web.DataRoomSourceAuthenticationWebArgumentResolver': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProvider': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenService': After spring hibernate upgrade to 5.x getting the exception ....Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenServiceSecureToken': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.token.securetoken.SecureTokenServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfileServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfilePersistorImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.trgr.cobalt.dataroom.authentication.securetoken.profile.SecureTokenProfileRepositoryImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalSessionFactory' defined in com.trgr.cobalt.dataroom.datasource.config.global.GlobalDataSourceConfiguration: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.SingleTableEntityPersister

@Convertor (javax.persistence) with autoapply true was present in one dependency jar... made it false and @Version started working in web app with hibernate 5.4...

:)
hubertlapsa
@hubertlapsa
Hi everyone, I introduce integration with oauth2.0 in my application using newest solution in Spring: https://github.com/spring-projects/spring-security/wiki/OAuth-2.0-Migration-Guide. Therefore I have a question if it is possible to set a timeout for token? I wants to avoid a situation where I will have to wait for a token for a long time. In the old approach it was possible to solve through ClientHttpRequestFactory: https://stackoverflow.com/questions/54085582/how-to-set-connection-timeout-with-oauth2resttemplate-while-fetching-access-toke/56608956#56608956. Currently, I do not see such a possibility using the latest solution.
1 reply
Ciaran McKenna
@ciaranmckenna
Hi guys, I have a question/point of discussion regarding the creation of interfaces for services associated with a Pet Clinic project I am working on.
I may be wrong and if I am please say. But, I thought it was better to have the service layer within the repository pattern handle logic and allow a repository interface to access the db?
In this way, there would be a separation of concerns, no violation of the Single Class Responsibility principle and more modular code?
Should the service class not be a service class instead of an interface?
Looking forward to a response, thanks guys.
jacknoob45
@jacknoob45

Hello guys, may I ask can we stop executing the rest of the validations after the first validation is failed?

    @NotBlank(message ="Username is required") //Stop here if the username is empty.
    @Size(min = 6, max = 15, message = "Username must be more than 5 characters and less than 16")
    @Pattern.List({
            @Pattern(regexp = "^\\S*$", message = "Username cannot contain any whitespaces and special characters"),
            @Pattern(regexp = "^[A-Za-z0-9 ]+$", message = "Username cannot contain any whitespaces and special characters")
    })
    public String username;

If the username is empty, then the expected output should be "Username is required"

public ResponseEntity<String> AddNewUser(@Validated @RequestBody AddUsersEntityDTO addUsersEntityDTO, BindingResult bindingResult) throws Exception{

        if(bindingResult.hasErrors()){
            List<ObjectError> list = bindingResult.getAllErrors();
            for(ObjectError objectError : list){
                System.out.println(objectError.getCode()+" - "+objectError.getDefaultMessage());
            }
        }

    }

But my current output is displaying all the validation like this

Size - Username must be more than 5 characters and less than 16
Pattern - Username cannot contain any whitespaces and special characters
NotBlank - Username is required

1 reply
Michael Legart
@legart
Good morning :) Is it just me or is 2.6.8 and 2.7.0 missing from https://search.maven.org/artifact/org.springframework.boot/spring-boot-buildpack-platform ?
4 replies
marekdominiak
@marekdominiak

Hey,

I have a problem with the date format in Spring Boot 2.6.3, with spring-hateoas (1.4.1).

I have the code:

@Date
@EqualsAndHashCode (callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@ApiModel (description = "Contains information about a license that is either single course license or portfolio lives")
public class LicenseResource extends RepresentationModel <LicenceResource> {

// @JsonFormat (pattern = "yyyy-MM-dd")
     private LocalDate startDate;
....
}

and the date format after sending this to the client is array [2011,1,1] instead of "2011-01-01".
Before the upgrade from Spring Boot 2.x.x but without Hateoas (with old Resource support) it worked as expected.

I have tried to use:
spring.jackson.date-format = yyyy-MM-dd
and
spring.mvc.format.date = yyyy-MM-dd

But none of the above works. I have tried to scan for related GitHub issues but haven't found any recent.
Only using
@JsonFormat (pattern = "yyyy-MM-dd")
on a specific field, but it's a bit too much work.

Or maybe someone has encountered such a problem? How did you setup defaults?

wagnerdk
@wagnerdk
Hello, is there a guide or wiki on how to migrate a normal java app (no http interface) to spring boot to add an http interface and profit of the capabilities of the framework?