How to add google OAuth(spring-social-google) to the existing spring project using spring-social? - spring

I developed spring application with oauth authentication using spring social project. I'm currently able to authenticate using facebook, twitter and linkedin. I would like to also add google authentication using spring-social-google. Its really confusing for me where to add google's connection factory in the existing spring social configuration.
My current spring social application context 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:facebook="http://www.springframework.org/schema/social/facebook"
xmlns:twitter="http://www.springframework.org/schema/social/twitter"
xmlns:social="http://www.springframework.org/schema/social"
xmlns:linkedin="http://www.springframework.org/schema/social/linkedin"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd
http://www.springframework.org/schema/social/linkedin http://www.springframework.org/schema/social/spring-social-linkedin.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/social/twitter http://www.springframework.org/schema/social/spring-social-twitter.xsd
http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="/WEB-INF/properties/application.properties" />
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" app-namespace="my-app" />
<twitter:config app-id="${twitter.consumerKey}" app-secret="${twitter.consumerSecret}"/>
<linkedin:config app-id="${linkedin.consumerKey}" app-secret="${linkedin.consumerSecret}"/>
<social:jdbc-connection-repository/>
<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource" />
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
<property name="connectInterceptors">
<list>
<bean class="com.prs.ony.controller.facebook.PostToWallAfterConnectInterceptor" />
<bean class="com.prs.ony.controller.twitter.TweetAfterConnectInterceptor" />
</list>
</property>
</bean>
<bean id="psc" class="org.springframework.social.connect.web.ProviderSignInController" autowire="constructor" />
<bean id="signInAdapter" class="com.prs.ony.controller.signin.SimpleSignInAdapter" autowire="constructor" />
<!-- <bean id="disconnectController" class="org.springframework.social.facebook.web.DisconnectController"
c:_0-ref="usersConnectionRepository" c:_1="${facebook.clientSecret}" /> -->
</beans>
Now im confused where to add the googles connection factory. It has to work along with the existing there oauth providers.
<bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.google.connect.GoogleConnectionFactory">
<constructor-arg value="${google.consumerKey}" />
<constructor-arg value="${google.consumerSecret}" />
</bean>
</list>
</property>
</bean>
Any help would be highly appreciated.

It is possible to omit the usage of the concrete social configuration namespace and register connection factories all together:
<bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
<constructor-arg name="appId" value="${facebook.clientId}" />
<constructor-arg name="appSecret" value="${facebook.clientSecret}" />
</bean>
<bean class="org.springframework.social.twitter.connect.TwitterConnectionFactory">
<constructor-arg name="consumerKey" value="${twitter.consumerKey}" />
<constructor-arg name="consumerSecret" value="${twitter.consumerSecret}" />
</bean>
<bean class="org.springframework.social.linkedin.connect.LinkedInConnectionFactory">
<constructor-arg name="consumerKey" value="${linkedin.consumerKey}" />
<constructor-arg name="consumerSecret" value="${linkedin.consumerSecret}" />
</bean>
<bean class="org.springframework.social.google.connect.GoogleConnectionFactory">
<constructor-arg name="clientId" value="${google.consumerKey}" />
<constructor-arg name="clientSecret" value="${google.consumerSecret}" />
</bean>
</list>
</property>
</bean>

Related

Spring JMS 4.1 + ActiveMQ handle stress request

