In the broadleaf demo site, after ordering I have seen..
A confirmation email has been sent to xyz#abc.com
But the email doesn't seem to go because it wasn't configured. I tried making these changes to my applicationContext-email.xml 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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<!-- A dummy mail sender has been set to send emails for testing purposes only
To view the emails sent use "DevNull SMTP" (download separately) with the following setting:
Port: 30000 -->
<bean id="blMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host"><value>smtp.mandrillapp.com</value></property>
<property name="port"><value>900</value></property>
<property name="protocol"><value>smtp</value></property>
<property name="username"><value>xyz#abc.com</value></property>
<property name="password"><value>mypassword</value></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtp.timeout">25000</prop>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
<bean id="blEmailTemplateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
<property name="prefix" value="emailTemplates/" />
<property name="suffix" value=".html" />
<property name="cacheable" value="${cache.page.templates}"/>
<property name="cacheTTLMs" value="${cache.page.templates.ttl}" />
</bean>
<bean id="blEmailTemplateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="blEmailTemplateResolver" />
</set>
</property>
<property name="dialects">
<set>
<bean class="org.thymeleaf.spring3.dialect.SpringStandardDialect" />
<ref bean="blDialect" />
</set>
</property>
</bean>
<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.ThymeleafMessageCreator">
<constructor-arg ref="blEmailTemplateEngine"/>
<constructor-arg ref="blMailSender"/>
</bean>
<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.NullMessageCreator">
<constructor-arg ref="blMailSender"/>
</bean>
<bean id="blEmailInfo" class="org.broadleafcommerce.common.email.service.info.EmailInfo">
<property name="fromAddress"><value>support#mycompany.com</value></property>
<property name="sendAsyncPriority"><value>2</value></property>
<property name="sendEmailReliableAsync"><value>false</value></property>
</bean>
<bean id="blRegistrationEmailInfo" parent="blEmailInfo">
<property name="subject" value="You have successfully registered!"/>
<property name="emailTemplate" value="register-email"/>
</bean>
<bean id="blForgotPasswordEmailInfo" parent="blEmailInfo">
<property name="subject" value="Reset password request"/>
<property name="emailTemplate" value="resetPassword-email"/>
</bean>
<bean id="blOrderConfirmationEmailInfo" parent="blEmailInfo">
<property name="subject" value="Your order with The Heat Clinic"/>
<property name="emailTemplate" value="orderConfirmation-email"/>
</bean>
</beans>
I have also seen a class called SendOrderConfirmationEmailActivity class. This class seems to send the email. This is listed in the activities in applicationContext-workflow.xml but I am getting the following exception.
[ERROR] 00:07:19 ContextLoader - Context initialization failed
[artifact:mvn] org.springframework.beans.FatalBeanException: Unable to merge source and patch locations; nested exception is org.broadleafcommerce.common.extensibility.context.merge.exceptions.MergeException: java.lang.NullPointerException
[artifact:mvn] at org.broadleafcommerce.common.extensibility.context.MergeApplicationContextXmlConfigResource.getConfigResources(MergeApplicationContextXmlConfigResource.java:86)
[artifact:mvn] at org.broadleafcommerce.common.web.extensibility.MergeXmlWebApplicationContext.loadBeanDefinitions(MergeXmlWebApplicationContext.java:130)
[artifact:mvn] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
Could you tell me the way of how to send order confirmation email?
I am using Broadleaf commerce demo 3.1.0-GA version.
You seem to have two blMessageCreator beans defined, the second a NullMessageCreator. I would remove the latter from your configuration and try again.
My configuration is more or less the same as your's except with just the ThymeleafMessageCreator defined. I reproduced your issue by adding the second blMessageCreator definition.
Also you mention seeing the SendOrderConfirmationEmailActivity class. Just be sure to check that you have an implementation of SendOrderConfirmationEmailActivity (if you didn't fork from a recent DemoSite version). You will need to provide this to link it up in the blCheckoutWorkflow which you override in applicationContext-workflow.xml. I believe you can find a demo implementation in the DemoSite app here.
Hope this gets you going.
Related
I am new to Spring batch and trying to write multiple XML files for each record that I am going to read from database table. Suppose if I read 10 records, I need to create 10 XML files. One for each record.
The name for each XML file should be unique. For that, I am planning to use "column_name1" value but I am not sure how to achieve that. If anyone can help me in this then that would be a great help.
Updated:
Added the #{formsPMVRowMapper.id} to resource property which can point to DefaultOutboundIFMRowMapper(Custom implementation of RowMapper) where I created a class level variable to set the row id. but still it's not working since it tries to call getter of ID even before getting into mapRow method which I think correct behviour but I am not sure how to get hold of that ID which I can use as resource name for my file in multiXmlFileItemWriter.
Could someone please let me know what could be the possibly correct way to do this?
Below is my Spring batch configuration file.
<util:properties id="batchProperties">
<prop key="batch.output.file">${outbound.pmv.filename}</prop>
</util:properties>
<bean id="itemReader" parent="pagingItemReader">
<property name="queryProvider" ref="outboundQueryProvider" />
<property name="rowMapper" ref="pmvRowMapper" />
</bean>
<bean id="pmvRowMapper"
class="tx.oag.cs.txcses.arch.batch.readers.DefaultOutboundIFMRowMapper">
<property name="idName" value="outbound_locate_record_staging_id" />
</bean>
<bean id="outboundQueryProvider" class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause"
value="select column_name1" />
<property name="fromClause" value="from table_name" />
<property name="whereClause"
value="where column_name1='AAA' and column_name1='bbbb'" />
<property name="sortKey" value="column_name1" />
</bean>
<bean id="batchProcessor" parent="outboundStagingBatchProcessor">
<property name="entityClass"
value="Class_Name" />
</bean>
<bean id="itemWriter" parent="multiXmlFileItemWriter"/>
<bean id="multiXmlFileItemWriter"
class="org.springframework.batch.item.file.MultiResourceItemWriter">
<property name="resource" value="${outbound.ifm.outbound}/#{pmvRowMapper.id}">
</property>
<property name="delegate">
<bean class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="marshaller">
<bean class="tx.oag.cs.txcses.arch.batch.utils.XMLStringMarshaller" />
</property>
</bean>
</property>
<property name="itemCountLimitPerResource" value="1" />
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"
value="classpath:config/env/#{#env}/batch-outbound.properties" />
<property name="properties" ref="batchProperties" />
<property name="localOverride" value="true" />
</bean>
I understand that above "resource" property can only write files with same name but I am not sure how to use "resource" property well in co-ordination with "resourceSuffixCreator" property.
I am setting up a Spring hibernate H2 application. When the server starts everything works but after an update (rebuild project in eclipse without restarting Tomcat) I get the following error messages saying that the database file can't be accessed.
Error Messages:
java.lang.IllegalStateException: The file is locked: nio:/home/bob/dataStore.mv.db [1.4.187/7]
java.nio.channels.OverlappingFileLockException
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Database may be already in use:
After Googling this error I tried adding File_LOCK=NO and DB_CLOSE_ON_EXIT=TRUE to the URL but no luck.
Context.xml file
<context:annotation-config />
<context:component-scan base-package="com" />
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<!-- <property name="url" value="jdbc:h2:tcp://localhost/~/dataStore;FILE_LOCK=NO;DB_CLOSE_ON_EXIT=TRUE" /> -->
<property name="url" value="jdbc:h2:file:~/dataStore;FILE_LOCK=NO;DB_CLOSE_ON_EXIT=TRUE;MVCC=TRUE" />
<property name="username" value="" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.entities" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.enable_lazy_load_no_trans">true</prop>
<prop key="format_sql">true</prop>
<prop key="use_sql_comments">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
What can I do so that the database does not get locked every time the project is rebuilt.
Also, eclipse is rebuilding the application after everytime the database is updated. How can I stop this?
Try DB_CLOSE_ON_EXIT=FALSE, from the Spring docs
If, for whatever reason, you do configure the connection URL for an embedded database, care should be taken to ensure that the database’s automatic shutdown is disabled. If you’re using H2 you should use DB_CLOSE_ON_EXIT=FALSE to do so.
if need to create multipul connecation then you need to use below code :
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/C:\Database\Data\production;"/>
Apache Ignite servers deployed on two machines automatically shut down. No concrete clue in logs. I am able to see following warning message in log file :
[00:35:14,047][WARNING][tcp-disco-sock-reader-#86379%null%][TcpDiscoverySpi] Failed to read magic header (too few bytes received) [rmtAddr=/10.96.36.48:47830, locAddr=/10.96.36.48:47500]
How can i debug and solve this issue ?
Configuration:
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="xyxCache" />
<property name="writeSynchronizationMode" value="FULL_SYNC" />
<property name="cacheMode" value="REPLICATED" />
<property name="rebalanceMode" value="SYNC" />
<property name="readFromBackup" value="true" />
<property name="startSize" value="150000" />
<property name="evictionPolicy">
<bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
<property name="maxSize" value="1000000" />
</bean>
</property>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<value>10.96.36.48:47500</value>
<value>10.96.36.214:47500</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
Check which process on 10.96.36.48 machine binded to port 47830.
For example, netstat -lnp will list the pid and process name next to each listening port. This will work under Linux.
This usually happens if some other application like telnet connects to the port.
Please share your configuration and setup details, without which it is not possible to answer any further.
I have an application which uses embedded activeMQ 5.11. At the start of the application it creates activemq-data\producerBroker\KahaDB folder at the class path location. I do want to change the location but spring.xml doesn't take a location.
Spring.xml as given,
<bean id="producerBroker" class="org.apache.activemq.broker.SslBrokerService">
<property name="brokerName" value="producerBroker" />
<property name="persistent" value="true" />
<property name="persistenceAdapter" ref="persistenceAdapter"/>
<property name="transportConnectors">
<list>
<bean class="org.apache.activemq.broker.TransportConnector">
<property name="name" value="xxx"></property>
<property name="uri" value="${transportConnectorURIs}"></property>
</bean>
</list>
</property>
<property name="jmsBridgeConnectors">
<list>
<bean class="org.apache.activemq.network.jms.JmsQueueConnector">
<property name="outboundQueueConnectionFactory">
<bean class="org.apache.activemq.ActiveMQSslConnectionFactory">
<property name="brokerURL" value="${brokerURL}" />
<property name="userName" value="${username}" />
<property name="password" value="${password}" />
<property name="trustStore" value="${trust.store.path}" />
<property name="trustStorePassword" value="${trust.store.password}" />
<!-- <property name="keyStore" value="${key.store.path}"/> -->
<!-- <property name="keyStorePassword" value="${key.store.password}"/> -->
</bean>
</property>
<property name="outboundQueueBridges">
<list>
<bean class="org.apache.activemq.network.jms.OutboundQueueBridge">
<constructor-arg value="${screenshotQueueName}" />
</bean>
<bean class="org.apache.activemq.network.jms.OutboundQueueBridge">
<constructor-arg value="${resultXmlQueueName}" />
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
<bean id="persistenceAdapter" class="org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter">
<property name="directory" value="E:\test"/>
Current issue is it throws an error as "exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.activemq.store.kahadaptor.KahaPersistenceA
apter] for bean with name 'kahaPersistenceAdapter' defined in class path resource [spring/resultupload/resultupload.xml]; nested exception is java.la
g.ClassNotFoundException: org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter"
Anyone has experience in the directory change in activeMQ 5.11 in java spring?
The destination of the persistence location must be defined at the broker level.
The kahaPersistenceAdapter (which was file based) was removed with version 5.9. You should use the kahaDB.
kahaDB - uses KahaDB an embedded lightweight non-relational database
<broker brokerName="broker" persistent="true" useShutdownHook="false">
<transportConnectors>
<transportConnector uri="tcp://localhost:61616"/>
</transportConnectors>
<persistenceAdapter>
<kahaDB directory="e:/temp" ... />
</persistenceAdapter>
</broker>
all valid attributes: http://activemq.apache.org/schema/core/activemq-core-5.11.0-schema.html#kahaDB
My Java app uses embedded Jetty 9.2.2. I added a library to pom.xml containg web_fragment.xml file. But the fragment is not picked up by Jetty. When I start the application I can see in logs that the library is loaded. However when a request is made to a servlet from the library, the app returns 404.
How to make it to work?
In the app there is a Spring configuration file dispatcher-servlet.xml and the library is included there:
<import resource="classpath:/web.fragment.lib.spring.xml" />
There is no web.xml file, but the app contains spring.xml file with mappings. It uses the dispatcher-servlet.xml 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-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
default-lazy-init="false">
<context:annotation-config/>
<context:property-placeholder system-properties-mode="FALLBACK" location="classpath:config.properties"/>
<bean name="WebServer" class="org.eclipse.jetty.server.Server" init-method="start">
<property name="connectors">
<list>
<bean name="LocalSocket" class="org.eclipse.jetty.server.ServerConnector">
<constructor-arg ref="WebServer"/>
<property name="host" value="0.0.0.0"/>
<property name="port" value="${jetty.port}"/>
</bean>
</list>
</property>
<property name="handler">
<bean class="org.eclipse.jetty.server.handler.HandlerCollection">
<property name="handlers">
<list>
<bean class="org.eclipse.jetty.servlet.ServletContextHandler">
<property name="sessionHandler">
<bean class="org.eclipse.jetty.server.session.SessionHandler"/>
</property>
<property name="contextPath" value="${context.path}"/>
<property name="servletHandler">
<bean class="org.eclipse.jetty.servlet.ServletHandler">
<property name="servlets">
<list>
<bean class="org.eclipse.jetty.servlet.ServletHolder">
<property name="name" value="dispatcherServlet"/>
<property name="servlet">
<bean class="org.springframework.web.servlet.DispatcherServlet"/>
</property>
<property name="initParameters">
<map>
<entry key="contextConfigLocation" value="**classpath:dispatcher-servlet.xml**"/>
</map>
</property>
</bean>
</list>
</property>
<property name="servletMappings">
<list>
<bean class="org.eclipse.jetty.servlet.ServletMapping">
<property name="pathSpecs">
<list>
<value>/</value>
</list>
</property>
<property name="servletName" value="dispatcherServlet"/>
</bean>
</list>
</property>
</bean>
</property>
</bean>
</list>
</property>
</bean>
</property>
</bean>
</beans>
Web Fragment auto configuration is a feature of the WebAppContext's Configuration layers.
In your example, you are using neither.
You are using Jetty, in an embedded sense, and are building up the list of servlets manually.
You'll either have to switch to building up your application via a WebAppContext or manually have to add the features that those web fragments provide.
The important thing to understand, is that web fragments are fragments of the webapp descriptor, which is a complicated feature of a webapp, which is something that is tracked by the WebAppContext, which is something that is configured by the list of Configuration layers defined in that specific WebAppContext.