So I'm looking at this and trying to understand ho...
# community-support
c
So I'm looking at this and trying to understand how this is a runtime dependency when it appears that hibernate-core is saying that it's compile time https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core/6.5.2.Final am I reading this wrong? Is hibernate-core not the only thing with a direct dependency here? how is it ending up as a runtime dependency? https://scans.gradle.com/s/73uwcvwekrefc/dependencies?focusedDependency=WzEsOCwyOTUsW[…]5Nl1dLFsxLDgsWzYxNiw3OTYsNzg0XV0sWzEsOCxbNjE2LDgwMiw3NjhdXV0
Copy code
Calculating task graph as no cached configuration is available for tasks: :jpa:dependencyInsight --configuration runtimeClasspath --dependency transaction
Type-safe project accessors is an incubating feature.
> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors
> Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :buildSrc:extractPrecompiledScriptPluginPlugins UP-TO-DATE
> Task :buildSrc:compilePluginsBlocks UP-TO-DATE
> Task :buildSrc:generatePrecompiledScriptPluginAccessors UP-TO-DATE
> Task :buildSrc:generateScriptPluginAdapters UP-TO-DATE
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE

> Task :jpa:dependencyInsight
jakarta.transaction:jakarta.transaction-api:2.0.1
  Variant runtime:
    | Attribute Name                 | Provided     | Requested    |
    |--------------------------------|--------------|--------------|
    | org.gradle.status              | release      |              |
    | org.gradle.category            | library      | library      |
    | org.gradle.libraryelements     | jar          | jar          |
    | org.gradle.usage               | java-runtime | java-runtime |
    | org.gradle.dependency.bundling |              | external     |
    | org.gradle.jvm.environment     |              | standard-jvm |
    | org.gradle.jvm.version         |              | 17           |
   Selection reasons:
      - By constraint: dependency was locked to version '2.0.1'
      - By ancestor

jakarta.transaction:jakarta.transaction-api:{strictly 2.0.1} -> 2.0.1
\--- runtimeClasspath

jakarta.transaction:jakarta.transaction-api:2.0.1
+--- org.hibernate.orm:hibernate-core:6.5.2.Final
|    +--- runtimeClasspath (requested org.hibernate.orm:hibernate-core:{strictly 6.5.2.Final})
|    +--- org.springframework.boot:spring-boot-dependencies:3.3.2
|    |    +--- runtimeClasspath (requested org.springframework.boot:spring-boot-dependencies:3.+)
|    |    \--- project :model (requested org.springframework.boot:spring-boot-dependencies:3.+)
|    |         \--- runtimeClasspath
|    +--- org.hibernate.orm:hibernate-envers:6.5.2.Final
|    |    +--- runtimeClasspath (requested org.hibernate.orm:hibernate-envers)
|    |    \--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
|    \--- org.springframework.boot:spring-boot-starter-data-jpa:3.3.2
|         +--- runtimeClasspath (requested org.springframework.boot:spring-boot-starter-data-jpa)
|         \--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)
\--- org.springframework.boot:spring-boot-dependencies:3.3.2 (*)

(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 2s
11 actionable tasks: 2 executed, 9 up-to-date

Publishing build scan...
<https://gradle.com/s/zngohwgoi6gv6>

Configuration cache entry stored.
v
compile = compile and runtime runtime = runtime
c
apparently I haven't had a large enough caffeine injection
v
🙂
c
sigh trying to track down the stupid of either how I get rid of it, or a better way of giving jakarta transaction versions
because spring boot refuses to, and apparently hibernate didn't either. The spec also foolishly didn't provide any kind of version (range or otherwise)
I guess it's not safe to remove it, I assumed it was required in the starter
v
Didn't get what you mean. Doesn't the scan say you set a strict version constraint for that lib in your jpa project?
c
the problem is jakarta-transaction requires CDI
as provided
and has a jpms constraint for the same
no one is actually providing them at runtime
I don't have a direct dependency on jakarta transaction
but because of the misguided spec... I have to include this stuff myself
and because spring boot has refused any remediation
I"m not even sure if hibernate should be the one providing a version of these "provided" dependencies. I think my understanding of an EE spec is they're meant to be provided by the ... "container", which is what spring is providing.
of course it wouldn't be a problem at all if spring didn't feel the need to not use the EE BOM (I think, 5 minutes)
ugh, so if a dependency in maven is defined as "provided" gradle doesn't do that if a version is provided either huh... still need to add it explicitly
is there a better way then just copy pasta-ing it?
"if transient or explicit transaction-api present also add deps"
v
Yes, a
provided
library is meant to be provided by the runtime environment, this can for example be a JEE container.
if a dependency in maven is defined as "provided" gradle doesn't do that if a version is provided either huh
Just like Maven, Gradle basically ignores any
provided
or
optional
entries, they are only considered informative for the human user. They will not be added automatically anywhere and they also will not influence versions in any way.
"if transient or explicit transaction-api present also add deps"
That would then be a component metadata rule in which you add the dependency
c
right, but provided isn't optional... that's what bothers me about the whole thing 😕 neways
but I guess to be fair an EE container is usually an external server. Embedded server is kind of new
v
Regarding dependency resolution it indeed is optional, as it is the responsibility of the runtime environment to provide the dependency. 🤷‍♂️
If some JEE server vendor builds a JEE server, it is his responsibility to provide the provided lib. In the case of a Spring Boot project, you are the one building the runtime environment along with your project, so it is your responsibility to provide the provided lib.
c
yeah... but I still think since the dependency is there and is "requires" that the spring boot starter should be providing it.... and spring boot should be using the EE bom to get a version
like, yes, but also no
this should be, by default, zero conf in spring boot
not "we are ignoring JPMS"
so we don't care that it causes runtime issues
I also blame java. I think automatic modules at minimum should be required these days. Issues like this should be at least a runtime warning.
I see zero failure on my part. Java isn't strict enough. Jakarta should have made these requires static, and spring should consider jpms requirements mandatory even if they don't directly need it themselves
v
requires static
does not make sense if it is provided, because as you correctly said, it is effectively required.
requires static
is for stuff that is optional and it works if it is not present at runtime. But yeah, probably Boot should provide it or at least provide a version. 🤷‍♂️
c
well, in this case the spec is arguably wrong. It probably should be optional
it's only needed for interceptors or something... that spring doesn't use for example
part of the failure here then is that spring is not collaborating properly on these specs
v
Actually I don't really get why you think Spring should do anything in relation to the JEE spec. Spring is not JEE. Spring is Spring. JEE is JEE. For example DI is done via Spring in Spring, but via CDI in JEE.
c
you can use CDI in JEE
err.. spring
last I checked
@Inject
still works
but that's not the point really
Spring does use JEE dependencies
so they should collaborate on the spec
v
@Inject
is not CDI
Both, Spring and CDI, support the
@Inject
annotation
c
because the transaction library added a CDI dependency
fair enough, I don't work with EE enough
the argument here is that the transaction library added CDI and another dependency
as required
spring supports transaction-api
afaik
but that dependency on cdi should probably have been optional
even a small discussion on whether a future version should externalize or make those dependencies optional
v
Possible
c
it's not all my discussion either. I'm not the first person to open a bug with jakarta transaction. I'm just the one who did it with spring
and I don't think it's unreasonable to say that spring should be paying attention to the EE specs if they're going to have dependencies on them
and say when the spec is not going to work for them
mmk, back to figuring it out and then putting in component rules or whatever