I am working on a migration task where we are migrating the project from Websphere 6.1 to Websphere 7.0.0.39. Also upgraded JDK version from 1.5 to 1.6.
Actually one of the web project, uses spring and hibernate combination. The version of spring is 2.5.3. The spring context is initialized while bootstrapping i.e. # server startup.
So i am getting org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed error while server startup.
I also did a google search on the below issue and found the jira SPR-4788 which says spring2.5 && ibm jdk6 will produce a NPE as below.
Stack Trace from the server startup log :
org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext#27822782]: org.springframework.beans.factory.support.DefaultListableBeanFactory#39ed39ed
[5/9/16 16:29:03:417 IST] 0000000c DefaultListab I org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#39ed39ed: defining beans [applicationContextHolder,dataSource,entityManagerFactory,transactionManager,jndiEPTemplate,sequenceProxy,transferActionItemDao,transferTemplateActionItemDao,achActionItemDao,achTemplateActionItemDao,wireActionItemDao,wireTemplateActionItemDao,posPayActionItemDao,cdBalancesDao,bankIRReportsDao,favoriteDao,stateDao,secureMsgActionItemDao,specialReportItemDao,alertsActionItemDao,shortcutMenuDao,userActionItemDao,achAuthActionItemDao,corporateWireBannerDao,wireBannerDao,corporateTransferBannerDao,transferBannerDao,corporateAchBannerDao,achBannerDao,corporatePosPayBannerDao,posPayBannerDao,issuesBannerDao,stopPayBannerDao,uploadBannerDao,corporateIssuesBannerDao,corporateStopPayBannerDao,corporateUploadBannerDao,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,CDBalancesDao,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor]; root of factory hierarchy
[5/9/16 16:29:03:417 IST] 0000000c ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:224)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:579)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1721)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:388)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:732)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:617)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1146)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1320)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:945)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:759)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$3.run(ApplicationMgrImpl.java:2082)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5398)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5486)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2087)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:434)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:377)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:944)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:496)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
Caused by: java.lang.NullPointerException
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:144)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:111)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:77)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:47)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 39 more
[5/9/16 16:29:03:433 IST] 0000000c webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(AccessController.java:224)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:579)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1721)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:388)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:732)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:617)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1146)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1320)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:945)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:759)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$3.run(ApplicationMgrImpl.java:2082)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5398)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5486)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2087)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:434)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:377)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:944)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:496)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
Caused by: java.lang.NullPointerException
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:144)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:93)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:58)
at java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:111)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:77)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:47)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 39 more
Spring jars in Class-Path of the web project:
3rdparty/spring-2.5.3.jar
3rdparty/spring-aop.jar
3rdparty/spring-beans.jar
3rdparty/spring-binding.jar
3rdparty/spring-context-support.jar
3rdparty/spring-context.jar
3rdparty/spring-core.jar
3rdparty/spring-dao.jar
3rdparty/spring-faces.jar
3rdparty/spring-jdbc.jar
3rdparty/spring-js.jar
3rdparty/spring-mock.jar
3rdparty/spring-security-acl.jar
3rdparty/spring-security-core-tiger.jar
3rdparty/spring-security-core.jar
3rdparty/spring-security-taglibs.jar
3rdparty/spring-support.jar
3rdparty/spring-test.jar
3rdparty/spring-tx.jar
3rdparty/spring-web.jar
3rdparty/spring-webflow.jar
3rdparty/spring-webmvc.jar
Spring Configuration File
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- http://static.springframework.org/spring/docs/2.5.x/reference/xsd-config.html -->
<!-- see Spring in Action pg 143 -->
<bean id="applicationContextHolder" class="com.s1.core.WebApplicationContextHolder" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
<property name="targetDataSource">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/EPDatabase" />
</bean>
</property>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="bankingEjbPersistenceUnit"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="DB2"/>
<property name="showSql" value="false"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="jndiEPTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.ibm.websphere.naming.WsnInitialContextFactory</prop>
<prop key="java.naming.provider.url">iiop://localhost:#BOOT_STRAP_PORT#</prop>
</props>
</property>
</bean>
<bean id="sequenceProxy" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" scope="prototype">
<property name="jndiName" value="ejb/com/s1/arch/sequence/SequenceServiceHome"/>
<property name="businessInterface" value="com.s1.arch.persistence.sequence.SequenceService"/>
<property name="jndiTemplate">
<ref local="jndiEPTemplate"/>
</property>
<property name="cacheHome" value="false"/>
<property name="lookupHomeOnStartup" value="false"/>
<property name="resourceRef" value="false"/>
<property name="homeInterface" value="com.s1.arch.persistence.sequence.SequenceServiceHome"/>
</bean>
<bean id="transferActionItemDao" class="com.s1.core.dashboard.dao.TransferActionItemDao" autowire="byName" />
<bean id="transferTemplateActionItemDao" class="com.s1.core.dashboard.dao.TransferTemplateActionItemDao" autowire="byName" />
<bean id="achActionItemDao" class="com.s1.core.dashboard.dao.AchActionItemDao" autowire="byName" />
<bean id="achTemplateActionItemDao" class="com.s1.core.dashboard.dao.AchTemplateActionItemDao" autowire="byName" />
<bean id="wireActionItemDao" class="com.s1.core.dashboard.dao.WireActionItemDao" autowire="byName" />
<bean id="wireTemplateActionItemDao" class="com.s1.core.dashboard.dao.WireTemplateActionItemDao" autowire="byName" />
<bean id="posPayActionItemDao" class="com.s1.core.dashboard.dao.PosPayActionItemDao" autowire="byName" />
<bean id="cdBalancesDao" class="com.s1.core.dashboard.dao.CDBalancesDao" autowire="byName" />
<bean id="bankIRReportsDao" class="com.s1.core.dashboard.dao.BankIRReportsDao" autowire="byName" />
<bean id="favoriteDao" class="com.s1.core.dashboard.dao.FavoriteDao" autowire="byName" />
<bean id="stateDao" class="com.s1.core.dashboard.dao.StateDao" autowire="byName" />
<bean id="secureMsgActionItemDao" class="com.s1.core.dashboard.dao.SecureMsgActionItemDao" />
<bean id="specialReportItemDao" class="com.s1.core.dashboard.dao.SpecialReportItemDao" autowire="byName" />
<bean id="alertsActionItemDao" class="com.s1.core.dashboard.dao.AlertsActionItemDao" autowire="byName" />
<bean id="shortcutMenuDao" class="com.s1.core.dashboard.dao.ShortcutMenuDao" autowire="byName" />
<bean id="userActionItemDao" class="com.s1.core.dashboard.dao.UserActionItemDao" autowire="byName" />
<bean id="achAuthActionItemDao" class="com.s1.core.dashboard.dao.AchAuthActionItemDao" autowire="byName" />
<bean id="corporateWireBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateWireBannerDao" autowire="byName" />
<bean id="wireBannerDao" class="com.s1.pso.core.banner.dao.PSOWireBannerDao" autowire="byName" />
<bean id="corporateTransferBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateTransferBannerDao" autowire="byName" />
<bean id="transferBannerDao" class="com.s1.pso.core.banner.dao.PSOTransferBannerDao" autowire="byName" />
<bean id="corporateAchBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateAchBannerDao" autowire="byName" />
<bean id="achBannerDao" class="com.s1.pso.core.banner.dao.PSOAchBannerDao" autowire="byName" />
<bean id="corporatePosPayBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporatePosPayBannerDao" autowire="byName" />
<bean id="posPayBannerDao" class="com.s1.pso.core.banner.dao.PSOPosPayBannerDao" autowire="byName" />
<bean id="issuesBannerDao" class="com.s1.pso.core.banner.dao.PSOIssuesBannerDao" autowire="byName" />
<bean id="stopPayBannerDao" class="com.s1.pso.core.banner.dao.PSOStopPayBannerDao" autowire="byName" />
<bean id="uploadBannerDao" class="com.s1.pso.core.banner.dao.PSOUploadBannerDao" autowire="byName" />
<bean id="corporateIssuesBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateIssuesBannerDao" autowire="byName" />
<bean id="corporateStopPayBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateStopPayBannerDao" autowire="byName" />
<bean id="corporateUploadBannerDao" class="com.s1.pso.core.banner.dao.PSOCorporateUploadBannerDao" autowire="byName" />
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config /> </beans>
Persistence.xml
<persistence 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"
version="1.0">
<persistence-unit name="bankingEjbPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<!-- The provider only needs to be set if you use several JPA providers
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<provider>org.unitils.orm.jpa.util.provider.hibernate.UnitilsHibernatePersistenceProvider</provider>
-->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.s1.core.dashboard.bean.AchActionItem</class>
<class>com.s1.core.dashboard.bean.AlertsActionItem</class>
<class>com.s1.core.dashboard.bean.BankIRReports</class>
<class>com.s1.core.dashboard.bean.BankTransactionActionItem</class>
<class>com.s1.core.dashboard.bean.CDBalancesEntity</class>
<class>com.s1.core.dashboard.bean.FavoriteItem</class>
<class>com.s1.core.dashboard.bean.PosPayActionItem</class>
<class>com.s1.core.dashboard.bean.SecureMsgActionItem</class>
<class>com.s1.core.dashboard.bean.ShortcutMenuEntity</class>
<class>com.s1.core.dashboard.bean.SpecialReportItem</class>
<class>com.s1.core.dashboard.bean.StateItem</class>
<class>com.s1.core.dashboard.bean.TransferActionItem</class>
<class>com.s1.core.dashboard.bean.WireActionItem</class>
<properties>
<!-- SQL stdout logging -->
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
<property name="hibernate.connection.release_mode" value="after_transaction"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect" />
<property name="hibernate.connection.datasource" value="jdbc/EPDatabase" />
<property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
<persistence-unit name="parserPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.s1.core.parser.ParsedPDStatement</class>
<class>com.s1.core.parser.ParsedPDStatementDetail</class>
<class>com.s1.core.parser.ParsedPDTransaction</class>
<class>com.s1.core.parser.ParsedPDTransactionMemo</class>
<class>com.s1.core.parser.ParsedCDStatement</class>
<class>com.s1.core.parser.ParsedCDStatementDetail</class>
<class>com.s1.core.parser.ParsedCDTransaction</class>
<class>com.s1.core.parser.ParsedCDTransactionMemo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.DB2Dialect" />
<!--<property name="hibernate.hbm2ddl.auto" value="update" /> -->
<!-- Enable pooling of connections for efficiency. Can be disabled in development -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.connection.datasource" value="jdbc/EPDatabase" />
<property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
</persistence>
Listener configuration in web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Related
I started to learn spring batch and I have a problem that when i want to
persist the state of the job in a database using JobRepositoryFactoryBean.
compiler displays :
"Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in class path resource [springConfig.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/simple/ParameterizedRowMapper"
but not error when i use MapJobRepositoryFactoryBean
I'm using spring 5
springconfig.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:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="springbatch" />
<context:annotation-config />
<bean id="personneReaderCSV" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="input/personnes.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
<property name="names" value="id,nom,prenom,civilite" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="targetType" value="springbatch.entities.Personne" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean name="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/spring_test" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>springbatch.entities.Personne</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<job id="importPersonnes" xmlns="http://www.springframework.org/schema/batch">
<step id="readWritePersonne">
<tasklet>
<chunk reader="personneReaderCSV"
processor="personProcessor"
writer="personWriter"
commit-interval="2" />
</tasklet>
</step>
</job>
<bean id="daoPersonne" class="springbatch.dao.PersonneDaoImp">
<property name="factory" ref="sessionFactory"></property>
</bean>
<bean id="personWriter" class="springbatch.batch.PersonneWriter">
<property name="dao" ref="daoPersonne"></property>
</bean>
<bean id="personProcessor" class="springbatch.batch.PersonneProcess">
</bean>
<bean id="batchLauncher" class="springbatch.MyBean">
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="Mysql" />
</bean>
<task:scheduled-tasks>
<task:scheduled ref="batchLauncher" method="message"
cron=" 59 * * * * * " />
</task:scheduled-tasks>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="org/springframework/batch/core/schema-mysql.sql" />
</jdbc:initialize-database>
</beans>
but not error when i use :
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
You are using Spring Batch v2.2 with Spring Framework 5. That's not going to work properly as ParameterizedRowMapper has been removed in Spring Framework 4.2+ (hence the exception).
I recommend that you use Spring Batch v4.1 (since v2.x is not maintained anymore) and your issue should be fixed.
The best way to manage Spring dependencies is to let Spring Boot do it for you either by generating a project from start.spring.io or by using the Spring Boot BOM. With both ways, you will have the correct Spring projects dependencies that are known to work well together.
I'm working on a project using JSpring and JPA/Hibernate. I try to call a native query to update the DB. Here is the error trace:
Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
at com.sun.proxy.$Proxy31.executeUpdate(Unknown Source)
at com.ncrm.dao.daoImpl.UpdateExt(daoImpl.java:124)
at com.ncrm.metier.MetierImpl.UpdateExt(MetierImpl.java:663)
at com.ncrm.loginBean.authentification(loginBean.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.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-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="com.ncrm.dao" />
<bean name="daoo" class="com.ncrm.dao.daoImpl"></bean>
<bean name="metier" class="com.ncrm.metier.MetierImpl">
<property name="dao" ref="daoo"></property>
</bean>
<!-- <bean name="paramEtat" class="com.ncrm.editionEtats.dao.paramEtatsImp"></bean> -->
<!-- ############################################################################## -->
<!-- le gestionnaire de transactions -->
<!-- ############################################################################## -->
<tx:annotation-driven transaction-manager="jpaTransactionManager" />
<bean id="jpaTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="localContainerEntityManagerFactoryBean" />
</bean>
<tx:annotation-driven transaction-manager="jpaTransactionManager" />
<bean id="jpaTransactionManagerBPa" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="localContainerEntityManagerFactoryBeanBpa" />
</bean>
<!-- ############################################################################## -->
<!-- couche de persistance JPA -->
<!-- ############################################################################## -->
<bean id="localContainerEntityManagerFactoryBean"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:config/persistence.xml" />
<property name="persistenceUnitName" value="ncrm_extraction" />
<property name="dataSource" ref="basicDataSource" />
<property name="jpaVendorAdapter">
<bean id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
<property name="generateDdl" value="false" />
<property name="showSql" value="false"></property>
</bean>
</property>
<property name="loadTimeWeaver">
<bean id="instrumentationLoadTimeWeaver"
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<bean id="localContainerEntityManagerFactoryBeanBpa"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:config/persistence.xml" />
<property name="persistenceUnitName" value="BpaProduciton" />
<property name="dataSource" ref="basicDataSourceBpa" />
<property name="jpaVendorAdapter">
<bean id="hibernateJpaVendorAdapterBpa"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
<property name="generateDdl" value="false" />
<property name="showSql" value="false"></property>
</bean>
</property>
<property name="loadTimeWeaver">
<bean id="instrumentationLoadTimeWeaverBpa"
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<!-- ############################################################################## -->
<!-- DataSource -->
<!-- ############################################################################## -->
<bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/r_ncrmextraction" />
<property name="username" value="root" />
<property name="password" value="fast" />
</bean>
<bean id="basicDataSourceBpa" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/" />
<property name="username" value="root" />
<property name="password" value="fast" />
</bean>
<!-- traduction des exceptions -->
<bean id="persistenceExceptionTranslationPostProcessor"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- annotations de persistance -->
<bean id="persistenceAnnotationBeanPostProcessor"
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
</beans>
My DAO Class
public class daoImpl implements Idao,Serializable {
String BDD_REF="r_multi_4";
private static final Logger logger = Logger.getLogger(daoImpl.class);
#PersistenceContext(unitName="ncrm_extraction")
EntityManager em;
#PersistenceContext(unitName="BpaProduciton")
EntityManager emBpa;
#Transactional
public int UpdateExt(String pk_obj_id_Rem,String Req) {
logger.debug("### DAO : Modifier le flag EXT table remise : "+pk_obj_id_Rem );
Query q = emBpa.createNativeQuery(Req);
// q.setParameter("Date", dteTr);
// q.setParameter("pk_obj_id_Rem", pk_obj_id_Rem);
int flag=q.executeUpdate();
return flag;
}
My persistence:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ncrm_extraction" transaction-type="RESOURCE_LOCAL">
<!-- <class>com.ncrm.dao.entities.user</class> -->
</persistence-unit>
<persistence-unit name="BpaProduciton" transaction-type="RESOURCE_LOCAL">
<!-- <class>com.ncrm.dao.entities.user</class> -->
</persistence-unit>
</persistence>
suppose you modify your DaoImpl as below.
#Modifying(clearAutomatically = true)
#Transactional
public int UpdateExt(String pk_obj_id_Rem,String Req) {
logger.debug("### DAO : Modifier le flag EXT table remise : "+pk_obj_id_Rem );
Query q = emBpa.createNativeQuery(Req);
int flag=q.executeUpdate();
return flag;
}
Hope this helps.
Refer this post for more details.
I am getting confused on how to get the entity Manager Factory in spring spring-datasource.xml using
I did the following :
spring-datasource.xml file:
<tx:jta-transaction-manager id="transactionManager" />
<tx:annotation-driven mode="proxy"
transaction-manager="transactionManager" />
<jee:jndi-lookup id="entityManagerFactory" jndi-name="jdbc/mysqldatasource" />
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="ebankingUnit"
transaction-type="JTA">
<jta-data-source>jdbc/mysqldatasource</jta-data-source>
<class>com.datamodel.Product</class>
<properties>
<property name="eclipselink.logging.level" value="INFO" />
<property name="eclipselink.query-results-cache.expiry"
value="5000" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="hibernate.hbm2ddl.auto" value="none" />
</properties>
</persistence-unit>
but I am getting thid
which version of Spring are you using? You don't even need persistence.xml in the latest versions.
Here is the configuration using Spring 3.x, for oracle.
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- FactoryBean that creates the EntityManagerFactory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="ORACLE" />
<property name="showSql" value="false" />
</bean>
</property>
<property name="packagesToScan" value="blah.com..domain" />
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/myoracledb}" />
</bean>
Now define myoracledb jndi resource in your web.xml
<Resource name="myoracledb" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
maxActive="50"
url="your db url"
username="dbuser" password="dbpwd" />
Regards
I searched through the same questions but unfortunately I couldn't find the solution.
I face with the following exception:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 32 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 2; The markup in the document following the root element must be well-formed.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:530)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:444)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at Main.main(Main.java:18)
Caused by: org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 2; The markup in the document following the root element must be well-formed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(XMLDocumentScannerImpl.java:1382)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:237)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 14 more
and this is my applicationContext.xml:
<context:component-scan base-package="com.springHibernate" />
<context:annotation-config />
<bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/myapp" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<!-- Beans Declaration -->
<bean id="User" class="com.mycompany.myapp.core.model.User"/>
<bean id="Institute" class="com.mycompany.myapp.core.model.Institute"/>
<!-- User Service Declaration -->
<bean id="UserBoImpl" class="com.mycompany.myapp.core.bo.impl.UserBoImpl">
<property name="userDao" ref="UserDaoImpl" />
</bean>
<bean id="InstituteBoImpl" class="com.mycompany.myapp.core.bo.impl.InstituteBoImpl">
<property name="instituteDao" ref="InstituteDaoImpl" />
</bean>
<!-- User DAO Declaration -->
<bean id="UserDaoImpl" class="com.mycompany.myapp.core.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="InstituteDaoImpl" class="com.mycompany.myapp.core.dao.impl.InstituteDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<property name="annotatedClasses">
<list>
<value>com.mycompany.myapp.core.model.User</value>
<value>com.mycompany.myapp.core.model.Institute</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
I don't know what the reason of exception is ...
I appreciate your comments.
The <beans> tag is closed and then more bean definitions are added. Move the closing beans tag so it nests the bean definitions. Another related thing that can burn you with XML config files is using the format tool within your IDE. Never format the XML config with a tool, it can add additional whitespace to your xml which gets interpreted breaking your configuration.
In a nutshell your doing this:
<beans>
<bean id="1"/>
</beans>
<bean id="2"/>
<bean id="3"/>
When it should be like:
<beans>
<bean id="1"/>
<bean id="2"/>
<bean id="3"/>
</beans>
Full Configuration With Changes
<?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.springHibernate" />
<context:annotation-config />
<bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/mydb" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<!-- Beans Declaration -->
<bean id="User" class="com.mycompany.myapp.core.model.User"/>
<bean id="Institute" class="com.mycompany.myapp.core.model.Institute"/>
<!-- User Service Declaration -->
<bean id="UserBoImpl" class="com.mycompany.myapp.core.bo.impl.UserBoImpl">
<property name="userDao" ref="UserDaoImpl" />
</bean>
<bean id="InstituteBoImpl" class="com.mycompany.myapp.core.bo.impl.InstituteBoImpl">
<property name="instituteDao" ref="InstituteDaoImpl" />
</bean>
<!-- User DAO Declaration -->
<bean id="UserDaoImpl" class="com.mycompany.myapp.core.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="InstituteDaoImpl" class="com.mycompany.myapp.core.dao.impl.InstituteDaoImpl">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<property name="annotatedClasses">
<list>
<value>com.mycompany.myapp.core.model.User</value>
<value>com.mycompany.myapp.core.model.Institute</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
</beans>
i got an example of spring configuration with jbpm here http://docs.jboss.org/drools/release/5.4.0.Final/droolsjbpm-integration-docs/html/ch.spring.html and i have implemented it.There is a bean called springTaskSessionFactory ,i don't get where this bean will be used in human task execution ?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbpm="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd">
<!-- persistence & transactions-->
<bean id="htEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="org.jbpm.task" />
</bean>
<bean id="htEm" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="htEmf"/>
</bean>
<bean id="jpaTxMgr" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="htEmf" />
<!-- this must be true if using the SharedEntityManagerBean, and false otherwise -->
<property name="nestedTransactionAllowed" value="true"/>
</bean>
<bean id="htTxMgr" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager">
<constructor-arg ref="jpaTxMgr" />
</bean>
<!-- human-task beans -->
<bean id="systemEventListener" class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener" />
<bean id="taskService" class="org.jbpm.task.service.TaskService" >
<property name="systemEventListener" ref="systemEventListener" />
</bean>
<bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl"
init-method="initialize" depends-on="taskService" >
<!-- if using the SharedEntityManagerBean, make sure to enable nested transactions -->
<property name="entityManager" ref="htEm" />
<property name="transactionManager" ref="htTxMgr" />
<property name="useJTA" value="false" />
<property name="taskService" ref="taskService" />
</bean>
</beans>