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

Add support for Jakarta EE #1284

Closed
abrudin opened this issue Oct 4, 2021 · 27 comments
Closed

Add support for Jakarta EE #1284

abrudin opened this issue Oct 4, 2021 · 27 comments
Labels
enhancement New feature or request

Comments

@abrudin
Copy link

abrudin commented Oct 4, 2021

Is your feature request related to a problem? Please describe.
When using springdoc-openapi-ui, one gets a dependency to the old javax-apis through the version of swagger-core that is included (via springdoc-common).

Describe the solution you'd like
It seems swagger has solved this by publishing separate artifacts suffixed with jakarta (See swagger-api/swagger-core#3881). It would be nice if one could do the same with springdoc, or if possible solve it in some other way, so as not have to manually exclude the javax-swagger-versions and include the jakarta-swagger versions a la

implementation(
  'io.swagger.core.v3:swagger-annotations-jakarta:2.1.11',
  'io.swagger.core.v3:swagger-integration-jakarta:2.1.11',
  'io.swagger.core.v3:swagger-models-jakarta:2.1.11'
)

implementation('org.springdoc:springdoc-openapi-ui:1.5.11') {
  exclude(group: 'io.swagger.core.v3', module: 'swagger-annotations')
  exclude(group: 'io.swagger.core.v3', module: 'swagger-integration')
  exclude(group: 'io.swagger.core.v3', module: 'swagger-models')
}

I'm not well enough versed in all the possibilities of configuring dependencies in maven to come up with the best solution to this, but it would be nice if it could be solved somehow, as jakarta.* is where the development will continue.

@bnasslahsen bnasslahsen changed the title Make it possible to use jakarta versions of swagger dependencies Add support for Jakarta EE Oct 9, 2021
@bnasslahsen
Copy link
Contributor

@abrudin,

Thank you for your proposal.
What is sure, is that once the support will be fully available in spring 6, the support should also be available in springdoc-openapi.

I think the straightforward solution, is to have separate dependencies: one dedicated for jakarta support and another one for javax.

Don't hesitate to propose a PR, if you have any solutions in mind.

This feature, should anyway be supported and will be added for the next springdoc major release.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 9, 2022
@juergenzimmermann
Copy link

1st milestone of Spring Boot 3 with support for Jakarta EE 9 is available.

@goafabric
Copy link

goafabric commented Jan 22, 2022

just found this issue after upgrading to Spring Boot 3.0 M1 ..
OpenAPI crashes by trying to use Reflection for javax Classes (like Servlet) .. which our now gone / replaced by the jakarta ee namespace ..

SpringDoc Version is 1.6.4

at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:461) ~[spring-core-6.0.0-M2.jar:6.0.0-M2]
... 90 common frames omitted

Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]

bnasslahsen added a commit that referenced this issue Jan 25, 2022
bnasslahsen added a commit that referenced this issue Jan 25, 2022
bnasslahsen added a commit that referenced this issue Jan 25, 2022
bnasslahsen added a commit that referenced this issue Jan 25, 2022
@bnasslahsen
Copy link
Contributor

bnasslahsen commented Jan 27, 2022

Hi @goafabric,

The support has been added in springdoc-openapi 2 branch.
For now we will Support Jakarta EE 9 and Spring-Boot 3.
springdoc-openapi v2 will require Java 17as a minimum version and Spring Boot 3.x
springdoc-openapi v2 will be released once spring-Boot 3 goes G.A.

This is the link for the demos code:

If you want to give it a try, this is a first version of the documentation updated here:

And this is the migration steps:

Note: spring-cloud and spring-native are not yet ready for spring-boot 3 support.

Please feel free to use and test the latest SNAPSHOT: springdoc-openapi v2.0.0-SNAPSHOT.

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.0.0-SNAPSHOT</version>
   </dependency>

Don't hesitate to provide your comments in this ticket.

@juergenzimmermann
Copy link

juergenzimmermann commented Jan 27, 2022

@bnasslahsen Will you release milestones until Spring Boot 3 goes GA or do we have to use snapshots until then?

@bnasslahsen
Copy link
Contributor

@juergenzimmermann,

Ofc we will release milestones until then. We will try to stick to spring-boot ones.
We just need to the SNAPSHOT version enough stable to release it!

Don't hesitate, to give it a try and share your comments.

