1

当试图打开一个 Hibernate 会话时,初始化新 Hibernate 配置的代码部分因“服务 jboss-as 具有循环依赖”异常而中断。

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

尝试了包含 JBoss 7.1 的 Hibernate 4.1.3 和 4.0.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
4

1 回答 1

2

在 hibernate.cfg.xml 的 session-factory 部分中删除 name 参数后,一切都开始工作而没有“循环依赖”错误。

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

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

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

变成:

<hibernate-configuration>
    <session-factory>
        ...
于 2012-05-28T22:36:43.273 回答