How to create cache expiry policy in ignite server by xml? - java

This is my example-default.xml,
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default is false. -->
<property name="peerClassLoadingEnabled" value="true"/>
<!-- Enable task execution events for examples. -->
<property name="includeEventTypes">
<list>
<!--Task execution events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
<!--Cache events-->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
<util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
</list>
</property>
<property name="CacheExpiryPolicy">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="expiryPolicyFactory">
<bean class="javax.cache.expiry.CreatedExpiryPolicy" factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="MINUTES"/>
<constructor-arg value="5"/>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</property>
But the above gives Bean property 'CacheExpiryPolicy' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
How I can solve this?

I found an apache-ignite-users forum question on this.
Please refer to this here
So, the final updated xml according to that forum reference 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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Added cache expiry policy -->
<bean id="cacheExpiryPolicy"
class="javax.cache.configuration.FactoryBuilder$SingletonFactory">
<constructor-arg>
<bean class="javax.cache.expiry.CreatedExpiryPolicy">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="MINUTES" />
<constructor-arg value="5" />
</bean>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean abstract="true" id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default
is false. -->
<property name="peerClassLoadingEnabled" value="true" />
<!-- Enable task execution events for examples. -->
<property name="includeEventTypes">
<list>
<!--Task execution events -->
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED" />
<!--Cache events -->
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" />
</list>
</property>
<!-- set the cacheConfiguration property -->
<property name="cacheConfiguration">
<list>
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="default" />
<property name="atomicityMode" value="ATOMIC" />
<property name="expiryPolicyFactory">
<bean parent="cacheExpiryPolicy" />
</property>
</bean>
</list>
</property>
</bean>
</beans>

Here is the example from the documentation:
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cacheWithExpiryPolicy"/>
<property name="expiryPolicyFactory">
<bean class="javax.cache.expiry.CreatedExpiryPolicy" factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="MINUTES"/>
<constructor-arg value="5"/>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</list>
</property>

Related

Spring batch 3600 partitions long pause before starting

