<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="username" value="abc#gmail.com" />
<property name="password" value="asasas" />
<property name="javaMailProperties">
<props>
<!-- <prop key="mail.smtp.auth">true</prop> -->
<prop key="mail.smtps.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.debug">false</prop>
<prop key="mail.smtp.ssl.trust">smtp.gmail.com</prop>
</props>
</property>
</bean>
</beans>
above code is working fine on localhost but when we are deploying on server it gives an Exception is java.lang.NoClassDefFoundError: org/bouncycastle/jce/spec/ECPublicKeySpec
Seems like BouncyCastle Jar is not found in class path , if it is working fine at local host then you must have used Add External jarOption of Eclipse which finds out the jar from your local file System ,
but when you deploy in Server you need to keep jar in WebContent/WEB-INF/lib directory
Related
I am writing unit tests for my Spring application using in-file HSQL db. I don't want to pollute this db with test data, so I am trying to set up another in-memory HSQL db instance to be used in tests.
In my abstract testing class I import test application context XML configuration:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration("/testingContext.xml")
#Transactional
public abstract class AbstractDaoForTesting {
testingContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
">
<jdbc:embedded-database id="dataSource" type="HSQL" />
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.se.micom" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="myEmf" />
</bean>
<tx:annotation-driven />
<bean id="persistenceExceptionTranslationPostProcessor" class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean id="characteristicDao" class="com.se.micom.dao.CharacteristicDaoImpl"/>
<bean id="functionalityDao" class="com.se.micom.dao.FunctionalityDaoImpl"/>
<bean id="segmentDao" class="com.se.micom.dao.SegmentDaoImpl"/>
<bean id="segmentService" class="com.se.micom.service.SegmentServiceImpl"/>
<bean id="functionalityService" class="com.se.micom.service.FunctionalityServiceImpl"/>
<bean id="characteristicService" class="com.se.micom.service.CharacteristicServiceImpl" />
</beans>
Up to now in-memory HSQL db is working fine in test.
However, as soon as I introduce in my project persistence.xml in src/main/resources/META-INF unit tests start to use this persistence unit and not the one from testingContext.xml.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="micomPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.se.micom.dao.domain.Characteristic</class>
<class>com.se.micom.dao.domain.Functionality</class>
<class>com.se.micom.dao.domain.Segment</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:file:D:\workspace_java\Micom2\db\micom"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
</properties>
</persistence-unit>
</persistence>
What's wrong with this configuration? Why tests "prefer" to use db defined in persistence.xml?
Your problem is a perfect example for Spring profiles. It is always problematic to have multiple beans doing the same thing in your context at once if you want a certain one to be used.
You should have two different profiles, "prod" and "test", and wrap your bean declaration in the xml config accordingly with <beans profile="XYZ"> ... </beans>. A more extensive example can be found here.
You can then annotate your test with #Profile("test") and it should use the correct database.
I know there are a lost postings with the same upcoming exception. But I tried them all and tried finally 3 different tutorials. And even these example sources are running into the following error:
Caused by: java.lang.IllegalArgumentException: A universal match pattern ('/**') is defined before other patterns in the filter chain, causing them to be ignored. Please check the ordering in your <security:http> namespace or FilterChainProxy bean configuration
at org.springframework.security.config.http.DefaultFilterChainValidator.checkPathOrder(DefaultFilterChainValidator.java:49) [spring-security-config-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.config.http.DefaultFilterChainValidator.validate(DefaultFilterChainValidator.java:39) [spring-security-config-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.afterPropertiesSet(FilterChainProxy.java:151) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
... 21 more
Am I doing something crucial wrong? Any advises would be appreciated. As I'd like to secure REST-methods a way with JavaConf would be good or even better as well =)
My web.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Backend</display-name>
<!-- RESTEasy configuration -->
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<!-- RESTEasy <-> Spring connector (RESTEasy can access Spring beans) -->
<listener>
<listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- Custom name for main spring configuration -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-context.xml</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
My spring-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<context:component-scan base-package="com.tripple" />
<mvc:annotation-driven />
<!-- Needed for Autowiring -->
<context:annotation-config />
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- MySQL DataSource -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/tripple" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.tripple.entity" />
<property name="hibernateProperties">
<props>
<!-- <prop key="hibernate.current_session_context_class">thread</prop> -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<security:http create-session="stateless"
authentication-manager-ref="authenticationManager">
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider ref="customAuthenticationProvider" />
</security:authentication-manager>
And finally my dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<tx:annotation-driven />
<mvc:annotation-driven />
Looking towords your configuration it seams that your Spring context loading twice
go throw following links
Spring MVC web app: application context starts twice
Spring context loading twice with both xml and annotation configuration
Application context loading twice
another problem might be a dependency conflict problem.
check for dependency conflicts ,cleaning up dependency conflicts and try to start up the application
hope this will help you !
The problem was, that I had a old JavaConf Class in the project as well. Therefore the context was loaded twice.
Removed the class and everything worked like a charm =)
I am trying to activate spring profile in my application.To do so,
i have added one parameter in web.xml to activate the default profile.
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
<context-param>
This my jdbc file which manipulates the properties.
and my jdbc.context.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<context:property-placeholder location="/WEB-INF/classes/jdbc.properties" /> <!-- TODO: config for different profiles, http://www.javacodegeeks.com/2012/06/spring-31-profiles-and-tomcat.html -->
<beans profile="dev">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="packagesToScan" value="com.i2sm.common" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
</beans>
</beans>
But when i restart my Tomcat server, it throws me following exception
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Sun Dec 23 00:57:22 GMT 2012]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:337)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1030)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Any Suggestion?
I think you need to specify spring.profiles.default as the context-param instead of spring.profiles.active.
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
Look at this question and refer this.
I'm working with JPA(Hibernate) and spring project these days, I configured spring, jpa and try to deploy the application on tomcat7, As I know jpa/hibernate creates tables using entity class first loading, but here I couldn't see any connection between database and application when applications starts, below you can see my configuration,I have seen lot of questions posted regarding this matter, I couldn't find the proper solution to my problem.
Can any one tell me what is the problem here.I have created a application without any issues in jetty server sometime back,
Thank you in advance
applicationContext-dao.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
default-lazy-init="true">
<!-- Use #Transaction annotations for managing transactions -->
<!--<tx:annotation-driven/>-->
<!-- holding properties for database connectivity / -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<tx:annotation-driven proxy-target-class="true" />
<!-- Activates scanning of #Autowired -->
<context:annotation-config/>
<!-- Activates scanning of #Repository -->
<context:component-scan base-package="lk.gov.elg"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"
p:dataSource-ref="dataSource"/>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:jpaVendorAdapter-ref="jpaAdapter">
<property name="persistenceUnitName" value="eLGPersistenceUnit"></property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
</property>
</bean>
<!-- Jpa adapter for the Hibernate -->
<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:databasePlatform="org.hibernate.dialect.MySQLDialect"
p:generateDdl="true"
p:showSql="true" >
</bean>
<bean
class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
<bean
class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
</beans>
persistance.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="eLGPersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<!--transaction-type="JTA">-->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
</properties>
<!--<provider>org.hibernate.ejb.HibernatePersistence</provider>-->
</persistence-unit>
</persistence>
I think there is no issue with your configuration, try after removing "default-lazy-init=true" attribute
Cheers
try changing:
<property name="hibernate.hbm2ddl.auto" value="validate"/>
to:
<property name="hibernate.hbm2ddl.auto" value="update"/>
or:
<property name="hibernate.hbm2ddl.auto" value="create"/>
I am getting various issues with configuration of spring hibernate and postgresql. I try to resolve one issue and i get some different issue.
I am using spring 3.1.0 release version and hibernate 4.1.4.Final
I am getting error BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
and my web.xml is
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
And my dispatcher-servlet is:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<mvc:annotation-driven> </mvc:annotation-driven>
<context:component-scan base-package="com.max.ade.common.model" />
<context:component-scan base-package="com.max.ade.daoImpl" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/TestUserDB" />
<property name="username" value="postgres" />
<property name="password" value="root123" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<!-- Scan packages for annotated entities -->
<property name="packagesToScan" value="com.max.ade.common.model" />
</bean>
<!-- Transaction support beans -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation- driven>
</beans>
And after issue resolving, above is my file structure for dispatcher-servlet.xml.
Are configuration things work differently with hibernate 3.6.4 and hibernate 4.1.4 beside issue mentioned (BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext)
Any concrete pointer will be great help.
Thanks.
It seems like you are mixing hibernate 3 and hibernate 4,
try to change this
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
to this
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
Regards