Hibernate / JBoss - 新服务上的“服务jboss-as具有循环依赖”()

时间:2012-05-28 09:48:23

标签: java hibernate jboss7.x

当试图打开Hibernate会话时,初始化新Hibernate配置的代码部分打破了“Service jboss-as has a circular dependency”异常。

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

尝试了用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

1 个答案:

答案 0 :(得分:2)

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

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

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

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

更改为:

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