I have the following spring batch job with a partitioned step that creates 3600 partitions for a partitioned step. I use a ThreadPoolTaskExecutor with a max pool size 100 and a queue capacity of 100 (although it seems to make no difference for speed). Im using Visual VM to monitor the threads and I notice the taskExecutor threads don't start until > 5 minutes after starting the job.
Oddly enough, If I limit the number of partitions to 100 the threads start fairly quickly and finish in about a minute.
Another issue I notice is that there doesn't seem to be more than one database connection ever as seen in the VisualVM thread visualization
Can someone please review my batch job below and tell me if I am missing something that would limit the number of database connections to 1? Also, why would adding more partitions affect the performance if my ThreadPoolTaskExecutor parameters don't change? Shouldn't the jobs just sit in a queue until there is a thread able to service them?
--- Spring batch job ---
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.0.xsd">
<context:property-placeholder location="${ext.properties.dataManipulation.Properties}"/>
<import resource="${ext.properties.dataManipulation.Connection}"/>
<import resource="flatFileLineProperties.xml"/>
<!-- JobRepository and JobLauncher are configuration/setup classes -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"/>
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
</bean>
<util:map id="keys" map-class="java.util.HashMap">
<entry key="SAILING_ID" value="ASCENDING" value-type="org.springframework.batch.item.database.Order"/>
<entry key="RES_ID" value="ASCENDING" value-type="org.springframework.batch.item.database.Order" />
</util:map>
<!-- Here is my partioned step -->
<bean id="reservationsItemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">
<property name="dataSource" ref="dataSource" />
<property name="queryProvider">
<bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause">
<value>
<![CDATA[
GUEST_ID,
FIRST_NAME,
LAST_NAME,
TITLE,
HOUSEHOLD_NAME,
SAILING_ID,
RES_ID
]]>
</value>
</property>
<property name="fromClause" value="FROM RESERVATION "/>
<property name="whereClause" >
<value>
<![CDATA[ AND SAIL_ID = :sailId
]]>
</value>
</property>
<!--<property name="sortKey" value="SAILING_ID" />-->
<property name="sortKeys" ref="keys"/>
<!--<property name="sortKeys" ref="sortKeys"/>-->
</bean>
</property>
<property name="parameterValues">
<map>
<!--<entry key="shipCode" value="#{stepExecutionContext[shipCode]}" />-->
<entry key="sailId" value="#{stepExecutionContext[sailId]}" />
</map>
</property>
<!--property name="pageSize" value="500000" /-->
<property name="pageSize" value="40000" />
<property name="rowMapper">
<bean class="com.ncl.endeca.mapper.ColumnToHashMapper" />
</property>
</bean>
<bean id="sortKeys" class="java.util.HashMap" scope="prototype" >
<constructor-arg>
<map key-type="java.lang.String" value-type="org.springframework.batch.item.database.Order">
<entry key="SAILING_ID" value="ASCENDING" />
<entry key="RES_ID" value="ASCENDING" />
</map>
</constructor-arg>
</bean>
<util:list id="client_fields" value-type="java.lang.String">
<value>FIRST_NAME</value>
<value>LAST_NAME</value>
<value>TITLE</value>
<value>HOUSEHOLD_NAME</value>
</util:list>
<bean id="reservationsItemWriter" class="com.ncl.endeca.writer.ReservationWriter" scope="step">
<property name="guestFields" ref="client_fields" />
<property name="outPrefix" value="${file.out.prefix}" />
<property name="shipCode" value="#{stepExecutionContext[shipCode]}" />
<property name="sailId" value="#{stepExecutionContext[sailId]}" />
<property name="soldOutSailings" ref="soldOutSailingsList" />
</bean>
<bean id="yearsAgo" class="java.lang.Integer">
<constructor-arg>
<value>${yearsAgo}</value>
</constructor-arg>
</bean>
<bean id="yearsAhead" class="java.lang.Integer">
<constructor-arg>
<value>${yearsAhead}</value>
</constructor-arg>
</bean>
<bean id="resPartitioner" class="com.ncl.endeca.partition.ReservationPartitioner">
<property name="yearsAgo" ref="yearsAgo" />
<property name="yearsAhead" ref="yearsAhead" />
<property name="batchLimit" value="${batch.limit}" />
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="${batch.corePoolSize}" />
<property name="maxPoolSize" value="${batch.maxPoolSize}" />
<property name="queueCapacity" value="${batch.queueCapacity}" />
</bean>
<!--<bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>-->
<!-- each thread will run this job, with different stepExecutionContext values. -->
<step id="slave" xmlns="http://www.springframework.org/schema/batch" >
<flow parent="readReservations"/>
</step>
<!--<bean id="countrySpecificCompletionPolicy" class="org.springframework.batch.core.resource.StepExecutionSimpleCompletionPolicy">-->
<!--<property name="keyName" value="sailId"/>-->
<!--</bean>-->
<batch:flow id="readReservations">
<batch:step id="reservations" xmlns="http://www.springframework.org/schema/batch" >
<tasklet throttle-limit="${batch.corePoolSize}">
<chunk reader="reservationsItemReader" writer="reservationsItemWriter" commit-interval="50000" />
</tasklet>
</batch:step>
</batch:flow>
<!-- Actual Job -->
<batch:job id="dataManipulationJob">
<batch:step id="masterStep">
<batch:partition step="slave" partitioner="resPartitioner">
<batch:handler grid-size="100" task-executor="taskExecutor" />
</batch:partition>
</batch:step>
</batch:job>
I have tried BasicDataSource and Hikari connections but the pool sizes have no affect when I monitor VisualVM
---- connection.xml ----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.0.xsd">
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="SELECT 10 from dual" />
<property name="dataSourceClassName" value="${hibernate.dataSourceClassName}" />
<property name="maximumPoolSize" value="${batch.maxPoolSize}" />
<property name="idleTimeout" value="${hibernate.hikari.idleTimeout}" />
<property name="dataSourceProperties">
<props>
<prop key="url">${dataSource.url}</prop>
<prop key="user">${dataSource.username}</prop>
<prop key="password">${dataSource.password}</prop>
</props>
</property>
</bean>
<!-- HikariCP configuration -->
<!--<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">-->
<!--<constructor-arg ref="hikariConfig" />-->
<!--</bean>-->
<!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="step">-->
<!--<property name="driverClassName" value="${hibernate.dataSourceClassName}" />-->
<!--<property name="url" value="${dataSource.url}" />-->
<!--<property name="username" value="${dataSource.username}" />-->
<!--<property name="password" value="${dataSource.password}" />-->
<!--<property name="testWhileIdle" value="false"/>-->
<!--<property name="maxActive" value="${batch.corePoolSize}"/>-->
<!--</bean>-->
<!-- connect to database -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:#******" />
<property name="username" value="****" />
<property name="password" value="****" />
</bean>
The time to create partitions depends on the performance of your ReservationPartitioner as well as the number of partitions. Creating 3600 partitions means creating 3600 StepExecution/ExecutionContext objects and persisting them in the corresponding tables. This can take time for such a high number of partitions.
In regards to the database connection, you are using the MapJobRepositoryFactoryBean with a ResourcelessTransactionManager so there are no interactions with a database for Spring Batch meta-data. The only component that interacts with the database according to your configuration is the JdbcPagingItemReader (I don't know what is the type of your ReservationWriter) so it is not surprising to see a single database connection.

Spring Rest api, differentiating the response format based on parameter

Below is my RestController class
#RestController
public class EmployeeRestController {
#RequestMapping(value = "/employees", produces={MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
public EmployeeList getEmployeesJson() {
System.out.println("EMPLOYEES");
return this.getEmployee();
}
}
This is my spring-dispatcher-servlet.xml
<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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.sharique.controller"/>
<context:component-scan base-package="com.sharique.restcontroller"/>
<mvc:default-servlet-handler/>
<!-- To switch on content negotiation strategies -->
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
<property name="favorParameter" value="true" />
<property name="parameterName" value="mediaType" />
<property name="ignoreAcceptHeader" value="true"/>
<property name="useJaf" value="false"/>
<property name="defaultContentType" value="application/json" />
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</map>
</property>
</bean>
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="order" value="1" />
<property name="messageConverters">
<list>
<!-- Message converters -->
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</list>
</property>
</bean>
<bean id="viewresolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
whenever am hitting the url, it's giving me response in xml format but when am differentiating it based on extension i.e., .xml/.json its working fine.
But I want to differentiate the response based on paramter, please help

How to fix No bean named 'springSecurityFilterChain' is defined

I'm developping a web application using spring, hibernate and primefaces.
In this application I get data from a database and use it to display charts.
when I run my application I get this error :
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
This is the application context 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:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
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.6.SEC01.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.6.SEC01.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.6.SEC01.xsd
">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/biblio?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name="mappingResources">
<list>
<value>Mapping/Status.hbm.xml</value>
<value>Mapping/Authorities.hbm.xml</value>
<value>Mapping/Livre.hbm.xml</value>
<value>Mapping/Users.hbm.xml</value>
<value>Mapping/Auteur.hbm.xml</value>
<value>Mapping/Emprunteur.hbm.xml</value>
<value>Mapping/Collection.hbm.xml</value>
<value>Mapping/Emprunt.hbm.xml</value>
<value>Mapping/Cathegorie.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<!--Spring Data Access Exception Translator Defintion-->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator" >
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<!--Hibernate Template Defintion-->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" >
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="jdbcExceptionTranslator">
<ref bean="jdbcExceptionTranslator"/>
</property>
</bean>
<!--Hibernate Transaction Manager Definition-->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!--========================= Start of DAO BEANS DEFINITIONS =========================-->
<bean id="autDao" class="Implementation.dao.AuteurDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="statusDao" class="Implementation.dao.StatusDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="categDao" class="Implementation.dao.CategorieDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="empDao" class="Implementation.dao.EmprunteurDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="colleDao" class="Implementation.dao.CollectionDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="livDao" class="Implementation.dao.LivreDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<bean id="emprDao" class="Implementation.dao.EmpruntDaoImpl" >
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<!--========================= Start of SERVICE BEANS DEFINITIONS =========================-->
<bean id="auDao" class="Implementation.service.AuteurServiceImpl" >
<property name="auteurDao" ref="autDao"/>
</bean>
<bean id="statDao" class="Implementation.service.StatusServiceImpl" >
<property name="statusDao" ref="statusDao"/>
</bean>
<bean id="catDao" class="Implementation.service.CategorieServiceImpl" >
<property name="categorieDao" ref="categDao"/>
</bean>
<bean id="emprunDao" class="Implementation.service.EmprunteurServiceImpl" >
<property name="emprunteurDao" ref="empDao"/>
</bean>
<bean id="collectionDao" class="Implementation.service.CollectionServiceImpl" >
<property name="collectionDao" ref="colleDao"/>
</bean>
<bean id="livrDao" class="Implementation.service.LivreServiceImpl" >
<property name="livreDao" ref="livDao"/>
</bean>
<bean id="empruDao" class="Implementation.service.EmpruntServiceImpl" >
<property name="empruntDao" ref="emprDao"/>
</bean>
</beans>
How can I solve this problem ?
Looks like you are using spring security filter in your application.
Can you post your web.xml?
You have to define in you web.xml
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>

Fail to create bean in spring suddently

I have encountered a problem of failed to create bean in spring suddenly. The webapp is already deployed and has been running for several months. However, below error message comes suddenly. It can be resolved by restarting the webapp, but comes again without any hints. Does anyone have any idea of this case?
Tomcat 6 is being used to host the webapp.
[2013/05/03 12:02:56:421 HKT] ajp-8009-42 org.ajax4jsf.webapp.BaseXMLFilter(227) - Exception in the filter chain
javax.servlet.ServletException: Error creating bean with name 'reportGenerationBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'scheduleBean' while setting bean property 'scheduleBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduleBean': Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException
applicationContext.xml as below
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:property-placeholder location="classpath*:webapp.properties,classpath*:env_prod.properties"/>
<context:annotation-config />
<bean id="facesUtils" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod">
<value>com.webapp.util.FacesUtils.init</value>
</property>
<property name="arguments">
<list>
<value>com.webapp.config.SpringBeanEnum</value>
<value>com.webapp.config.FacesBeanEnum</value>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="inspectbookSessionFactory"/></property>
</bean>
<context:component-scan base-package="com.webapp.bo, com.webapp.service" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="hibernateDAO" abstract="true">
<property name="sessionFactory"><ref local="inspectbookSessionFactory"/></property>
</bean>
<!-- Temporary Setting -->
<bean id="ItemSearchBeanDao" class="com.webapp.dao.tmp.ItemSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.order}"/>
</bean>
<bean id="BookedSearchBeanDao" class="com.webapp.dao.tmp.BookedSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.booked}"/>
</bean>
<bean id="ScheduleBeanDao" class="com.webapp.dao.tmp.ScheduleBeanDao" parent="hibernateDAO"></bean>
<bean id="WhItemSearchBeanDao" class="com.webapp.dao.tmp.WhItemSearchBeanDao" parent="hibernateDAO">
<property name="maxRecordNo" value="${no_of_record.whItem}"/>
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="-secret-"/>
</bean>
<bean id="EmailUtil" class="com.webapp.util.EmailUtil">
<property name="mailSender" ref="mailSender"/>
</bean>
<bean id="freeMarkerTemplateMailer" class="com.webapp.bo.email.impl.FreeMarkerTemplateMailer">
<property name="mailSender" ref="mailSender"/>
</bean>
<bean id="emailService" class="com.webapp.bo.email.impl.EmailServiceImpl" >
<property name="orgunitDao" ref="OrgunitDAO"/>
<property name="contactMethodDao" ref="ContactMethodDAO"/>
<property name="mailer" ref="freeMarkerTemplateMailer"/>
</bean>
<bean id="scheduleEmail" class="com.webapp.bo.schedule.impl.ScheduleEmailImpl" >
<property name="orgunitDao" ref="OrgunitDAO"/>
<property name="scheduleBeanDao" ref="ScheduleBeanDao"/>
<property name="emailService" ref="emailService"/>
</bean>
<bean name="scheduleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.webapp.service.schedule.ScheduleJob" />
<property name="jobDataAsMap">
<map>
<entry key="scheduleEmail" value-ref="scheduleEmail" />
</map>
</property>
</bean>
<!-- JSF backing bean START -->
<bean id="vendorSearchBean" class="com.webapp.service.search.item.VendorSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.vendor}"/>
</bean>
<bean id="itemSearchBean" name="itemSearchBean" class="com.webapp.service.search.item.NewItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.order}"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="itemSearchPopupBean" name="itemSearchPopupBean" class="com.webapp.service.search.item.NewItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.order}"/>
</bean>
<bean id="detailBean" class="com.webapp.service.detail.DetailBean" scope="session">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="itemSearchPopupBean" ref="itemSearchPopupBean"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="bookedSearchBean" class="com.webapp.service.search.booked.BookedSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.booked}"/>
</bean>
<bean id="scheduleConfirmBean" class="com.webapp.service.schedule.ScheduleConfirmBean" scope="session">
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="scheduleBean" class="com.webapp.service.search.schedule.ScheduleBean" scope="session">
<property name="popupBean" ref="popupBean"/>
</bean>
<bean id="dropBean" class="com.webapp.service.search.schedule.DropBean" scope="request">
<property name="scheduleBean" ref="scheduleBean"/>
</bean>
<bean id="inspectContactBean" class="com.webapp.service.detail.contact.InspectContactBean" scope="session">
<property name="detailBean" ref="detailBean"/>
</bean>
<bean id="inspectLocationBean" class="com.webapp.service.detail.contact.InspectLocationBean" scope="session">
<property name="detailBean" ref="detailBean"/>
</bean>
<bean id="whItemSearchBean" class="com.webapp.service.search.warehouse.WhItemSearchBean" scope="session">
<property name="maxRecordNo" value="${no_of_record.whItem}"/>
<!--<property name="propertiesUtil" ref="propertiesUtil"/>-->
</bean>
<!-- Autocomplete -->
<bean id="autocomplete" class="com.webapp.service.common.AutocompleteBean" scope="session"></bean>
<!-- PackingListBean -->
<bean id="packingListBean" class="com.webapp.service.common.PackingListBean" scope="session">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="popupBean" ref="popupBean"/>
</bean>
<!-- Report Bean -->
<bean id="reportGenerationBean" class="com.webapp.service.report.ReportGenerationBean" scope="request">
<property name="itemSearchBean" ref="itemSearchBean"/>
<property name="packingListBean" ref="packingListBean"/>
<property name="scheduleBean" ref="scheduleBean"/>
</bean>
<!-- popupBean -->
<bean id="popupBean" class="com.webapp.service.common.PopupControlBean" scope="session">
</bean>
<!-- JSF backing bean END -->
</beans>

Java Spring: getting error " Unknown property sub-element: <util:constant>"

I'm trying to use the util:constant tag for ioc, but I'm getting the following error message:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'threadPoolExecutor' defined in class path resource [spring.xml]: Unknown property sub-element: <util:constant>
Here's my 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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:config.properties</value>
</property>
</bean>
<bean id="main" class="pikefin.Main">
<property name="executorSample" ref="executorSample"/>
</bean>
<bean id="executorSample" class="pikefin.ExecutorSample">
<constructor-arg ref="threadPoolExecutor" />
</bean>
<bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" value="2"/>
<constructor-arg index="2" value="10"/>
<constructor-arg index="3"><util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/></constructor-arg>
<constructor-arg index="4" ref="arrayBlockingPool"/>
</bean>
<bean id="arrayBlockingPool" class="java.util.concurrent.ArrayBlockingQueue">
<constructor-arg value="5"/>
</bean>
</beans>
Update:
Here's my xml with the <value> tag added which causes a different error message:
Invalid content was found starting with element 'util:constant'. No child element is expected at this point.
(Sidenote: for some reason my formatting controls have disappeared when posting in SO)
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:config.properties</value>
</property>
</bean>
<bean id="main" class="pikefin.Main">
<property name="executorSample" ref="executorSample"/>
</bean>
<bean id="executorSample" class="pikefin.ExecutorSample">
<constructor-arg ref="threadPoolExecutor" />
</bean>
<bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" value="2"/>
<constructor-arg index="2" value="10"/>
<constructor-arg index="3">
<value>
<util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/>
</value>
</constructor-arg>
<constructor-arg index="4" ref="arrayBlockingPool"/>
</bean>
<bean id="arrayBlockingPool" class="java.util.concurrent.ArrayBlockingQueue">
<constructor-arg value="5"/>
</bean>
</beans>
For enum's you can directly assign the values and Spring will take care of binding it to the correct enum:
<constructor-arg index="3" value="SECONDS">
Also, your original entry worked for me perfectly:
<bean id="threadPoolExecutor" class="java.util.concurrent.ThreadPoolExecutor">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" value="2"/>
<constructor-arg index="2" value="10"/>
<constructor-arg index="3"><util:constant static-field="java.util.concurrent.TimeUnit.SECONDS"/></constructor-arg>
<constructor-arg index="4" ref="arrayBlockingPool"/>
</bean>

Categories

Resources