Announcement Announcement Module
Collapse
No announcement yet.
JBoss problems when integrating hibernate with spring mvc Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JBoss problems when integrating hibernate with spring mvc

    For some reason I can't post what I wanted as the forum thinks it has a url in it so I need to make 1 post (hopefully this) before I can post my question so bear with me...

  • #2
    Hi,

    Hopefully this will be something stupid I've done being a spring newb but I'm putting together an online timesheet system with spring mvc and hibernate. The MVC parts all worked fine until I started to integrate hibernate. When I add a bean for my session factory like this...

    Code:
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="myDataSource"/>
    		<property name="mappingResources">
    			<list>
    				<value>contract.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<value>hibernate.dialect=org.hibernate.dialect.HSQLDialect</value>
    		</property>
    	</bean>
    ...and deploy to JBoss, JBoss freezes during deployment at this point...

    Code:
    2009-03-05 19:16:46,328 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/timesheet]] (main) Initializing Spring root WebApplicationContext
    2009-03-05 19:16:46,328 INFO  [org.springframework.web.context.ContextLoader] (main) Root WebApplicationContext: initialization started
    2009-03-05 19:16:46,390 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (main) Refreshing [email protected]578f3f: display name [Root WebApplicationContext]; startup date [Thu Mar 05 19:16:46 GMT 2009]; root of context hierarchy
    2009-03-05 19:16:46,546 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (main) Loading XML bean definitions from ServletContext resource [/WEB-INF/timesheet-data.xml]
    2009-03-05 19:16:46,671 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (main) Loading XML bean definitions from ServletContext resource [/WEB-INF/timesheet-persistence.xml]
    2009-03-05 19:16:46,718 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (main) Loading XML bean definitions from ServletContext resource [/WEB-INF/timesheet-servlet.xml]
    2009-03-05 19:16:46,750 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (main) Loading XML bean definitions from ServletContext resource [/WEB-INF/timesheet-security.xml]
    2009-03-05 19:16:47,171 INFO  [org.springframework.security.userdetails.memory.UserMap] (main) Adding user [org.springframework.security.userdetails.User@fe877a00: Username: mark; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER]
    2009-03-05 19:16:47,171 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (main) Bean factory for application context [[email protected]578f3f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@6edcf4
    2009-03-05 19:16:47,375 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (main) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6edcf4: defining beans [contractManager,myDataSource,mySessionFactory,hibernateTemplate,messageSource,viewResolver,/login.htm,/contracts.htm,/createContract.htm,_authenticationManager,_filterChainProxy,_httpSessionContextIntegrationFilter,_filterChainProxyPostProcessor,_filterChainList,_securityContextHolderAwareRequestFilter,_accessManager,_portMapper,_exceptionTranslationFilter,_filterSecurityInterceptor,_sessionFixationProtectionFilter,_anonymousAuthenticationProvider,_anonymousProcessingFilter,_rememberMeServices,_rememberMeAuthenticationProvider,_rememberMeFilter,_rememberMeServicesInjectionBeanPostProcessor,_logoutFilter,_basicAuthenticationEntryPoint,_basicAuthenticationFilter,_formLoginFilter,_formLoginEntryPoint,_entryPointInjectionBeanPostProcessor,_userServiceInjectionPostProcessor,org.springframework.security.providers.dao.DaoAuthenticationProvider#0,org.springframework.security.userdetails.memory.InMemoryDaoImpl#0,org.springframework.security.config.AuthenticationProviderBeanDefinitionParser$AuthenticationProviderCacheResolver#0]; root of factory hierarchy
    ...and then it just sits there. If I turn the logging level to debug I can see that the bean it stalls at is my session factory.

    This is a clean install of JBoss-5.0.1.GA, I'm using Spring 2.5.6 and Hibernate 3.2. The hibernate jar files are deployed with the web application under web-inf/lib. My db is hsqldb 1.8.0.10 running in server mode. The data source I'm using looks like this...

    Code:
    	<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    		<property name="url" value="jdbc:hsqldb:hsql://localhost/timesheetdb"/>
    		<property name="username" value="sa"/>
    		<property name="password" value=""/>
    	</bean>
    ...and the connection url works fine for the squirrel client.

    Any ideas what's going on and/or what I can try to 'unstick' JBoss? Incidentally, if I remove the session factory bean and leave all others in (including the data source) the web app deploys happily.

    Thanks,

    Mark

    Comment


    • #3
      Bit more information...

      It seems to be stuck in a loop generating this output...

      Code:
      16:07:10,062 TRACE [BaseClassLoader] BaseClassLoader@dfa2ae{vfszip:/C:/dev/tools/java/jboss-5.0.1.GA/server/default/deploy/timesheet.war/} load class locally org.slf4j.ILoggerFactory
      16:07:10,062 TRACE [VFSClassLoaderPolicy] getProtectionDomain:className=org.slf4j.ILoggerFactory path=org/slf4j/ILoggerFactory.class codeSourceURL=jar:file:/C:/dev/tools/java/jboss-5.0.1.GA/server/default/deploy/timesheet.war!/WEB-INF/lib/s
      lf4j-api-1.5.2.jar
      16:07:10,062 TRACE [BaseClassLoader] BaseClassLoader@dfa2ae{vfszip:/C:/dev/tools/java/jboss-5.0.1.GA/server/default/deploy/timesheet.war/} getPackage org.slf4j
      16:07:10,062 TRACE [BaseClassLoader] BaseClassLoader@dfa2ae{vfszip:/C:/dev/tools/java/jboss-5.0.1.GA/server/default/deploy/timesheet.war/} already loaded package org.slf4j org.slf4j
      16:07:10,062 TRACE [ClassLoaderManager] Run failed with exception
      java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader)
       previously initiated loading for a different type with name "org/slf4jILoggerFactory"
              at java.lang.ClassLoader.defineClass1(Native Method)
              at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
              at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:63)
              at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:546)
              at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:506)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:504)
              at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:481)
              at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:134)
              at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)
              at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:452)
              at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:258)
              at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:152)
              at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:259)
              at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1102)
              at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:772)
              at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:415)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
              at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:169)
              at org.springframework.orm.hibernate3.LocalSessionFactoryBean.class$(LocalSessionFactoryBean.java:174)
              at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:174)
      I'm guessing that this is some kind of class path problem but can anyone shed any light on what is going on?

      Thanks,

      Mark

      Comment

      Working...
      X