I am getting below error after updating spring-boot starter parent to 2.4.3. But after setting up server.servlet.register-default-servlet=true application is working as expected. But one i would like to know is, in the reference spring documentation >Spring Boot 2.4 will no longer register the DefaultServlet provided by your servlet container. In most applications, it isn’t used since the Spring MVC’s DispatcherServlet is the only servlet that’s required.
So do i missing anything as my application is not considering DispatcherServlet as default one
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalStateException: Unable to locate the default servlet for serving static content. Please set the 'defaultServletName' property explicitly.
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
Related
Error creating bean with name 'rqueueConfig' defined in class path resource [com/github/sonus21/rqueue/spring/boot/RqueueListenerAutoConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.sonus21.rqueue.config.RqueueConfig]: Factory method 'rqueueConfig' threw exception; nested exception is java.lang.UnsupportedOperationException: Scripting commands not supported in pipelining/transaction mode
Followed steps mentioned on the website, https://github.com/sonus21/rqueue
There, it was mnentioned #EnableRqueue annotation, but it gave me a error, that it cannot find the annotation.
I am using JAVA 11 and spring boot framework.
OK - problem ==> 2 Datasources (or more) will cause an error when using Springboot Session.
I have a Springboot project, with different data sources for different purposes. So within said project I would like to have Spring replace the HttpSession, with the Spring-Session module's HttpSession.
The creation of the session tables is simple if you follow the guides.
But the guides and API docs say you need JUST one data source. And so, since I have 2 or more I get the following error:
2020-07-21 21:38:59.134 ERROR 171262 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter :
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException.
Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource
[org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]:
Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type 'javax.sql.DataSource' available:
expected single matching bean but found 2: authModelDs,secureSessionDS
So since it cannot decide which one to use, I have to manually configure it, except that the entire process leads you to a class called
org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration, which is quite literally non-configurable under the given need to set your own datasource.
I have looked a bit around, and there is no way to configure the Session Filter, once it is created to replace the datasource there too.
So I am boggled: how can I set the correct datasource for the configured Spring-Session?
Any help would be appreciated.
AHA! Soooooo
There is an annotation that you can place on the Bean creation of your datasource, to specify that such a bean is the SpringBoot session datasource.
The annotation is - #SpringSessionDataSource
It is not something that is really straight forward in the documentation at all!
Props to the following Stack Overflow answer:
Spring Boot and Spring Session: How to control the DataSource
I am working on a spring boot web application with security features. I am relying on a library with a custom Cors Filter that I need to use but my application keeps picking the Spring Web Framework Cors Filter instead and renders the following error:
[ERROR] Failed to execute goal
org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:run
(default-cli) on project tools-services: An exception occurred while
running. null: InvocationTargetException: Error creating bean with
name 'springSecurityFilterChain' defined in class path resource
[org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [javax.servlet.Filter]: Factory method
'springSecurityFilterChain' threw exception; nested exception is
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean
named 'corsFilter' is expected to be of type
'org.springframework.web.filter.CorsFilter' but was actually of type
'com.myproj.sample.inf.sec.filter.CorsFilter' -> [Help 1]
I am trying to create a CorsFilter bean in my Application.java class as such:
#Bean
public CorsFilter corsFilter() {
return new CorsFilter();
}
However, this gives me the same error. Is there a way to make Spring Boot point to the custom cors filter or disable the spring cors filter?
Probably is because of the same name. Can you try to change bean name used in your Application.java?
We are creating a new Spring Boot project and a part of it needs multi-threading operation. We are trying to use the ManagedExecutorService, so we declared it as follows:
#Resource(name="java:comp/DefaultManagedExecutorService")
private ManagedExecutorService mes;
And during execution returned the error:
Injection of resource dependencies failed; nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException:
Invalid bean definition with name 'java:comp/DefaultManagedExecutorService' defined in JNDI environment: JNDI lookup failed; nested exception is
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
Does this means that Spring Boot does not support/allow us to use the ManagedExecutorService in tomcat?
I have the OAuth 2 configuration working properly, and I'm currently in the process of enabling Web UI as well. Since the configuration involves Web security, I already have part of it set up. Actually, my understanding is that I don't really have much more to add anymore, other than the MVC components (like the login page, URL mappings, etc.) However, I'm having trouble logging into the Web app since the user is being tagged as anonymousUser.
Both WebSecurityConfigurerAdapter and ResourceServerConfigurerAdapter define method configure(HttpSecurity). Currently, I'm using the one defined in ResourceServerConfigurerAdapter but that's where I'm experiencing the User being tagged as anonymous. If I try using the one in WebSecurityConfigurerAdapter (with OAuth 2 currently configured), I get the following error message:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Cannot apply org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer#546ed2a0 to already built object
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
...
Caused by:
Caused by: java.lang.IllegalStateException: Cannot apply org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer#546ed2a0 to already built object
at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.add(AbstractConfiguredSecurityBuilder.java:196) ~[spring-security-config-4.1.3.RELEASE.jar:4.1.3.RELEASE]
...
However, when I disable everything related to the OAuth 2, and only use WebSecurityConfigurerAdapter (with HttpSecurity set up), login via the Web UI works as expected (i.e. user is not tagged as anonymous). I'm not sure what key area I got wrong on this.