Results 1 to 4 of 4

Thread: Hibernate unable to create SessionFactory

  1. #1
    Join Date
    Sep 2011
    Posts
    11

    Default Hibernate unable to create SessionFactory

    Hello,

    I am learning Spring and I am trying to create a small app in STS that uses Spring MVC and Hibernate. I am running into a problem where the Hibernate SessionFactory is not getting created when run (on JBOSS 5). I thought I have all the libraries included but perhaps there are some missing ones that I am not aware of? Here is the error message:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.LocalSessionFactoryBean


    Here are the relative beans in my servlet-context.xml file:
    Code:
    <!-- Connection to Database  -->   
    	<beans:bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    	<beans:property name ="driverClassName" value="org.hsqldb.jdbcDriver" />
    	<beans:property name = "url" value="jdbc:hsqldb:C:\SpringProjects\MVCProj1\database" />
    	<beans:property name = "username" value="ryan" />
    	<beans:property name = "password" value="ryan" />
    	</beans:bean>
    
    <!-- Hibernate SessionFactory -->
    	<beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">				   	
    		<beans:property name="dataSource" ref="datasource"></beans:property>
    		<beans:property name="configLocation" value="classpath:hibernate.cfg.xml"></beans:property>
    		<beans:property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"></beans:property>
    		<beans:property name="hibernateProperties" >
    			<beans:props>
    				<beans:prop key="hibernate.dialect">hibernate.dialect=org.hibernate.dialect.HSQLDialect</beans:prop>
    				<beans:prop key="hibernate.show_sql">true</beans:prop>
    			</beans:props>
    		</beans:property>
    	</beans:bean>



    Here is a screenshot of the project jars included:
    sts.jpg

    Any help for this newbie to Spring and Hibernate would be appreciated.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    You are mixing different strategies for managing dependencies I suggest sticking with one, let maven manage all of your dependencies.

    The fact that you are mixing strategies is also the root of your error, you are using extra libraries which aren't exposed to the web container (WEB-INF/lib) and thus your spring-hibernate classes aren't found.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Sep 2011
    Posts
    11

    Default

    Thank you very much. Now when I run the application, I get this error message:

    Code:
    error in script file line: 1 Unexpected token UNIQUE, requires COLLATION in statement [SET DATABASE UNIQUE]
    Any idea what that means?

  4. #4
    Join Date
    Sep 2011
    Posts
    11

    Default

    Ok I think I resolved that error. I found information about updating the hsqldb.jar file for JBoss. That link is here: http://stackoverflow.com/questions/4...atabase-unique

    Now I have a new problem (of course), the JBoss server (ver. 5.01) is showing this error:
    Code:
    20:52:41,421 ERROR [AbstractKernelController] Error installing to Configured: name=jboss.web.deployment:war=/MVCProj1 state=Instantiated mode=Manual requiredState=Configured
    java.lang.RuntimeException: Exception setting attribute SecurityManagement on mbean jboss.web.deployment:war=/MVCProj1
    	at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:170)
    	at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:114)
    	at org.jboss.system.microcontainer.ConfigureAction.installAction(ConfigureAction.java:58)
    	at org.jboss.system.microcontainer.ConfigureAction.installAction(ConfigureAction.java:42)
    	at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
    	at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
    	at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
    	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    	at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
    	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    	at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
    	at org.jboss.system.ServiceController.install(ServiceController.java:274)
    	at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:90)
    	at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
    	at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
    	at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
    	at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    	at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    	at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    	at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
    	at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    	at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    	at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    	at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    	at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    	at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    	at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    	at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
    	at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
    	at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
    	at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
    	at org.jboss.Main.boot(Main.java:209)
    	at org.jboss.Main$1.run(Main.java:547)
    	at java.lang.Thread.run(Thread.java:662)
    Caused by: javax.management.InvalidAttributeValueException: Set attribute  has class class org.jboss.security.integration.JNDIBasedSecurityManagement loaded from BaseClassLoader@138ec91{vfsfile:/C:/JBoss%205.01/jboss-5.0.1.GA/server/default/conf/jboss-service.xml} that is not assignable to attribute class interface org.jboss.security.ISecurityManagement loaded from BaseClassLoader@67d193{vfszip:/C:/JBoss%205.01/jboss-5.0.1.GA/server/default/deploy/MVCProj1.war/}
    	at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.checkAssignable(ModelMBeanAttributeInterceptor.java:229)
    	at org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelMBeanAttributeInterceptor.java:88)
    	at org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:76)
    	at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)
    	at org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:461)
    	at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:617)
    	at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:166)
    	... 40 more
    Is this a bug with JBoss or do I need to manipulate the settings of the JBoss server?

    Thanks again.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •