13 Replies Latest reply on Jan 2, 2012 8:10 AM by cristhiank

    Hibernate 3 + Spring 3 error on deployment

    Sebastian Otaegui Newbie

      Hello,

       

      I am trying to make liferay portal run on AS 7 (I am using the latest 7.1.0.Alpha1-SNAPSHOT).

       

      I got around some bumps at the beggining.

       

      liferay requires some dependencies to be "in the lib/ext" so I created a module (through trial and error) and have these two that I needed:

       

      modules/com/liferay/portal/main/module.xml

      {code:xml}<module xmlns="urn:jboss:module:1.0" name="com.liferay.portal">

        <resources>

          <resource-root path="portal-service-6.0.6.jar"/>

          <resource-root path="portlet-6.0.6.jar"/>

          <!-- Insert resources here -->

        </resources>

       

       

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.servlet.api"/>

          <module name="javax.servlet.jsp.api"/>

        </dependencies>

      </module>{code}

      and also

       

      modules/org/hsqldb/main/module.xml (this is an in memory database driver)

      {code:xml}<module xmlns="urn:jboss:module:1.0" name="org.hsqldb">

        <resources>

          <resource-root path="hsql.jar"/>

              <!-- Insert resources here -->

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

        </dependencies>

      </module>{code}

       

      Now I am getting this error that seems to be caused by liferay using the hibernate 4 beta1 lib instead of the hibernate3.jar that is in its WEB-INF/lib

       

       

      {quote}Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]

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

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

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

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

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

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

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

                at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) [spring-beans.jar:]

                ... 76 more

      Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:170) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:137) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:118) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:208) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:85) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.BasicServiceRegistryImpl.configureService(BasicServiceRegistryImpl.java:80) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:143) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:118) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:68) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2251) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2247) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1718) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1756) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860) [spring-orm.jar:]

                at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779) [spring-orm.jar:]

                at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) [spring-orm.jar:]

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

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

                ... 83 more

      Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider]

                at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:190) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:112) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.BasicServiceRegistryImpl.initiateService(BasicServiceRegistryImpl.java:68) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:160) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                ... 100 more

      Caused by: java.lang.ClassCastException: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider

                at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:187) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]

                ... 104 more{quote}

       

       

      So if my conclusion is correct, the question is, how do I force my application to "not see" hibernate4 from the server and use the hibernate3 that is provided in the WEB-INF/lib

       

      I am attaching the full server log.

       

      Thanks in advance

       

      PS: The same exact error is obtained in CR1

        • 1. Re: Hibernate 3 + Spring 3 error on deployment
          Stuart Douglas Master

          I don't think this is possible yet, although I know Scott Marlow is working on a solution to enable hibernate 3 apps to work on AS7.

           

          Last I heard this will take the form of a jar that can be dropped into the application, so it should not require you to wait for a new release of the AS.

          1 of 1 people found this helpful
          • 2. Re: Hibernate 3 + Spring 3 error on deployment
            Sebastian Otaegui Newbie

            It would be nice to have a way of deploying a module with hibernate3 if that is possible at all.

             

            Or have a way to make an application "not see" a module (in this case the hibernate 4 jars) or something like that.

             

            Otherwise the duplication of the hibernate jar files in the war files (portlets) in a portal like liferay is cumbersome, I have some environments that have +10 portlets, that is ~39mb of jar files at the very least.

             

            I also have common libraries that provide daos for all the portlets and if I could deploy them as modules (and those rely on spring and hibernate) would make my life easier.

             

            We are currently running EAP 4.3, and my plan was to start moving to EAP 6 a couple of months after it is released but seeing this I am kind of losing my optimism.

            • 3. Re: Hibernate 3 + Spring 3 error on deployment
              Scott Marlow Master

              Sebastian,

               

              Jiras AS7-647 (https://issues.jboss.org/browse/AS7-647) and AS7-574 cover the idea of deploying Hibernate 3 in some fashion (as part of the application and possibly as a module).  I started to restructure the existing JPA container/subsystem code into separate modules to support this effort.  You could register to watch those jiras if you like and when they are fixed, you will get a notification.

               

              For the part of getting AS7 to ignore certain parts of the application (e.g. persistence.xml definitions or PersistenceContext/Unit annotations/descriptors), I'm not sure if there is a jira for that yet (perhaps that would be about implementing something like support for "jboss-ignore.txt" that we had in earlier AS releases).

               

              Scott

              • 4. Re: Hibernate 3 + Spring 3 error on deployment
                Scott Marlow Master

                I was just reading https://docs.jboss.org/author/display/AS7/Spring+applications+development+and+migration+guide.  See the part about "jboss-deployment-structure" to prevent the Hibernate 4 modules from being injected into the application.  That sounds like it might help you.

                 

                Also see http://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7 for more on "jboss-deployment-structure.

                1 of 1 people found this helpful
                • 5. Re: Hibernate 3 + Spring 3 error on deployment
                  Jason Greene Master

                  Exclusions are the correct way to isolate your app from the hibernate dep that gets add. Although note that if the dep is getting added it means somewhere in your app you are using JPA injection @PersistenceContext etc.

                   

                  If you are using JPA and you add an exclusion to the module/subddeployment using it, JPA will not function correctly because the JPA generated proxies need access to hibernate.

                   

                  On the other hand if you are using spring managed JPA (which is not actually spec JPA) then you want to look at the spring migration guide linked above.

                  • 6. Re: Hibernate 3 + Spring 3 error on deployment
                    Sebastian Otaegui Newbie

                    After adding this to my liferay war file I could go a bit further:

                    {code:xml}

                    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                      <deployment>

                        <exclusions>

                           <module name="org.hibernate"/>

                        </exclusions>

                        <dependencies>

                            <module name="com.liferay" />

                            <module name="org.hsqldb" />

                        </dependencies>

                      </deployment>

                    </jboss-deployment-structure>

                    {code}

                     

                    and I get this stacktrace below, any idea?

                     

                     

                    {quote}

                    01:46:41,385 INFO  [stdout] (MSC service thread 1-4) Loading file:/home/otaeguis/dev/jboss-as-web-7.0.0.Final/standalone/deployments/liferay.war/WEB-INF/classes/portal.properties

                    01:46:45,137 INFO  [stdout] (MSC service thread 1-4) 01:46:45,134 INFO  [DialectDetector:69] Determining dialect for HSQL Database Engine 1

                    01:46:45,139 INFO  [stdout] (MSC service thread 1-4) 01:46:45,138 WARN  [DialectDetector:84] Liferay is configured to use Hypersonic as its database. Do NOT use Hypersonic in production. Hypersonic is an embedded database useful for development and demo'ing purposes. The database settings can be changed in portal.properties.

                    01:46:45,182 INFO  [stdout] (MSC service thread 1-4) 01:46:45,181 INFO  [DialectDetector:49] Using dialect org.hibernate.dialect.HSQLDialect

                    01:46:46,301 INFO  [stdout] (MSC service thread 1-4) 01:46:46,299 ERROR [ContextLoader:220] Context initialization failed

                    01:46:46,302 INFO  [stdout] (MSC service thread 1-4) org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferaySessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Cannot create inner bean 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' of type [com.liferay.portal.kernel.util.PortalClassLoaderUtil] while setting bean property 'sessionFactoryClassLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' defined in class path resource [META-INF/hibernate-spring.xml]: Initialization of bean failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    01:46:46,302 INFO  [stdout] (MSC service thread 1-4)  [Xlint:cantFindType]

                    01:46:46,302 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

                    01:46:46,303 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:575)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

                    01:46:46,304 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:47)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)

                    01:46:46,305 INFO  [stdout] (MSC service thread 1-4)           at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)           at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)           at java.lang.Thread.run(Thread.java:662)

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' defined in class path resource [META-INF/hibernate-spring.xml]: Initialization of bean failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)  [Xlint:cantFindType]

                    01:46:46,306 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)

                    01:46:46,311 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

                    01:46:46,311 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)

                    01:46:46,311 INFO  [stdout] (MSC service thread 1-4)           ... 24 more

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4) Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)  [Xlint:cantFindType]

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129)

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.Lint$Kind.signal(Lint.java:316)

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getSuperclass(MissingResolvedTypeWithKnownSignature.java:98)

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:144)

                    01:46:46,312 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.patterns.OrPointcut.fastMatch(OrPointcut.java:47)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:82)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:233)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)

                    01:46:46,313 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1418)

                    01:46:46,314 INFO  [stdout] (MSC service thread 1-4)           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

                    01:46:46,315 INFO  [stdout] (MSC service thread 1-4)           ... 26 more

                    01:46:46,315 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-4) Exception sending context initialized event to listener instance of class com.liferay.portal.spring.context.PortalContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferaySessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Cannot create inner bean 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' of type [com.liferay.portal.kernel.util.PortalClassLoaderUtil] while setting bean property 'sessionFactoryClassLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' defined in class path resource [META-INF/hibernate-spring.xml]: Initialization of bean failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    [Xlint:cantFindType]

                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281) [spring-beans.jar:]

                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120) [spring-beans.jar:]

                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317) [spring-beans.jar:]

                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076) [spring-beans.jar:]

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

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

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

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

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

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

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

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

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

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

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

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

                              at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:47) [portal-impl.jar:]

                              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

                              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]

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

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

                              at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

                              at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

                    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.util.PortalClassLoaderUtil#385144d5' defined in class path resource [META-INF/hibernate-spring.xml]: Initialization of bean failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    [Xlint:cantFindType]

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

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

                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [spring-beans.jar:]

                              ... 24 more

                    Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type org.jboss.modules.ModuleClassLoader

                    [Xlint:cantFindType]

                              at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.Lint$Kind.signal(Lint.java:316) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getSuperclass(MissingResolvedTypeWithKnownSignature.java:98) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:144) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.patterns.OrPointcut.fastMatch(OrPointcut.java:47) [aspectj-weaver.jar:]

                              at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:82) [aspectj-weaver.jar:]

                              at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:233) [spring-aop.jar:]

                              at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200) [spring-aop.jar:]

                              at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254) [spring-aop.jar:]

                              at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286) [spring-aop.jar:]

                              at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117) [spring-aop.jar:]

                              at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) [spring-aop.jar:]

                              at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68) [spring-aop.jar:]

                              at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359) [spring-aop.jar:]

                              at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) [spring-aop.jar:]

                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) [spring-beans.jar:]

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

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

                              ... 26 more

                     

                     

                    01:46:46,420 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Error listenerStart

                    01:46:46,420 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [] startup failed due to previous errors

                    01:46:46,438 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-4) Closing Spring root WebApplicationContext

                    01:46:46,441 INFO  [stdout] (MSC service thread 1-4) 01:46:46,441 INFO  [HotDeployUtil:69] Initializing hot deploy manager 888448950

                    01:46:46,442 INFO  [stdout] (MSC service thread 1-4) 01:46:46,442 INFO  [HotDeployUtil:69] Initializing hot deploy manager 707705059

                    01:46:46,451 INFO  [org.jboss.web] (MSC service thread 1-4) registering web context:

                    01:46:46,510 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "liferay.war"

                    {quote}

                     

                     

                    The hibernate-spring.xml

                     

                    {code:xml}

                    <beans

                        default-destroy-method="destroy"

                        default-init-method="afterPropertiesSet"

                        xmlns="http://www.springframework.org/schema/beans"

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"

                    >

                        <bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortalHibernateConfiguration">

                            <property name="dataSource" ref="liferayDataSource" />

                        </bean>

                        <bean id="liferaySessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl">

                            <property name="sessionFactoryClassLoader">

                                <bean class="com.liferay.portal.kernel.util.PortalClassLoaderUtil" factory-method="getClassLoader" />

                            </property>

                            <property name="sessionFactoryImplementor" ref="liferayHibernateSessionFactory" />

                        </bean>

                        <bean id="liferayTransactionManager" class="com.liferay.portal.spring.transaction.TransactionManagerFactory" factory-method="createTransactionManager">

                            <constructor-arg ref="liferayDataSource" />

                            <constructor-arg ref="liferayHibernateSessionFactory" />

                        </bean>

                        <bean id="hibernateStatisticsService" class="com.liferay.portal.dao.orm.hibernate.jmx.HibernateStatisticsService">

                            <property name="sessionFactory" ref="liferaySessionFactory" />

                        </bean>

                        <bean id="hibernateMBeanExporter" class="org.springframework.jmx.export.MBeanExporter">

                            <property name="beans">

                                <map>

                                    <entry key="Hibernate:name=statistics">

                                        <ref local="hibernateStatisticsService" />

                                    </entry>

                                </map>

                            </property>

                            <property name="server" ref="mBeanServer" />

                        </bean>

                        <bean id="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil" class="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil">

                            <property name="dynamicQueryFactory">

                                <bean class="com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl" />

                            </property>

                        </bean>

                        <bean id="com.liferay.portal.kernel.dao.orm.OrderFactoryUtil" class="com.liferay.portal.kernel.dao.orm.OrderFactoryUtil">

                            <property name="orderFactory">

                                <bean class="com.liferay.portal.dao.orm.hibernate.OrderFactoryImpl" />

                            </property>

                        </bean>

                        <bean id="com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil" class="com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil">

                            <property name="projectionFactory">

                                <bean class="com.liferay.portal.dao.orm.hibernate.ProjectionFactoryImpl" />

                            </property>

                        </bean>

                        <bean id="com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil" class="com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil">

                            <property name="propertyFactory">

                                <bean class="com.liferay.portal.dao.orm.hibernate.PropertyFactoryImpl" />

                            </property>

                        </bean>

                        <bean id="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil" class="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil">

                            <property name="restrictionsFactory">

                                <bean class="com.liferay.portal.dao.orm.hibernate.RestrictionsFactoryImpl" />

                            </property>

                        </bean>

                    </beans>

                    {code}

                     

                    META-INF/persistence-custom.xml

                     

                    {code:xml}

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

                    <persistence

                        version="1.0"

                        xmlns="http://java.sun.com/xml/ns/persistence"

                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

                    >

                        <persistence-unit name="LiferayPersistence" transaction-type="RESOURCE_LOCAL">

                            <exclude-unlisted-classes>true</exclude-unlisted-classes>

                        </persistence-unit>

                    </persistence>

                    {code}

                     

                    Any Idea? I am kind of lost.

                     

                    Thanks in advance

                    • 7. Re: Hibernate 3 + Spring 3 error on deployment
                      Sebastian Otaegui Newbie

                      By recommendation of David Lloyd I added a dependency in the jboss-deployment-structure.xml to org.jboss.modules but now it shows:

                       

                      {quote}

                      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mBeanServer': Post-processing of the FactoryBean's object failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type com.sun.jmx.mbeanserver.JmxMBeanServer

                      [Xlint:cantFindType]

                       

                      {quote}

                       

                      I could not find com.sun.jmx.mbeanserver.JmxMBeanServer in the modules provided but that is part of the jvm.

                      • 8. Re: Hibernate 3 + Spring 3 error on deployment
                        Stuart Douglas Master

                        This post: http://community.jboss.org/message/616226#616226 explains how to get access to JVM classes that are hidden by JBoss modules.

                        • 9. Re: Hibernate 3 + Spring 3 error on deployment
                          Sebastian Otaegui Newbie

                          I am one step further.

                           

                          I created the module as instructed in the document you pointed out and the jmx part didnt complain again.

                           

                          Now I am having this error:

                           

                          {quote}

                          15:44:26,870 INFO  [stdout] (MSC service thread 1-2) 15:44:26,868 ERROR [PortalInstances:354] com.liferay.portal.kernel.exception.SystemException: com.liferay.util.EncryptorException: java.lang.ClassNotFoundException: com.sun.crypto.provider.SunJCE from [Module "deployment.liferay.war:main" from Service Module Loader]

                           

                          {quote}

                           

                          and I added <include path="com/sun/crypto"/> as I did with the com.sun.jmx and didn't work do I have to do something special for com.sun.crypto ?

                           

                          What is happening now is not making a lot of sense.

                           

                          This is my jboss-deployment-structure.xml

                          {code:xml}

                          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                            <deployment>

                              <exclusions>

                                 <module name="org.hibernate"/>

                              </exclusions>

                              <dependencies>

                                  <module name="com.liferay" />

                                  <module name="org.hsqldb" />

                                  <module name="org.jboss.modules" />

                                  <module name="javax.mail.api" />

                                  <module name="system" export="false">
                                      <imports>

                                          <include path="com/sun/jmx"/>

                                          <include path="com/sun/crypto"/>

                                          <exclude path="/**" />
                                      </imports>
                                  </module>
                              </dependencies>

                            </deployment>

                          </jboss-deployment-structure>

                          {code}

                           

                           

                           

                          Thanks in advance

                          • 10. Re: Hibernate 3 + Spring 3 error on deployment
                            Sebastian Otaegui Newbie

                            Is there anything special that has to be done to see the com/sun/crypto classes?

                            • 11. Re: Hibernate 3 + Spring 3 error on deployment
                              jaikiran pai Master

                              java.lang.ClassNotFoundException: com.sun.crypto.provider.SunJCE

                              Sebastian Otaegui wrote:

                               

                              
                                      <module name="system" export="false">            
                                           <imports>                 <include path="com/sun/jmx"/>                 <include path="com/sun/crypto"/>

                              From what I know, the include path is not recursive. So try changing it to (or a variation of that):

                               

                              <include path="com/sun/crypto/**"/>  

                              • 12. Re: Hibernate 3 + Spring 3 error on deployment
                                Sebastian Otaegui Newbie

                                The solution was a bit more complex to find (for me) than that but the solution is simple

                                 

                                the com.sun.crypto.provider.SunJCE class is part of the <JAVA_HOME>jre/lib/ext directory

                                 

                                In order scan and load the ext directory I needed to add a MANIFEST.MF to my war file with the following content:

                                Extension-List: crypto

                                crypto-Extension-Name: javax.crypto

                                 

                                With that in my web project it scans the ext dir and then finds the sunjce_provider.jar that has a MANIFEST.MF that declares:

                                 

                                {noformat}

                                Manifest-Version: 1.0

                                Implementation-Vendor: Sun Microsystems, Inc.

                                Implementation-Version: 1.6

                                Implementation-Vendor-Id: com.sun

                                Specification-Vendor: Sun Microsystems, Inc.

                                Created-By: 1.6.0 (Sun Microsystems Inc.)

                                Specification-Version: 1.6

                                Extension-Name: javax.crypto

                                 

                                (...)snip(...)

                                {noformat}

                                 

                                and loads it.

                                 

                                so the end result is the following my jboss-deployment-structure.xml looked like this:

                                {code:xml}

                                <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                                  <deployment>

                                    <exclusions>

                                       <module name="org.hibernate"/>

                                    </exclusions>

                                    <dependencies>

                                        <module name="com.liferay" />

                                        <module name="org.hsqldb" />

                                        <module name="org.jboss.modules" />

                                        <module name="system" export="false">

                                            <imports>

                                                <include path="com/sun/jmx"/>

                                                <exclude path="/**" />

                                            </imports>

                                        </module>

                                    </dependencies>

                                  </deployment>

                                </jboss-deployment-structure>

                                {code}

                                 

                                and the MANIFEST.MF looks like this:

                                 

                                {noformat}

                                Manifest-Version: 1.0

                                Ant-Version: Apache Ant 1.8.1

                                Created-By: 1.6.0_24-b07 (Oracle Corporation)

                                Extension-List: crypto

                                crypto-Extension-Name: javax.crypto

                                 

                                {noformat}

                                 

                                (note that there is a '\n' after javax.crypto)

                                 

                                Thanks to Stuart Douglas for his help

                                • 13. Re: Hibernate 3 + Spring 3 error on deployment
                                  cristhiank Newbie

                                  Hello,

                                   

                                  I'm facing the same issue with JBoss AS 7.1 CR1b release, In this release de system module have been removed and the Extension-List is not working for me, hope you can help me.

                                  This is my stacktrace

                                   


                                  {code}

                                  08:08:36,685 WARN  [org.jboss.as.server.deployment.service-loader] (MSC service thread 1-3) Encountered invalid class name "org.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer" for service type "org.xmlpull.v1.XmlPullParserFactory"

                                  08:08:38,561 WARN  [org.jboss.as.server.deployment.module.module-extension-list-processor] (MSC service thread 1-1) Could not find Extension-List entry ExtensionListEntry [name=javax.crypto, title=crypto] referenced from ResourceRoot [root="/D:/Development/Servers/jboss-as-7.1.0.CR1b/content/ROOT.war/WEB-INF/classes"]

                                  08:08:57,386 ERROR [com.liferay.portal.kernel.process.ClassPathUtil] (MSC service thread 1-2) Class com.liferay.portal.servlet.MainServlet is not loaded from a standard location (/WEB-INF/classes)

                                  08:09:38,808 INFO  [com.liferay.portal.spring.hibernate.DialectDetector] (MSC service thread 1-2) Determine dialect for MySQL 5

                                  08:09:38,845 INFO  [com.liferay.portal.spring.hibernate.DialectDetector] (MSC service thread 1-2) Found dialect org.hibernate.dialect.MySQLDialect

                                  08:09:39,365 INFO  [com.liferay.portal.cache.ehcache.LiferayCacheManagerPeerProviderFactory] (MSC service thread 1-2) portalPropertyKey net.sf.ehcache.configurationResourceName.peerProviderProperties has value peerDiscovery=automatic,multicastGroupAddress=239.255.0.4,multicastGroupPort=23304,timeToLive=1

                                  {code}