Spring file upload goes to Access denied page

Spring file upload goes to Access denied page

When Spring security is enabled, when I upload a file using multipart, SpringSecurity redirects me to Access denied url.

Refer to https://stackoverflow.com/questions/28225359/file-upload-spring-security
I amend my Initializer as follows!

public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer{
protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
insertFilters(servletContext, new MultipartFilter());

This error disappears. I landed in another problem. I’m resolving it now!!


Spring 5 migration: Unable to find setter method for attribute: [commandName]

Spring 5 Migration brings this pain. You will get this error during form submission.

Unable to find setter method for attribute: [commandName]

Command object does not work anymore.

Refer to https://stackoverflow.com/questions/46989072/org-apache-jasper-jasperexception-web-inf-views-home-jsp-line-25-column/48364974

commandName is dead in Spring 5. Replace it with modelAttribute

<form:form modelAttribute="customer" action="customerView" method="post">

It worked! I need to make this change in my workspace now!

Migrating to Hibernate 5: Table ‘crm.hibernate_sequence’ doesn’t exist

I’m doing upgrading Spring 4 to Spring 5 and Hibernate 4 to 5.
My existing functionality refused to work. It broke with the following exception.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘crm.hibernate_sequence’ doesn’t exist

I’m using MariaDB/MySQL. I don’t have to maintain any sequence tables as Oracle. In addition, it was working without any issues. All my primary keys are autogenerated with the following annotations.

private Long id;

Thanks to https://stackoverflow.com/questions/32968527/hibernate-sequence-doesnt-exist

Adding hibernate.id.new_generator_mappings=false to Hibernate properties solved the problem.

Eclipse tomcat does not start – May be locked by another process.

Happy Western New Year 2019!

I had a single spring web project. It became too big over the day. I had to split it up into multiple reusable projects so that I can build APIs. After I split it, Tomcat refused to start with the following error.

Publishing failed with multiple errors
Could not delete D:/Pandian/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/crm-upload/WEB-INF/lib. May be locked by another process.
Could not delete D:/Pandian/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/crm-upload/WEB-INF. May be locked by another process.

I tried to clean work folder, It doesn’t work. I did the following sequence to resolve this.

  1. Remove the tomcat server from eclipse server tab
  2. Restart Eclipse
  3. Add a new tomcat server
  4. Start the project


Read properties values in Java Spring Controller

To configure the environmental parameters, we read the values from property files. I have a controller which upload the files. The uploaded files will be saved in a location, which is defined in a property file. In this example I shall show you how to read the location name from the property file.

public class FileUploadController {
  String uploadFolder;

I have defined the property in app.properties file which is saved in src folder (or any other path defined in classpath.


Thats it! The variable uploadFolder will be assigned using the values given by app.properties.