5 Replies Latest reply on May 28, 2012 5:03 AM by alesky78

    as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2

    alesky78

      hi guys

       

      i have a problem making a portin to an application wirted in  tomcat and now i'm doing a porting for jboss as 7.1

       

      the application use jpa and hibernate

      the jpa versione is 1.0 and hibernate 3.4

       

      the problme is that when i deployed the application and the entity manager is created

      i get this errore

       

      Caused by: java.lang.AbstractMethodError

        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:632) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) [spring-orm-3.0.0.RELEASE.jar:3.0.0.RELEASE]

       

      as you can see bottom is clear that the persistence configuration file it aspect to have version 2.0 and not 1.0 has is described in my configurations files...

      but in my web applciation inside the lib folder there are the jar related the the correct version of hibernate that are hiberate 3.4

      but it use the enityt manager implementation that is not bundled in my ear

       

      reading the documentation i undestand that this sould be an automatic dependences becouse in one of my class i defined the annotation @PersistenceContext

      https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

       

      thats mean that i have to define

      jboss-deployment-structure.xml. configuration file to avoid to load the hibernate dependences loaded in jboss as7?

      is this correct someone can give my confirm about this?

       

       

       

      Error parsing XML (7) : cvc-complex-type.3.1: Value '1.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '2.0'.

      15:53:10,335 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-7) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@72ad15e6: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.CommonAnnotationBeanPostProcessor#0,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#1,org.springframework.aop.config.internalAutoProxyCreator,coDataSource,coEntityManagerFactory,coTransactionManager,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,cityDao,zipCodeDao,countryDao,documentDao,regionDao,languageDao,districtDao,civicStatusDao,titleDao,edDegreeDao,documentTypeDao,headBranchDao,residenceTypeDao,salaryRangeDao,accountCurrencyTypeDao,accountOfficerDao,employmentTypeDao,employmentStatusDao,occupationDao,jobTitleDao,bankDao,branchDao,supDao,linkTypeDao,sectorDao,areaDao,subCodeDao,customerLanguageDao,validationRulesDao,mappingEngineManager,mappingLoader,mappingRepository,paramProvider,fixParamProcessor,listParamProcessor,mapParamProcessor,pojoParamProcessor,commareaParamProcessor,MappingTransformerEntityToModel,MappingTransformerModelToEntity,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#2,configurationBuilder,createNewCustomerMulePublisher,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#3,beanValidator,scanner,kBase,statelessKSession,kAgent,org.springframework.context.annotation.CommonAnnotationBeanPostProcessor#1,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#4,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#5,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#1,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#6,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#7,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#8,pdsClientExceptionFactory,pdsClientExceptionHelper,pdsClientMessageHelper,pdsClientMessageRepository,pdsAxi2ClientRedirectService,exceptionFactory,exceptionHelper,messageHelper,messageRepository,dateUtil,customerLanguageConfigService,countryService,documentService,regionService,areaService,languageService,civilStatusService,districtService,edDegreeService,sectorService,subCodeService,titleService,branchService,cityService,employerService,residenceTypeService,salaryRangeService,accountCurrencyTypeService,accountOfficerService,bankService,validationRulesService,supService,zipCodeService,poBoxService,linkTypeService,customerOriginationService,pdsIntegrationService,wfIntegrationService,contextBean,wfRelation,wfEngine,cifEjb,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#9,defaultValuesPresentationBean]; root of factory hierarchy

      15:53:10,362 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-7) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'coEntityManagerFactory' defined in URL [vfs:/C:/jboss/jboss-as-7.1.1.Final/standalone/deployments/EarTest.ear/co.web.war.war/WEB-INF/lib/co.business.orm-1.0.jar/config/spring/dao/co-orm-jpa-context.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) [spring-context-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416) [spring-context-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261) [spring-web-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192) [spring-web-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_31]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]

      Caused by: java.lang.AbstractMethodError

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:632) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) [spring-orm-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:288) [spring-orm-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398) [spring-beans-3.0.0.RELEASE.jar:3.0.0.RELEASE]

                ... 20 more

        • 1. Re: as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2
          alesky78

          no i create an ear with my war and i have create a jboss-deployment-structure.xml in the meta-inf of the ear

           

          so:

           

          EAR

                    WAR

                         myapp class page etc...

                    META-INF

                         jboss-deployment-structure.xml

           

           

          this is my jboss-deployment-structure.xml file

           

          <?xml version="1.0" encoding="UTF-8"?>

          <jboss-deployment-structure>

                    <deployment>

                              <exclusions>

                                        <module name="org.jboss.as.jpa" slot="main"/>

                                        <module name="org.hibernate" slot="main"/>

                              </exclusions>

                    </deployment>

          </jboss-deployment-structure>

           

          i don't think i should remove org.jboss.as.jpa but only org.hibernate but i din't have any result the exception is always the same

           

          Caused by: java.lang.AbstractMethodError

                    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:632) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

           

          probably the module name attribute is not correct?

            <module name="org.hibernate" slot="main"/>

          i tryed also substituting with

          <module name="org.hibernate" slot="4.0.1"/>

           

          again same issue

          • 2. Re: as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2
            sfcoy

            We successfully deploy WAR files that use Hibernate 3.4 and Spring 3.0.x to JBoss AS 7.1.x by just adding:

            {code:xml}

            <?xml version="1.0" encoding="UTF-8"?>

            <classloading xmlns="urn:jboss:classloading:1.0"

                domain="myapp-web"

                parent-domain="DefaultDomain"

                export-all="NON_EMPTY"

                import-all="true"

                parent-first="false"

                excluded="org.apache.log4j,org.slf4j"

                >

                <!-- Forces the use of JBoss provided log4j and slf4j implementations -->

            </classloading>

            {code}

            to the WEB-INF directory.

            • 3. Re: as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2
              alesky78

              Thanks Stephen

               

              your environment is like mine

              Hibernate 3.4 and Spring 3.0.x to JBoss AS 7.1.x

               

              regaring the file that you propose to add in the WEB-INF

               

              what is the name of the file?

              jboss-classloading.xml

               

              I tryed with this name but again same issue


              Caused by: java.lang.AbstractMethodError

                        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:632) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

               

               

               

               



              • 4. Re: as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2
                sfcoy

                That's the correct name. Did you get rid of all the other changes that you made for AS 7?

                • 5. Re: as7.1 how to avoid to import automatic dependences related to hiberate 4 and jpa 2
                  alesky78

                  yes

                  i removede the jboss-deployment-structure.xml that was the only change i did