@juergenzimmermann
Copy link

I just upgraded using springdoc-openapi-starter-webflux-ui and it works fine. Thank you for supporting Jakarta EE 9.

@goafabric
Copy link

@bnasslahsen
works like a charm .. yeah i know about spring-native .. its not even supported by the spring people
thx for your extraordinary fast support for all things spring

@bnasslahsen
Copy link
Contributor

@juergenzimmermann,

FYI, springdoc-openapi v2.0.0-M1 has been released.

@juergenzimmermann
Copy link

Thank you @bnasslahsen

@leandrocgsi
Copy link

Hi @goafabric,

The support has been added in springdoc-openapi 2 branch. For now we will Support Jakarta EE 9 and Spring-Boot 3. springdoc-openapi v2 will require Java 17as a minimum version and Spring Boot 3.x springdoc-openapi v2 will be released once spring-Boot 3 goes G.A.

This is the link for the demos code:

If you want to give it a try, this is a first version of the documentation updated here:

And this is the migration steps:

Note: spring-cloud and spring-native are not yet ready for spring-boot 3 support.

Please feel free to use and test the latest SNAPSHOT: springdoc-openapi v2.0.0-SNAPSHOT.

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.0.0-SNAPSHOT</version>
   </dependency>

Don't hesitate to provide your comments in this ticket.

Thank you so much!!!

@JohnNiang
Copy link
Contributor

Thank @bnasslahsen for your efforts!

I'm experiencing org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M2.

@jesperancinha
Copy link

Hi there, I'm experiencing this same issue. Here is the exception:

Caused by: java.lang.ClassNotFoundException: javax.validation.constraints.Min
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 120 common frames omitted

This is something quite needed for one of the modules I'm working on. When do you reckon a release will be available to use?

@jesperancinha
Copy link

If you look at the link above, you'll see what is happening. It seems like springdoc is still using the old javax validations and is not providing support to jakarta yet.

@bnasslahsen
Copy link
Contributor

@juergenzimmermann,

Please:

And then, if you still have any comment, make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

@downloadpizza
Copy link

downloadpizza commented Aug 23, 2022

Is there any way to convince springdoc to still use javax annotations? I would like to avoid the extra dependency but it decides to try to use jakarta.annotation.Generated over the javax one (I assume this is on your side and not openapi codegens)

@bnasslahsen
Copy link
Contributor

bnasslahsen commented Aug 23, 2022

Is there any way to convince springdoc to still use javax annotations? I would like to avoid the extra dependency but it decides to try to use jakarta.annotation.Generated over the javax one (I assume this is on your side and not openapi codegens)

  • springdoc 1.x supports already javax annotations. This is the version to use with spring-boot 2.x.
  • springdoc 2.x will support jakarta annotations and will only support spring-boot 3.x which depends on jakarta annotations as well.

@goafabric
Copy link

@bnasslahsen
has
org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M5

already support for native images in boot 3.0 ?

because last time i tried i could not get it working

thank u

@bnasslahsen
Copy link
Contributor

@goafabric,

The native support is added to the v2.0.0-M7-SNAPSHOT, which now fully supports spring-boot 3.0.0-M5.
If you have some time, do not hesitate to test it before the next release.

For the OpenAPI REST endpoints, you just need to build your application with the spring native profile.
For the UI, you will have to add springdoc.enable-native-support=true. This is mainly related to webjars/webjars-locator-core#96

@goafabric
Copy link

@bnasslahsen
works like a charm ! thank you very much
and as always for all your efforts

@goafabric
Copy link

goafabric commented Oct 16, 2022

@bnasslahsen

With a more complex project with jpa I get the error below.
But there is an easy fix by registering a reflection hint.
Maybe you can also incorporate that.
Thank u

---fix ---
hints.reflection().registerType(java.lang.Module.class, MemberCategory.INVOKE_DECLARED_METHODS);

