How to configure HIbernate in AS7
samwun9988 Sep 3, 2011 9:53 AMHi,
I got the following error when I deployed a WAR file based on hibernate.
23:49:15,546 INFO [org.jboss.jpa] (MSC service thread 1-1) read persistence.xml for HousewareCategoryPU
23:49:15,548 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added javax.persistence.api, javaee.api, org.jboss.as.jpa, org.javassist dependencies to category-ws-0.0.1-SNAPSHOT.war
23:49:15,548 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added (default provider) org.hibernate dependency to application deployment (since 1 PU(s) didn't specify jboss.as.jpa.providerModule)
23:49:15,548 INFO [org.jboss.as.jpa] (MSC service thread 1-2) added org.hibernate dependency to application deployment
23:49:15,581 INFO [org.jboss.wsf.stack.cxf.deployment.aspect.DescriptorDeploymentAspect] (MSC service thread 1-8) Spring not available, skipping check for user provided jbossws-cxf.xml / cxf.xml configuration files.
23:49:15,582 INFO [org.jboss.wsf.stack.cxf.metadata.MetadataBuilder] (MSC service thread 1-8) Add Service
id=CXFCategoryServlet
address=http://localhost:80/category-ws-0.0.1-SNAPSHOT/services
implementor=ix.houseware.category.service.CreateCategoryImpl
invoker=org.jboss.wsf.stack.cxf.JBossWSInvoker
serviceName={http://service.category.houseware.ix/}CreateCategoryImplService
portName={http://service.category.houseware.ix/}CreateCategoryImplPort
wsdlLocation=null
mtomEnabled=false
23:49:15,582 INFO [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-8) register: jboss.ws:context=category-ws-0.0.1-SNAPSHOT,endpoint=CXFCategoryServlet
23:49:15,588 INFO [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-8) Creating Service {http://service.category.houseware.ix/}CreateCategoryImplService from class ix.houseware.category.service.CreateCategory
23:49:15,611 INFO [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-8) Setting the server's publish address to be http://localhost:80/category-ws-0.0.1-SNAPSHOT/services
23:49:15,613 WARN [org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver] (MSC service thread 1-8) Cannot resolve resource: cxf
23:49:15,620 INFO [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-8) WSDL published to: file:/usr/local/users/jboss/jboss71A/standalone/data/wsdl/category-ws-0.0.1-SNAPSHOT.war/CreateCategoryImplService.wsdl
23:49:15,627 INFO [org.jboss.as.jpa] (MSC service thread 1-8) Deployment has its own Persistence Provider class org.hibernate.ejb.HibernatePersistence
23:49:15,635 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
23:49:15,636 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
23:49:15,636 WARN [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) Unable to instantiate driver class "com.mysql.jdbc.Driver": org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.category-ws-0_0_1-SNAPSHOT_war is already registered
23:49:15,638 INFO [org.jboss.as.webservices.service.EndpointService] (MSC service thread 1-2) Starting service jboss.ws.endpoint."category-ws-0.0.1-SNAPSHOT".CXFCategoryServlet
23:49:15,638 INFO [org.jboss.jpa] (MSC service thread 1-3) starting Persistence Unit Service 'category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU'
23:49:15,639 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) HHH00204:Processing PersistenceUnitInfo [
name: HousewareCategoryPU
...]
23:49:15,646 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-3) HHH00194:Package not found or wo package-info.java: ix.houseware.category.service
23:49:15,647 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-3) HHH00194:Package not found or wo package-info.java: ix.houseware.category.bean
23:49:15,647 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-3) HHH00194:Package not found or wo package-info.java: ix.houseware.category.common
23:49:15,647 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-3) HHH00194:Package not found or wo package-info.java: ix.houseware.category.base
23:49:15,647 WARN [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-3) HHH00194:Package not found or wo package-info.java: ix.houseware.category.Enum
23:49:15,654 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-3) HHH00130:Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
23:49:15,661 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-3) HHH00400:Using dialect: org.hibernate.dialect.MySQLDialect
23:49:15,661 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-3) HHH00268:Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
23:49:15,662 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-3) HHH00397:Using ASTQueryTranslatorFactory
23:49:15,667 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.persistenceunit."category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [:1.6.0_03-p4]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [:1.6.0_03-p4]
at java.lang.Thread.run(Thread.java:619) [:1.6.0_03-p4]
Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)
at org.dom4j.DocumentHelper.getDocumentFactory(DocumentHelper.java:36)
at org.dom4j.DocumentHelper.createDocument(DocumentHelper.java:41)
at org.hibernate.envers.configuration.RevisionInfoConfiguration.generateDefaultRevisionInfoXmlMapping(RevisionInfoConfiguration.java:86)
at org.hibernate.envers.configuration.RevisionInfoConfiguration.configure(RevisionInfoConfiguration.java:322)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:94)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:134)
at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:63)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1720)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:894)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:879)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143)
at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
... 3 more
23:49:15,872 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployment of "category-ws-0.0.1-SNAPSHOT.war" was rolled back with failure message {"Failed services" => {"jboss.persistenceunit.\"category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU\": Failed to start service"}}
23:49:15,874 INFO [org.jboss.as.webservices.service.EndpointService] (MSC service thread 1-8) Stopping service jboss.ws.endpoint."category-ws-0.0.1-SNAPSHOT".CXFCategoryServlet
23:49:15,876 WARN [org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver] (MSC service thread 1-2) Cannot resolve resource: org.apache.cxf.ws.rm.RMManager/bus
23:49:15,879 INFO [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-2) remove: jboss.ws:context=category-ws-0.0.1-SNAPSHOT,endpoint=CXFCategoryServlet
23:49:15,889 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) Stopped deployment category-ws-0.0.1-SNAPSHOT.war in 16ms
23:49:15,890 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Failed services" => {"jboss.persistenceunit.\"category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"category-ws-0.0.1-SNAPSHOT.war#HousewareCategoryPU\": Failed to start service"}}}}
Here is my pom.xml file:
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.15</version>
<type>jar</type>
</dependency>
</dependencies>
Any suggestion and pointers to document is very apprciated.
Thanks
Sam