Currently, My system is using Spring-jms 4.1.6 and ActiveMQ 5.2.0
We facing the issue is that when we have stress requests (50000 continuity requests like DDOS), the server is dying.
I think there are some problems with my config on the consumer side;
The config below is the original config
<?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:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
</bean>
<!-- Administrated objects -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="failover:(tcp://localhost:${JMS_PORT})"/>
</bean>
</property>
<property name="reconnectOnException" value="false"/>
</bean>
<bean id="queue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="test.service" />
</bean>
<!-- Message listener container for services -->
<bean id="errorHandler" class="com.myconsumer.test.LogErrorHandler"/>
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="queue" />
<property name="concurrentConsumers" value="10" />
<property name="maxConcurrentConsumers" value="20" />
<property name="messageListener" ref="serviceExporterDispatcher" />
<property name="errorHandler" ref="errorHandler" />
</bean>
<bean id="securityTokenVerificator" class="com.myconsumer.test.SecurityTokenVerificator">
<property name="authenticationService" ref="authenticationService" />
</bean>
<bean id="businessServiceInterceptor" class="com.myconsumer.test.RemoteInvocationBusinessServiceInterceptor">
<property name="securityTokenVerificator" ref="securityTokenVerificator" />
</bean>
<bean id="requestContextHandler" class="com.myconsumer.test.RequestContextHandler"/>
<bean id="remoteInvocationErrorHandler" class="com.myconsumer.test.RemoteInvocationErrorHandler" />
<bean id="serviceExporterDispatcher" class="com.myconsumer.test.ServiceExporterDispatcher">
<property name="businessServiceInterceptor" ref="businessServiceInterceptor" />
<property name="requestContextHandler" ref="requestContextHandler" />
<property name="remoteInvocationErrorHandler" ref="remoteInvocationErrorHandler" />
</bean>
</beans>
I tried with pool connection but it did not improve anything
<?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:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
</bean>
<!-- Administrated objects -->
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="failover:(tcp://localhost:${JMS_PORT})"/>
</bean>
</property>
<!-- <property name="reconnectOnException" value="false"/>
<property name="sessionCacheSize" value="3"/> -->
</bean>
<bean id="queue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="test.service" />
</bean>
<!-- Message listener container for services -->
<bean id="errorHandler" class="com.myconsumer.test.LogErrorHandler"/>
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="pooledConnectionFactory" />
<property name="destination" ref="queue" />
<property name="concurrentConsumers" value="10" />
<property name="maxConcurrentConsumers" value="20" />
<property name="messageListener" ref="serviceExporterDispatcher" />
<property name="errorHandler" ref="errorHandler" />
</bean>
<bean
class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
<property name="concurrency" value="3-10"/>
</bean>
<bean id="securityTokenVerificator" class="com.myconsumer.test.SecurityTokenVerificator">
<property name="authenticationService" ref="authenticationService" />
</bean>
<bean id="businessServiceInterceptor" class="com.myconsumer.test.RemoteInvocationBusinessServiceInterceptor">
<property name="securityTokenVerificator" ref="securityTokenVerificator" />
</bean>
<bean id="requestContextHandler" class="com.myconsumer.test.RequestContextHandler"/>
<bean id="remoteInvocationErrorHandler" class="com.myconsumer.test.RemoteInvocationErrorHandler" />
<bean id="serviceExporterDispatcher" class="com.myconsumer.test.ServiceExporterDispatcher">
<property name="businessServiceInterceptor" ref="businessServiceInterceptor" />
<property name="requestContextHandler" ref="requestContextHandler" />
<property name="remoteInvocationErrorHandler" ref="remoteInvocationErrorHandler" />
</bean>
</beans>
Update config for Producer
<?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:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx"
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/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Initialize service invoker properties -->
<bean id="propertyPlaceHolder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<bean factory-bean="resourceUtils" factory-method="getProperties">
<constructor-arg>
<bean factory-bean="resourceLoader"
factory-method="getResource">
<constructor-arg>
<value>service-invoker/service-invoker.properties</value>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<!-- Administrated objects -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${broker.url}"/>
</bean>
</property>
</bean>
<bean id="queue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="${service.queue}" />
</bean>
<!-- Service Locator -->
<bean id="serviceLocator" class="com.myproducer.test.service.impl.ApplicationServiceLocatorImpl">
<property name="authenticationService" ref="authenticationService"/>
</bean>
<!-- Services -->
<bean id="authenticationService"
class="com.myproducer.test.service.impl.ClientJmsInvokerProxyFactoryBean">
<property name="serviceInterface" value="com.myservicer.test.authentication.v1.AuthenticationService" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="queue" ref="queue" />
<property name="receiveTimeout" value="${receiveTimeout}" />
</bean>
</beans>
Important
My 50000 request is sent frequently, I'm using nodejs to send and send the requests without waiting for the response to test the server.

How can I connect to two different databases, one for reading and one for writing in the same application using Spring?

