Skip to main content

Posts

Showing posts with the label Spring Boot

Factory method 'filterChain' threw exception with message: This object has already been built

  Problem org.springframework.beans.factory.UnsatisfiedDependencyException : Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChains' parameter 0: Error creating bean with name 'filterChain' defined in class path resource [com/.class]: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'filterChain' threw exception with message: This object has already been built at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments( AutowiredAnnotationBeanPostProcessor.java:817 ) ~[spring-beans-6.0.4.jar:6.0.4] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject( AutowiredAnnotationBeanPostProcessor.java:769 ) ~[spring-beans-6.0.4.jar:6.0.4] at org.spri

Spring Boot Maven plugin - How to deploy WAR to an external tomcat's webapp folder?

 Introduction Spring Boot Maven plugin by default generates the WAR file inside the target folder. In this post, I will explain how to copy the generated war file to an external Tomcat's webapps folder using Spring Boot Maven plugin. In my earliest post , you can learn how to package a Spring Boot application as WAR.  Solution Step 1  Follow this link to specify the packaging as WAR in pom.xml and also to configure the  SpringBootServletInitializer class Step 2 (optional) Specify a cleaner name for WAR using the finalName tag in pom.xml  <finalName>auth</finalName> Step 3 Specify the outputDirectory directory      <build> <finalname>auth</finalname> <plugins> <plugin>           <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> <configuration>           <outputdirectory>D:/Development Utils/apache-tomcat-9.0.30/webapps</outputdirectory>

Spring RestTemplate - How to skip SSL certificates validation?

In this tutorial, we will explore to consume restful web services hosted on https URL with SSL certificates. We will use Sprint RestTemplate to consume the restful web services. It is very easy to consume the web services hosted on HTTP protocol. Challange is consuming the web services hosted on HTTPS with SSL certificates enabled. I encountered the following exception when accessing SSL hosted web services Caused by: javax.net.ssl.SSLHandshakeException:        sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target  at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917) We will use  SSLContext to skip SSL validation. What is SSL Context? SSL Context is a collection of ciphers, trusted certificates, TLS extensions and options, and protocol versions. It acts as a factory

Spring Boot - How to deploy WAR file to Tomcat or any other external container?

Introduction When we develop Spring Boot application using Maven, the project is by default configured to package the project as JAR with an embedded Tomcat or another container. If we wish to export the project as WAR for deployment on the external container, we will have to change the configuration. Below are the steps to export Spring Boot project as WAR STEP 1 Change the maven.xml, replace the packaging value as provided below <packaging> war </packaging> STEP 2 Extend your main application class file from  SpringBootServletInitializer and override its  configure method as shown below Please leave your feedback in the comments box.