Multiple annotations found at this line: Factory bean not Found - java

I am building a Spring project in Spring Tool Suite(3.6.4.RELEASE).
I am trying to upgrade spring framework version from 4.0.3.RELEASE to 4.2.7.RELEASE using maven.
Before upgradation there was no error and everything running smoothly. Now project is compiling and running without error but login page is not showing and also I am getting error in my spring security configuration xml.
Error in spring-security.xml:
Showing following error on STS hovering:
Multiple annotations found at this line:
- Factory bean 'org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser
$DefaultWebSecurityExpressionHandlerBeanFactory' not found [config set: mcare-dashboard-web/web-context]
- Factory bean 'org.springframework.security.config.http.HttpConfigurationBuilder
$SecurityContextHolderAwareRequestFilterBeanFactory' not found [config set: mcare-dashboard-web/web-context]
Project Hierarchy:
My pom.xml was like following:
Then I just changed the version number like this:
After that spring-security.xml was showing the error.
Can anybody explain why is this happening?

You state that you are upgrading Spring from version 4.0.3.RELEASE to 4.2.7.RELEASE. However effectively you are upgrading both Spring and Spring Security. This due to having a single version property, named org.springframework-version, to manage both the version of the Spring and Spring Security dependencies.
So changing org.springframework-version to 4.2.7.RELEASE effectively upgrades Spring Security as well.
To fix this you want to have two distinct version properties one for Spring and another for Spring Security. You can than upgrade only Spring or Spring Security.

Related

Intellij Spring - Invalid content was found starting with element '{"http://www.springframework.org/schema/context":compnent-scan"}'

I am trying to learn Spring through using the Intellij IDE. I don't understand this error in my pom.xml:
The error message I am getting when I try to add the component-scan context tag
I am trying to add the component-scan context so that Spring can detect beans automatically.
my pom.xml

getting status code as "DOWN" for actuator/health endpoint

I have recently updated my spring-boot project to 2.7.5 from 2.0 version, i got some documentationPluginsBootstrapper related error and swagger did't open.
with this link i have added bean and new property in properties file, than it started workig fine..
Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
i have actuator dependency in my project(i can't remove the dependency) for actuator/health endpoint im getting status code down..
I'm getting like this for working url
{"groups":[],"status":{"code":"DOWN","description":""}}
Need to Add the below on your config file properties/yaml :
management.endpoint.health.show-details=always

ServerSymmetricEngine fails to start

I have an embedded Spring boot app. When I start the server
ServerSymmetricEngine serverEngine = new ServerSymmetricEngine(new File("server.properties"));
It always fails when the following error:
Error creating bean with name 'domainServerExporter' defined in class path resource [symmetric-jmx.xml]: Error setting property values
Invalid property 'registrationBehaviorName' of bean class [org.springframework.jmx.export.MBeanExporter]: Bean property 'registrationBehaviorName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
What could be the issue? I have an embedded Tomcat (In spring boot), why should I expose the jmx config?
Version 3.5 of SymmetricDS depends on Spring 3.1.2, so make sure your dependencies are correct. But, those are old versions and no longer supported.
Instead, I recommend using the latest version of SymmetricDS. The project switched Maven repositories a while back, so maybe you're just picking up old versions from Maven central. Here is the current Maven repository for SymmetricDS:
http://maven.jumpmind.com/repo/

Spring boot embedded Kafka integration throws NoClassDefFoundError

Spring Boot: 2.0.3.RELEASE
org.apache.kafka.kafka-streams: 1.0.0
org.apache.kafka.kafka-clients: 1.0.0
org.springframwork.kafka:spring-kafka-test:2.1.7.RELEASE
I have a working Spring boot application with Kafka. I am trying to follow https://blog.mimacom.com/testing-apache-kafka-with-spring-boot/ to create an integration test.
When I add the #EmbeddedKafka annotation I get the error when I run
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaEmbedded': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/kafka/common/record/RecordFormat
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:407) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
There are a few google results on this error however they are all on old kafka-client versions and they should be fixed in the version I use.
This looks like a version mismatch but it is not clear to me what I am supposed to me.
As indicated in comments errors like these are always due to library version incompatibilities. The following combination worked
spring boot: 2.1
spring-streams/spring-client: 2.0.1 (Using 2.2.0 creates some compatibility issues)
spring-kafka: 2.2.5.RELEASE

Spring Web Reactive not working as war file deployed on Tomcat 8.5

I have Spring Boot (2.0.0 M5) application which provides some REST API. I'd like to implement this API using RouterFunctions.
While I'm running app using embedded Jetty everything works fine.
When I convert the app to WAR file (following documentation here) and deploy it to Tomcat 8.5 I always get 404 when trying to call any of the endpoints.
I can see in the log that endpoints are recognised:
[ost-startStop-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/say-hello],methods=[GET]}" onto java.lang.String com.example.demo.DemoController.test()
[ost-startStop-1] o.s.w.r.f.s.s.RouterFunctionMapping: Mapped /api => {
/v1 => {
/status ->
com.example.demo.DemoApplication$$Lambda$189/1904651750#5fdc83e
}
}
But when calling curl -v http://localhost:8080/demo/say-hello or curl -v http://localhost:8080/demo/api/v1/status I see default Tomcat 404 page. The path is correct, I rename .war to demo.war before deploying it.
Did anybody come across similar issue? You can find the code here.
I'm afraid the WAR deployment model is not supported in Spring Boot for WebFlux at the moment. Spring Framework does support that model (although I'm not sure it supports deploying an app to a non-root context).
You can always create an issue on the Spring Boot issue tracker, but I'm not sure this will be implemented, as deploying to a Servlet container is not the primary focus there (and you can't do that with Netty).
Quick note: adding #EnableWebFlux is a signal that you'd like to take the WebFlux configuration in your own hands and that Spring Boot should not auto-configure things for you in that space.
Answering it now just in case some one else is still facing this issue.
In the POM file, you need to exclude the netty and add tomcat separately.
compile ('org.springframework.boot:spring-boot-starter-webflux') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-
reactor-netty'
}
compile 'org.springframework.boot:spring-boot-starter-tomcat'
Please check the link for full code : https://github.com/sushantkr16/Spring-boot2-webflux-annotation

Categories

Resources