Use Case: I am running a spring application which has orders. I can create plans for these orders. My dev environment/db does not have any orders and they come from a different application (we share the same db). So, Is there a way I can read orders from production database but when I create a plan, it gets saved to dev database?
My persistence.xml is as below
<?xml version="1.0" encoding="UTF-8" ?>
<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_2_0.xsd"
version="2.0">
<persistence-unit name="Demo_PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.entity.ErrorMessage</class>
<class>com.entity.ErrorMessageTxt</class>
<class>com.entity.ErrorMessageTxtId</class>
<class>com.entity.Language</class>
<class>com.entity.TextEntity</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.InformixDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.id.new_generator_mappings" value="true" />
<property name="hibernate.cache.region.factory_class"
value="net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory" />
<property name="hibernate.cache.use_second_level_cache"
value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<!-- Adding timeouts for Lock Mode and Query -->
<property name="javax.persistence.query.timeout" value="60000" />
<property name="javax.persistence.lock.timeout" value="60000" />
</properties>
</persistence-unit>
</persistence>
My spring-config.xml is as below
<?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:task="http://www.springframework.org/schema/task"
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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:component-scan base-package="com.project"/>
<context:component-scan base-package="com.project2"/>
<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
<task:executor id="myExecutor"/>
<task:scheduler id="myScheduler"/>
<bean id="qa-informix" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/dcSysCommon"/>
</bean>
<bean id="pum" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
<property name="dataSources">
<map>
<entry key="localDataSource" value-ref="qa-informix" />
</map>
</property>
<property name="defaultDataSource" ref="qa-informix"/>
</bean>
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="pum" />
<property name="jpaDialect">
<bean class="com.project.utils.IsolationSupportHibernateJpaDialect"/>
</property>
<property name="persistenceUnitName" value="PYD_PU" />
</bean>
<!-- bean post-processor for JPA annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- this enables the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf" />
</bean>
<bean id="interpolator" class="org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator" />
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="messageInterpolator" ref="interpolator" />
</bean>
<bean class="com.project3.common.core.bo.LanguageBusinessObject" primary="true" />
<bean name="restUtils" class="com.project1.utils.RestUtils" />
<bean id="srvPropertyFile" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="srvPropertyFile" />
</bean>
<bean id="beanConfig" class="io.swagger.jaxrs.config.BeanConfig">
<property name="title" value="Swagger UI for QAS"/>
<property name="version" value="1.0.0" />
<property name="schemes" value="http" />
<property name="host" value="#{srvPropertyFile.hostName}:#{srvPropertyFile.pydPort}" />
<property name="basePath" value="planyourday/#{srvPropertyFile.countryCode}/#{srvPropertyFile.dcNumber}"/>
<property name="resourcePackage" value="com.project1.resources"/>
<property name="license" value="Apache 2.0 License"/>
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
<property name="scan" value="true"/>
</bean>
<bean id="apiListingResource" class="com.project1.utils.SwaggerApiListingResource"/>
<bean id="swaggerSerializers" class="io.swagger.jaxrs.listing.SwaggerSerializers" scope="singleton"/>
</beans>
In my Jetty server config, I am defining the srvPropertyFile which references to the environment.properties file which has the database connection to dev db.
How should I manage my persistence context so that the entity manager used while reading orders and the entity manager used while creating plans connects to different databases?
you have to configure two persistence unit, data source and transaction manager(one for read and other for write) each.
While using entity manager specify the persistence unit like below.
PersistenceUnit(unitName = "x")
EntityManagerFactory entityManagerFactory;

ignoreUnresolvablePlaceholders not working

