Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart property gives error when enabled #3209

Closed
cbelleza opened this issue Jun 11, 2015 · 2 comments
Closed

Multipart property gives error when enabled #3209

cbelleza opened this issue Jun 11, 2015 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@cbelleza
Copy link

Hi,

When the property multipart.enabled=true is enabled, throws an exception on console saying it has an invalid value. You can notice in the following link http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html, it should work normally.

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'enabled' of bean class [org.springframework.boot.autoconfigure.web.MultipartProperties]: Bean property 'enabled' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:927)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
    at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:749)
    at org.springframework.validation.DataBinder.doBind(DataBinder.java:645)
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:121)
    at org.springframework.validation.DataBinder.bind(DataBinder.java:630)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:253)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:227)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:296)
    ... 73 common frames omitted
# MULTIPART (MultipartProperties)
multipart.enabled=true
multipart.file-size-threshold=0 # Threshold after which files will be written to disk.
multipart.location= # Intermediate location of uploaded files.
multipart.max-file-size=1Mb # Max file size.
multipart.max-request-size=10Mb # Max request size.

So to dodge this issue, I had to add via Java configuration one filter enabling the Multipart in Spring Boot:

@Configuration
    public class TestConfig {

        @Bean
        public FilterRegistrationBean openEntityManagerFilterRegistrationBean() {
            // Set upload filter
            final MultipartFilter multipartFilter = new MultipartFilter();
            final FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(multipartFilter);
            filterRegistrationBean.addInitParameter("multipartResolverBeanName", "commonsMultipartResolver");

            return filterRegistrationBean;
        }

        @Bean
        public CommonsMultipartResolver commonsMultipartResolver() {
            final CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
            commonsMultipartResolver.setMaxUploadSize(-1);

            return commonsMultipartResolver;
        }
    }
@philwebb philwebb added the type: bug A general bug label Jun 12, 2015
@philwebb philwebb added this to the 1.2.5 milestone Jun 12, 2015
@wilkinsona
Copy link
Member

The default value for multipart.enabled is true so the simple workaround for this issue is to remove multipart.enabled=true from your application.properties.

@cbelleza
Copy link
Author

Ok, but I do not see the filter enabled on log by default.

How can I see if it's working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants