Spring Migration from 4.x to 5.3.19 - spring

I have migrated all libraries for Spring4.x and hibernate3.x to Hibernate 5 and spring 5.3.19. I have below line of code in my configuration file
bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> with this it's throwing error class not found. I understood it's deprecated in latest spring. But what is the alternative for this in latest spring version.
After commenting the above line in my configuration file, Server is started successfully But when I hit URL I am getting below error.
HTTP Status 404 – Not Found
Type Status Report
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.43.

Related

spring boot 3 upgrade: error in application.yml file

I have upgraded spring boot version to 3 and getting below error for the field connection-timeout in properties file, what alternative can I use for this?
Property source 'Config resource 'class path resource [application.yml]' via location 'optional:classpath:/'':
Key: server.connection-timeout
Line: 16
Reason: Each server behaves differently.
Please refer to the release notes or reference guide for potential alternatives.
There is an answer: https://stackoverflow.com/a/72700025/345130
In short, server.connection-timeout was removed in Spring Boot 2.3.0.RELEASE.
User server-specific properties, such as server.tomcat.connection-timeout.

Custom error page routing struts 2 + spring boot

I am trying to run a struts 2 application in spring boot provided embedded tomcat, I have managed to do so following the link https://jgalacambra.wordpress.com/2016/06/13/spring-boot-and-struts-2/. The application is working, however I am not able to get through the custom page error routing based on http error code which was configured earlier in web.xml. I have tried below solutions so far and none of them seems to work as I keep getting default tomcat error page for 404.
Things I have tried so far:
1.Disabled white label error page using.
"server.error.whitelabel.enabled=false"
2.created public/error folder in src/main/resouces and placed all html error code related html files there.
3.Also tried creating templates folder under src/main/resources and placed http error code files there.
4.I have also configured my filterregistration bean with below setting.
registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
Can someone please help what needs to be done for the error routing to work???

Consider defining a bean of type 'org.springframework.social.twitter.api.Twitter' in your configuration

So I am following https://spring.io/guides/gs/accessing-twitter/ to connect my application to Twitter to get some user data. But it looks like with recent changes to Spring boot (version 2.0.3.RELEASE) and Spring-social-twitter, I am not able to execute the said article successfully. I keep getting following error:
Consider defining a bean of type 'org.springframework.social.twitter.api.Twitter' in your configuration.
Has anyone tried the same sample with new Spring boot release? What am I missing?

Spring 4 MVC Hibernate Resource not found

Was recently following this tutorial : https://examples.javacodegeeks.com/enterprise-java/spring/mvc/spring-mvc-hibernate-tutorial/ , I have followed everything mentioned there but when I go access my app it just shows a 404 with message "The requested resource is not available."
I have already made sure my app compiles and no error were found, I wonder what could be wrong?
also where should i look at for integrating spring 4 with hibernate?
thanks

Why do I get "HTTP Status 503 - This application is not currently available" in tomcat 6?

I have an application written with Struts2 and Spring for DI and I'm using Tomcat 6 as container. Assuming I have packaged the application as my-application.war after deployment on Tomcat I can access it through http://my-host/my-application.
When I delete the .war file, Tomcat's supposed to undeploy the application and according to here When I try the http://my-host/my-application I should get:
HTTP Status 404
but instead I get:
HTTP Status 503 - This application is not currently available
When I redeploy the application to same context path I get a weird exception:
Unable to instantiate Action, [ActionClass], defined for '' in
namespace '/' Failed to convert value of type [MyClass] to required type
[MyClass] for property 'myClass': no matching editors or conversion strategy
found
in which ActionClass has a property myClass of type MyClass which is injected by Spring and by default is a singleton. It's weird because type of both objects is the same. I suspect the application don't get undeployed completely in the first place cause when I restart Tomcat the scenario will be repeated. I would appreciate any help on finding the possible cause of this.
Well I think I found the answer. As I guessed the problem was with the improper undeployment.
It seems that deploying and undeploying an application without restarting the tomcat is a tricky business. When you deploy your application Tomcat classloader loads the classes in of the application and once they're loaded it seems they won't be unloaded with undeployment. And constantly deploying and undeploying an application will cause a serious memory leak. This case is specially true with singletons since the remained version of object in JVM doesn't match the newly deployed class. Hence the error I got above.
The safe path seems to be restarting Tomcat each time you redeploy any application.
Sources helped me find these information:
What makes hot deployment a "hard problem"?
Tomcat: hot deploying new jars
This post on CodeRanch
And some more sources found on Google

Resources