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

[BUG] 3.0.0 raises compilation error cannot access javax.servlet.http.HttpServletRequest #33378

Closed
lchrennew opened this issue Nov 27, 2022 · 5 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@lchrennew
Copy link

lchrennew commented Nov 27, 2022

Hi there,

I'm trying to migrate springboot from 2.7.5 to 3.0.0, and I got a compilation error when I try to run mvn compile.

I think this should be a bug caused by the mismatch between the new version embeded tomcat and the legacy commons-fileupload.

POM

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
    </parent>
...
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

FileUploadController.java

import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.web.bind.annotation.*;


import static org.apache.commons.fileupload.servlet.ServletFileUpload.isMultipartContent;

@RestController
public class FileFacade {

...
    @SneakyThrows
    @PostMapping("/files/{bucket}")
    public void upload(
        RequestContext request,
        @PathVariable String bucket,
        @RequestParam String path
    ) {
        when(isMultipartContent(request))
            .then(
                this::startUploading,
                new UploadingArgs(bucket, path, new ServletFileUpload().getItemIterator(request)));
    }
...
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2022
@bclozel
Copy link
Member

bclozel commented Nov 27, 2022

This is expected as support has been removed in favor of standard multipart support. The new baseline is Jakarta EE9+ APIs.

See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Release-Notes#miscellaneous and https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#web-applications and spring-projects/spring-framework#29562.

Thanks!

@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 27, 2022
@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2022
@pcgeng
Copy link

pcgeng commented Jul 3, 2023

@bclozel We have the same issue after upgrading spring boot to 3.x since commons-fileupload:1.5 is till using javax.servlet.http.HttpServletRequest for request parsing, which means we cannot use commons-fileupload for large file upload features in spring boot 3.x, right? If so, is there a replacement for large file upload support in spring boot 3.x?

@bclozel
Copy link
Member

bclozel commented Jul 3, 2023

@pcgeng please use StackOverflow for questions. Feel free to link to the question here.

@rakesh-sahani
Copy link

I found the one more bug while working Jakarta servlet or web. When you will try to access the HttpServletRequest has the newPushBuilder method always gives null object. If you will satisfied the condition but object remains the null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants