I have an issue on migration JSF Apache myfaces CDI to Spring Boot - spring

Am migrating JSF to Spring boot. I have some Apache myfaces CDI annotation like 'ViewAccessScoped' and #Inject WindowContext. I have added dependency in pom.xml file. When I try to run an application. It throws error : illegal state exception : no org.apache.myfaces.extensions.cdi.core.api.provider.BenManageProvider in place ! Please ensure that you configured the CDI implementation of your choice properly. Can I use Apache myfaces CDI in spring boot.? or is there any another way to resolve the issue.?

Related

Spring Boot 3.0 package javax.validation does not exist

I'm trying to use a method parameter validation feature supported by Bean Validation 1.1. For instance, the following method triggers the validation of the first parameter, making sure it's valid:
public String generateOtp(#Valid TotpAuthenticatorForm form, BindingResult bindingResult)
When I build a Spring Boot 2.7.7 project it's fine, but building a Spring Boot 3.0.1 project fails with a compilation error:
package javax.validation does not exist
How do I fix the issue?
According to the release-notes, Spring Boot 3.0 has migrated from Java EE to Jakarta EE APIs for all dependencies, including:
Jakarta Validation 3.0
Spring Boot 2.7 - Jakarta Bean Validation 2.0
Spring Boot 3.0 - Jakarta Bean Validation 3.0
You can fix the issue by using Jakarta Bean Validation 3.0. Simply update import statements:
javax.validation
->
jakarta.validation

Resources not being wired after upgrading to jakarta-api 2.1.1

When upgrading jakarta-api 1.3.5 to 2.1.1, the #Resource annotated fields remain null. I'm using spring-context 5.3.22 (not spring-boot) and java 17.
The spring context is initialized manually; The AnnotationConfigApplicationContext is instantiated in main.
I figured, since Spring Boot 3.0 has migrated all Java EE APIs to their equivalent Jakarta EE variant, spring-context 5.3.22 should be able to wire the #Resource annotated fields. What am I missing?

Spring Boot 3 and JSF with Jakarta not working

Spring Boot 3 gives with its milestones the customers time to migrate from Java EE to Jakarta, changing package names from javax to jakarta. But it's more than package names. I can't get Spring Boot to run with JSF, let alone Primefaces-Jakarta.
All solutions I try, seem to either rely on CDI, and then complain there is no working CDI, --> because Spring Boot has another injection mechanism, this isn't Glassfish. Or it complains it can't find the factories, like this:
Servlet.init() for servlet [facesServlet] threw exception
java.lang.IllegalStateException: Keine Factory als Backup für jakarta.faces.lifecycle.LifecycleFactory gefunden.
at jakarta.faces.FactoryFinderInstance.notNullFactory(FactoryFinderInstance.java:496) ~[jakarta.faces-api-4.0.1.jar:na]
at jakarta.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:190) ~[jakarta.faces-api-4.0.1.jar:na]
If I set factory class names manually, they want CDI again, and I'm back where I started (and I don't want to have Spring and CDI existing in parallel anyway).
I use the latest versions of the Jakarta libraries and Spring Boot milestones.
Like "jakarta.faces:jakarta.faces-api:4.0.1", "org.glassfish:jakarta.faces:4.0.0" and "org.springframework.boot:spring-boot-starter-web:3.0.0-M4".
Is there any tutorial, open-source project or anything else which shows how it's done?
Adding at the end of your faces config following could help:
servletContext.setAttribute(com.sun.faces.RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED, Boolean.TRUE);

Changes To Spring #Autowired From Spring Boot 2.5.6 to 2.6.2

We have a Spring Boot App packaged as a war file and deployed on Wildfly. When I update the Spring Boot version from 2.5.6 to 2.6.2, I see lots of exception with Spring Autowire of variables. The problems being reported are circular dependency.
Has something changes with new version of Spring that changes how the autowiring works? I tried to research and can find no mention to changes in that area.
Thanks
The thing is that with the new Spring Boot version, circular dependencies are not allowed by default. Check the release notes.
You can get back to the previous behaviour setting the following configuration:
spring.main.allow-circular-references: true
However, I would suggest you revisit the application design.

spring data redis / spring boot dependency mismatch?

I tried upgrading a Spring Boot application from spring-data-redis 1.6.4.RELEASE to 1.7.2.RELEASE by adding the spring-data-redis dependency to the POM whilst leaving the spring-boot-starter-redis unchanged (using Spring Boot 1.3.5.RELEASE). The upgraded application fails to start with this error:
Caused by: java.lang.AbstractMethodError: org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(Ljava/lang/reflect/Method;Lorg/springframework/data/repository/core/RepositoryMetadata;Lorg/springframework/data/projection/ProjectionFactory;Lorg/springframework/data/repository/core/NamedQueries;)Lorg/springframework/data/repository/query/RepositoryQuery;
A bit cryptic.
You need to upgrade all of Spring Data, not just Spring Data Redis. By just overriding the version of Spring Data Redis you're left with an incompatible version of Spring Data Commons.
As you are using Spring Boot, you should override the version of the spring-data-releasetrain.version property to Hopper-SR2:
<properties>
<spring-data-releasetrain.version>Hopper-SR2</spring-data-releasetrain.version>
</properties>
and remove the version from any Spring Data-related dependencies you have declared so that Boot's dependency management can keep them all aligned.

Resources