I am using ignoreUnresolvablePlaceholders in my spring context.
as below.
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:messaging.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="false" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
event setting ignoreUnresolvablePlaceholders to true its not ignoring my spring bean being injecting.
i am passing amq.topic= in property file for
<bean id="messageTopic1" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="${amq.topic}" />
</bean>
But its not ignoring this bean for being injecting.
below is my Spring-context.xml amd property 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:context="http://www.springframework.org/schema/context"
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-3.1.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:messaging.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="false" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
<!-- Active MQ Broker Configuration Details -->
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${amq.url}" />
</bean>
<bean id="messageQueue1" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="${amq.queue}" />
</bean>
<bean id="messageTopic1" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="${amq.topic}" />
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<bean id="activeMQ" class="com.isc.common.messaging.AmqUtilityHelper">
<property name="destination" ref="messageQueue1" />
<property name="jmsTemplate" ref="jmsTemplate" />
</bean>
<!-- <bean id="activeMQ1" class="com.isc.common.messaging.AmqUtilityHelper">
<property name="destination" ref="messageTopic1" />
<property name="jmsTemplate" ref="jmsTemplate" />
</bean> -->
<bean id="messageBroker" class="com.isc.common.messaging.AmqUtilityHelper">
<property name="activeBroker" value="${active.broker}" />
</bean>
</beans>
And Below is the property file that i am loading.
#AMQ/Solace properties production:
# uncomment the borker to use
active.broker=activeMQ
#active.broker=solace
#active.broker=activeMQ
#AMQ Broker Properties
amq.url=failover:(tcp://localhost:61616)??initialReconnectDelay=2000&maxReconnectAttempts=5
amq.queue=messageQueue1
amq.topic=
#Solace Broker Properties
solace.url=smf://192.168.56.101:55555
solace.userName=spring_user#Solace_Spring_VPN
solace.passWord=spring_password
solace.jndiName=JNDI/CF/spring1
solace.queue=JNDI/Q/requests
#solace.topic=JNDI/topic1
By default, ApplicationContext implementations eagerly create and
configure all singleton beans as part of the initialization process.
Generally, this pre-instantiation is desirable, because errors in the
configuration or surrounding environment are discovered immediately,
as opposed to hours or even days later. When this behavior is not
desirable, you can prevent pre-instantiation of a singleton bean by
marking the bean definition as lazy-initialized. A lazy-initialized
bean tells the IoC container to create a bean instance when it is
first requested, rather than at startup.
Can you please try to lazily initialize your bean using below construct.
lazy-init="true"
<bean id="messageTopic1" class="org.apache.activemq.command.ActiveMQTopic"
lazy-init="true">
<constructor-arg value="${amq.topic}" />
</bean>

My Spring Application integration with Alfresco Activity workflow

I have developed web application with spring framework and PostgreSQL,
In my application there is requirement of workflow.
For my application database is different.
I want to integrate Alfresco Activity workflow in may application,
Could any body give how can I integrate Alfresco Activity workflow in may web application?
You may integrate alfresco activity in this way:
maven dependency:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti-version}</version>
</dependency>
spring configuration file like this:
<?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"
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">
<bean id="activitiTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="activitiEngineDataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="activitiEngineDataSource" />
<property name="transactionManager" ref="activitiTransactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="deploymentResources" value="classpath:/bpm/*.bpmn20.xml"/>
<property name="history" value="full" />
<property name="jobExecutorActivate" value="false" />
<property name="mailServerUsername" value="valerio.vaudi#localhost"/>
<property name="mailServerPassword" value="pass"/>
<property name="mailServerHost" value="localhost"/>
<property name="mailServerPort" value="25"/>
<property name="mailServerUseTLS" value="true"/>
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="formService" factory-bean="processEngine" factory-method="getFormService"/>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="itentitiService" factory-bean="processEngine" factory-method="getIdentityService" />
<jdbc:embedded-database id="activitiEngineDataSource" type="H2">
<jdbc:script location="classpath:org/activiti/db/create/activiti.h2.create.engine.sql" />
<jdbc:script location="classpath:org/activiti/db/create/activiti.h2.create.history.sql" />
<jdbc:script location="classpath:org/activiti/db/create/activiti.h2.create.identity.sql" />
</jdbc:embedded-database>
</beans>
use activity eclipse plug-in for editing your bpmn2.0 file
and use the api for use the engine.
how use the api I can suggest to read Activity in action.
I Hope that this can help you

Struts2+Spring 3 validations issue

I am trying to use struts2 validations. I have a setup with Struts2.2.3 and Spring 3.0.5. I have a -validation.xml in place. Fields are getting validated and error message is getting displayed on the server console, but its not getting displayed on the UI. Also action is not getting forwarded to the results specified for the "input" tag.
My action class does not extend from ActionSupport instead it implements Preparable. Is this could be the problem?
So I also tried with my Action class define as
public class CandidateAction extends ActionSupport implements Preparable
on hitting the page i am getting following error
Invalid action class configuration that references an unknown class named [candidateAction]
even though i have a bean defined with name "candidateAction" in the application context.xml
ApplicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="dao" class="org.kovid.dao.impl.DaoImpl" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/xyz" />
<property name="username" value="abc" />
<property name="password" value="abc" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="baseAction" scope="prototype" class="org.kovid.action.BaseAction">
</bean>
<bean id="candidateAction" scope="prototype"
class="org.kovid.matrimony.action.CandidateAction">
<constructor-arg ref="dao" />
</bean>
<bean id="simpleSearchAction" scope="prototype"
class="org.kovid.matrimony.action.SimpleSearchAction">
<constructor-arg ref="dao" />
</bean>
<bean id="advanceSearchAction" scope="prototype"
class="org.kovid.matrimony.action.AdvanceSearchAction">
<constructor-arg ref="dao" />
</bean>
<bean id="imageAction" scope="prototype"
class="org.kovid.matrimony.action.ImageAction">
<constructor-arg ref="dao" />
</bean>
</beans>

Resources