-- error --
Caused by: java.lang.IllegalArgumentException: Method "getLayer" could not be invoked: java.lang.NoSuchMethodException: Could not find method java.lang.Module.getLayer [498](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:500) at nonapi.io.github.classgraph.reflection.ReflectionUtils.invokeMethod(ReflectionUtils.java:231) ~[na:na] [499](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:501) at nonapi.io.github.classgraph.classpath.ModuleFinder.findModuleRefsFromCallstack(ModuleFinder.java:227) ~[na:na] [500](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:502) at nonapi.io.github.classgraph.classpath.ModuleFinder.<init>(ModuleFinder.java:284) ~[na:na] [501](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:503) at nonapi.io.github.classgraph.classpath.ClasspathFinder.<init>(ClasspathFinder.java:164) ~[na:na] [502](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:504) at io.github.classgraph.Scanner.<init>(Scanner.java:166) ~[na:na] [503](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:505) at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1531) ~[na:na] [504](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:506) at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1559) ~[na:na] [505](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:507) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1584) ~[na:na] [506](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:508) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1623) ~[na:na] [507](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:509) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1636) ~[na:na] [508](https:/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:510) at org.webjars.WebJarAssetLocator.scanForWebJars(WebJarAssetLocator.java:188) ~[na:na]

bnasslahsen added a commit that referenced this issue Oct 16, 2022
@bnasslahsen
Copy link
Contributor

@goafabric,

Good hint!
I have also found it for spring-data-rest.
I have moved it to to the common hints!

@goafabric
Copy link

@bnasslahsen
tried out RC1 this morning .. unfortunately it does not only need graalvm 22.3
which is currently only provided by liberica and no paketo build (just to let you know)

it also needs additional hints .. but then it works again:

hints.reflection().registerType(java.lang.Module.class, MemberCategory.INVOKE_DECLARED_METHODS);
hints.reflection().registerType(java.lang.ModuleLayer.class, MemberCategory.INVOKE_DECLARED_METHODS);
hints.reflection().registerType(java.lang.module.Configuration.class, MemberCategory.INVOKE_DECLARED_METHODS);
hints.reflection().registerType(java.lang.module.ResolvedModule.class, MemberCategory.INVOKE_DECLARED_METHODS);

@lpandzic
Copy link

Is there a version of springdoc-openapi-webmvc-core somewhere that supports this change?

@rzaayshan
Copy link

Hi @goafabric,

The support has been added in springdoc-openapi 2 branch. For now we will Support Jakarta EE 9 and Spring-Boot 3. springdoc-openapi v2 will require Java 17as a minimum version and Spring Boot 3.x springdoc-openapi v2 will be released once spring-Boot 3 goes G.A.

This is the link for the demos code:

* https:/springdoc/springdoc-openapi-demos/tree/2.x

If you want to give it a try, this is a first version of the documentation updated here:

* https://springdoc.org/v2/

And this is the migration steps:

* https:/springdoc/springdoc-openapi-demos/wiki/springdoc-openapi-2.x-migration-guide

Note: spring-cloud and spring-native are not yet ready for spring-boot 3 support.

Please feel free to use and test the latest SNAPSHOT: springdoc-openapi v2.0.0-SNAPSHOT.

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.0.0-SNAPSHOT</version>
   </dependency>

Don't hesitate to provide your comments in this ticket.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConversionServiceProvider' defined in class path resource [org/springdoc/core/configuration/SpringDocConfiguration$WebConversionServiceConfiguration.class]: Failed to instantiate [org.springdoc.core.providers.WebConversionServiceProvider]: Factory method 'webConversionServiceProvider' threw exception with message: class org.springframework.boot.autoconfigure.web.format.WebConversionService cannot be cast to class java.util.List (org.springframework.boot.autoconfigure.web.format.WebConversionService is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')

I get the error like this

@bnasslahsen
Copy link
Contributor

@rzaayshan,

Make sure you read the Contribution guidelines

As mentionned, in the guidelines above, if you feel you are facing an issue, make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

@springdoc springdoc deleted a comment from jonatan-ivanov Nov 22, 2022
@springdoc springdoc deleted a comment from jonatan-ivanov Nov 22, 2022
@springdoc springdoc deleted a comment from mmm8955405 Nov 24, 2022
@bnasslahsen
Copy link
Contributor

The springdoc-openapi v2 has been released as spring-boot v3 is now GA.
The documentation of the springdoc-openapi v2, has been updated accordingly as well.

@springdoc springdoc locked as resolved and limited conversation to collaborators Nov 24, 2022
@bnasslahsen bnasslahsen linked a pull request Nov 24, 2022 that will close this issue
@bnasslahsen bnasslahsen removed a link to a pull request Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants