gpt4 book ai didi

java - Hibernate/JBoss - 新配置()上的 "Service jboss-as has a circular dependency"

转载 作者:行者123 更新时间:2023-11-30 04:46:53 24 4
gpt4 key购买 nike

当尝试打开 Hibernate session 时,初始化新 Hibernate 配置的代码部分会因“Service jboss-as 具有循环依赖项”异常而中断。

从控制台应用程序调用相同的代码可以正常工作。

尝试了 Hibernate 4.1.3 和 4.0.1(其中包含 JBoss 7.1),但出现了相同的错误。

如果有人能将我推向正确的方向,我将不胜感激。

Configuration configuration = new Configuration();

JBoss 输出:

...
11:30:00,482 INFO [org.jboss.as] (MSC service thread 1-4) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3324ms - Started 173 of 250 services (76 services are passive or on-demand)
11:30:00,571 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "JBCXFRS.war"
11:30:10,903 INFO [org.jboss.resteasy.spi.ResteasyDeployment] (http-localhost-127.0.0.1-8080-2) Deploying javax.ws.rs.core.Application: class hr.spi.rs.MyApplication
11:30:24,081 INFO [org.hibernate.annotations.common.Version] (http-localhost-127.0.0.1-8080-3) HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
11:30:24,144 INFO [org.hibernate.Version] (http-localhost-127.0.0.1-8080-3) HHH000412: Hibernate Core {4.1.3.Final}
11:30:24,213 INFO [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-3) HHH000206: hibernate.properties not found
11:30:24,233 INFO [org.hibernate.cfg.Environment] (http-localhost-127.0.0.1-8080-3) HHH000021: Bytecode provider name : javassist
11:30:24,432 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-3) HHH000043: Configuring from resource: /hibernate.cfg.xml
11:30:24,437 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-3) HHH000040: Configuration resource: /hibernate.cfg.xml
11:30:24,825 INFO [org.hibernate.cfg.Configuration] (http-localhost-127.0.0.1-8080-3) HHH000041: Configured SessionFactory:
11:30:25,466 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-3) HHH000402: Using Hibernate built-in connection pool (not for production use!)
11:30:25,473 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-3) HHH000115: Hibernate connection pool size: 1
11:30:25,479 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-3) HHH000006: Autocommit mode: false
11:30:25,488 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-3) HHH000401: using driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] at URL [jdbc:sqlserver://MyDbServer;databaseName=MyDatabase]
11:30:25,496 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http-localhost-127.0.0.1-8080-3) HHH000046: Connection properties: {user=sa, password=****}
11:30:38,571 INFO [org.hibernate.dialect.Dialect] (http-localhost-127.0.0.1-8080-3) HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
11:30:38,837 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (http-localhost-127.0.0.1-8080-3) HHH000399: Using default transaction strategy (direct JDBC transactions)
11:30:38,897 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (http-localhost-127.0.0.1-8080-3) HHH000397: Using ASTQueryTranslatorFactory
11:30:39,868 INFO [org.hibernate.validator.util.Version] (http-localhost-127.0.0.1-8080-3) Hibernate Validator 4.2.0.Final
11:30:40,289 INFO [org.jboss.as.controller] (MSC service thread 1-2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming (missing) dependents: [service jboss.data-source.java:jboss/datasources/ExampleDS, service jbosgi.xservice."javax.naming.InitialContext", service jbosgi.xservice."javax.naming.spi.InitialContextFactoryBuilder", service jboss.deployment.unit."JBCXFRS.war".CLEANUP]
service jboss.naming.context.java (missing) dependents: [service jboss.naming.context.java.TransactionManager]

11:30:40,303 ERROR [stderr] (http-localhost-127.0.0.1-8080-3) Initial SessionFactory creation failed.org.jboss.msc.service.CircularDependencyException: Service jboss-as has a circular dependency

最佳答案

删除 hibernate.cfg.xml 的 session 工厂部分中的名称参数后,一切都开始工作,而不会出现“循环依赖”错误。

我不知道为什么它在运行时会出现任何问题,或者有人应该如何从神秘的 JBoss 异常中推断出这一点。

将其作为答案发布,希望它可以帮助某人节省一天的时间。

<hibernate-configuration>
<session-factory name="">
...

更改为:

<hibernate-configuration>
<session-factory>
...

关于java - Hibernate/JBoss - 新配置()上的 "Service jboss-as has a circular dependency",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10782573/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com