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

Jakarta support (as java21 version) #12

Open
jflute opened this issue Jul 25, 2024 · 5 comments
Open

Jakarta support (as java21 version) #12

jflute opened this issue Jul 25, 2024 · 5 comments
Assignees

Comments

@jflute
Copy link
Contributor

jflute commented Jul 25, 2024

// Japanese here

LastaFluteのjakarta対応に合わせて、jakarta21ブランチのharborを作る。

@jflute jflute self-assigned this Jul 25, 2024
@jflute
Copy link
Contributor Author

jflute commented Jul 25, 2024

commons-fileuploadもjakarta対応のバージョンを使わないといけない。

https://commons.apache.org/proper/commons-fileupload/commons-fileupload2-jakarta-servlet6/summary.html

<dependency> <!-- used for multipart request -->
	<groupId>org.apache.commons</groupId>
	<artifactId>commons-fileupload2-jakarta-servlet6</artifactId>
	<version>${commons.fileupload.version}</version>
</dependency>

そして、HarborMultipartRequestHandlerがコンパイルエラーのオンパレード。

ServletFileUploadがいなくなってるとかどうすりゃいいのか?

fessで先立って対応しているコードを教えてもらったので参考にする。
https://github.com/codelibs/fess/commit/90d6af13850c9e58a08ac46dce01287e557248c8#diff-46ded191a59579f83512554ead4[…]fd37acde6513fcbe2e7db5a9a1421c7f](https://github.com/codelibs/fess/commit/90d6af13850c9e58a08ac46dce01287e557248c8#diff-46ded191a59579f83512554ead4b7692fd37acde6513fcbe2e7db5a9a1421c7f)

JakartaServletDiskFileUploadを使う。

@jflute
Copy link
Contributor Author

jflute commented Jul 25, 2024

変更点概要:
o ServletFileUpload -> JakartaServletDiskFileUpload
o SizeLimitExceededException -> FileUploadByteCountLimitException
o FileItem -> DiskFileItem
o DiskFileItemFactoryはbuilder()でnewする
o StringのencodingがもろもろCharsetに
o e.getPermittedSize() -> e.getPermitted()

@jflute
Copy link
Contributor Author

jflute commented Jul 25, 2024

一括修正:

import javax.annotation.Resource
↓
import jakarta.annotation.Resource

@jflute
Copy link
Contributor Author

jflute commented Jul 25, 2024

jtaをjakarta対応に

<dependency>
	<groupId>jakarta.transaction</groupId>
	<artifactId>jakarta.transaction-api</artifactId>
	<version>2.0.1</version>
</dependency>

@jflute
Copy link
Contributor Author

jflute commented Jul 25, 2024

warファイル作るところ:

<artifactId>maven-dependency-plugin</artifactId>
...
<!-- servlet container libraries are located as war resource -->
<includeArtifactIds>
	jakarta.servlet-api, jakarta.servlet.jsp, jakarta.servlet.jsp-api
	, jetty-boot, jetty-all, javax.el, jetty-jsp, jetty-schemas, jakarta.websocket-api
	, tomcat-boot, tomcat-embed-core, tomcat-embed-logging-juli
	, tomcat-jasper, tomcat-jasper-el, tomcat-el-api, tomcat-jsp-api, ecj

...
<artifactId>maven-war-plugin</artifactId>
<configuration>
	<!-- servlet container libraries are not in application -->
	<packagingExcludes> <!-- #jakarta -->
		WEB-INF/lib/jakarta.servlet-api-*.jar, WEB-INF/lib/jakarta.servlet.jsp-*.jar
		, WEB-INF/lib/jetty-*.jar, WEB-INF/lib/jakarta.el-*.jar, WEB-INF/lib/jakarta.websocket-*.jar
		, WEB-INF/lib/org.eclipse.jdt.core-*.jar
		, WEB-INF/lib/tomcat-*.jar
	</packagingExcludes>

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

No branches or pull requests

1 participant