[英]Unable to lookup JNDI name [javax.transaction.TransactionManager]
[英]Quarkus Hibernate No bean found for required type [interface javax.transaction.TransactionManager] and qualifiers [[]]
我從 Quarkus 網站建立了一個 Quarkus/Kotlin/Gradle 項目。 我正在嘗試使用休眠/華麗/反應式制作一個簡單的反應式 api:
API:
@Path("incidents")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
class IncidentResource {
@Inject
lateinit var incidentRepository: IncidentRepository
@GET
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
fun getHello(): String = "hello"
@GET
fun get(): Uni<List<Incident>> = incidentRepository.findAll().list()
}
Model:
@Entity
data class Incident(
@Id
@GeneratedValue
@field:JsonProperty("id")
val id: String,
@Column(nullable = false)
@field:JsonProperty("summary")
val summary: String,
)
存儲庫:
@ApplicationScoped
class IncidentRepository : PanacheRepository<Incident> {
}
/incidents/hello 路徑工作正常,但 /incidents 給我一個錯誤:
Request failed : javax.enterprise.inject.UnsatisfiedResolutionException: No bean found for required type [interface javax.transaction.TransactionManager] and qualifiers [[]]
at io.quarkus.arc.impl.InstanceImpl.bean(InstanceImpl.java:175)
at io.quarkus.arc.impl.InstanceImpl.getInternal(InstanceImpl.java:196)
at io.quarkus.arc.impl.InstanceImpl.get(InstanceImpl.java:93)
at io.smallrye.context.jta.context.propagation.JtaContextProvider.tm(JtaContextProvider.java:120)
at io.smallrye.context.jta.context.propagation.JtaContextProvider.currentContext(JtaContextProvider.java:34)
at io.smallrye.context.impl.ThreadContextProviderPlan.takeThreadContextSnapshots(ThreadContextProviderPlan.java:72)
at io.smallrye.context.impl.SlowCapturedContextState.<init>(SlowCapturedContextState.java:25)
at io.smallrye.context.SmallRyeThreadContext.captureContext(SmallRyeThreadContext.java:729)
at io.smallrye.context.SmallRyeThreadContext.contextualSupplier(SmallRyeThreadContext.java:719)
at io.smallrye.mutiny.context.BaseContextPropagationInterceptor.decorate(BaseContextPropagationInterceptor.java:27)
at io.smallrye.mutiny.infrastructure.Infrastructure.decorate(Infrastructure.java:124)
at io.smallrye.mutiny.groups.UniCreate.completionStage(UniCreate.java:134)
at org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl.uni(MutinySessionFactoryImpl.java:62)
at org.hibernate.reactive.mutiny.impl.MutinyQueryImpl.uni(MutinyQueryImpl.java:40)
at org.hibernate.reactive.mutiny.impl.MutinyQueryImpl.getResultList(MutinyQueryImpl.java:191)
at io.quarkus.hibernate.reactive.panache.common.runtime.CommonPanacheQueryImpl.lambda$list$4(CommonPanacheQueryImpl.java:219)
at io.quarkus.hibernate.reactive.panache.common.runtime.CommonPanacheQueryImpl.applyFilters(CommonPanacheQueryImpl.java:323)
at io.quarkus.hibernate.reactive.panache.common.runtime.CommonPanacheQueryImpl.list(CommonPanacheQueryImpl.java:219)
at io.quarkus.hibernate.reactive.panache.runtime.PanacheQueryImpl.list(PanacheQueryImpl.java:149)
at com.alert.api.IncidentResource.get(IncidentResource.kt:26)
at com.alert.api.IncidentResource_Subclass.get$$superaccessor5(IncidentResource_Subclass.zig:733)
at com.alert.api.IncidentResource_Subclass$$function$$8.apply(IncidentResource_Subclass$$function$$8.zig:29)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.alert.api.IncidentResource_Subclass.get(IncidentResource_Subclass.zig:691)
at com.alert.api.IncidentResource$quarkusrestinvoker$get_407a850349137c93edc5dab2a621b8699ccd0a7c.invoke(IncidentResource$quarkusrestinvoker$get_407a850349137c93edc5dab2a621b8699ccd0a7c.zig:33)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:122)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:47)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder.lambda$start$1(StaticResourcesRecorder.java:65)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:101)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:206)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
我也有這個警告:
CDI: programmatic lookup problem detected
-----------------------------------------
At least one bean matched the required type and qualifiers but was marked as unused and removed during build
Removed beans:
- CLASS bean io.smallrye.context.jta.context.propagation.JtaContextProvider$LifecycleManager [types=[class io.smallrye.context.jta.context.propagation.JtaContextProvider$LifecycleManager], qualifiers=[@javax.enterprise.inject.Default(), @javax.enterprise.inject.Any()]]
Required type: class io.smallrye.context.jta.context.propagation.JtaContextProvider$LifecycleManager
Required qualifiers: [@javax.enterprise.inject.Default()]
應用程序屬性
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=test
quarkus.datasource.password=test
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.sql-load-script=import.sql
# Reactive config
quarkus.datasource.reactive.url=postgresql://localhost:5432/test
我找不到這個特定堆棧的適當示例或指南,我遵循了這個: https://quarkus.io/guides/hibernate-orm-panache-kotlin任何想法?
它在 application.properties 中需要 quarkus-hibernate-orm-panache-kotlin 依賴和quarkus.datasource.jdbc=false
TransactionManager
實現可以在實現io.quarkus:quarkus-narayana-jta
package 中找到。
您的數據庫 URL 需要如下所示:`quarkus.datasource.reactive.url=vertx-reactive:postgresql://...
另外,不要使用quarkus.hibernate-orm.database.generation=update
配置,因為它需要 JDBC
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.