camel sql-stored ends in "java.sql.SQLException: Non supported SQL92 token at position" with Oracle datasource - oracle

When I run the following simple route with a stored-procdure, it results in an exception: "java.sql.SQLException: Non supported SQL92 token at position"
The same route with embedded Derby datasources works as expected.
Question
Any ideas? Is something wrong with my "implementation" or is it a problem of the underlying jar files?
Stack:
camel 2.23.2
ojdbc7.jar
Spring XML
Route:
<?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
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- In Memory Database
<jdbc:embedded-database id="myDataSource" type="DERBY">
<jdbc:script location="classpath:/sql/createAndPopulateDatabase.sql"/>
</jdbc:embedded-database>
-->
<bean id="oracleDataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:#..."/>
<property name="username" value="xx"/>
<property name="password" value="yy"/>
</bean>
<bean id="sql-stored" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="oracleDataSource"/>
</bean>
<camelContext id="camel"
xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<setHeader headerName="in1">
<constant>1</constant>
</setHeader>
<setHeader headerName="in2">
<constant>1</constant>
</setHeader>
<to uri="sql-stored:INOUTDEMO(INTEGER ${headers.in1},INOUT INTEGER ${headers.in2} out1,OUT INTEGER out2)"/>
<log message="Result: ${body}" loggingLevel="INFO" />
</route>
</camelContext>
</beans>
Stored-Procedure:
I know that the procedure would not work in an oracle db, but the exception is thrown "long" before the involved classes / methods would recognize, that the procedure doesn't work / even exist.
CREATE PROCEDURE INOUTDEMO(IN1 INTEGER, INOUT IN2 INTEGER, OUT OUT1 INTEGER)
PARAMETER STYLE JAVA
LANGUAGE JAVA
EXTERNAL NAME
'org.apache.camel.component.sql.stored.TestStoredProcedure.inoutdemo';
Stacktrace:
Caused by: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException; SQL state [99999]; error code [17034]; Nicht unterstütztes SQL92-Token in Position: 20; nested exception is java.sql.SQLException: Nicht unterstütztes SQL92-Token in Position: 20
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1414)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:632)
at org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:116)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:76)
at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:186)
at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:86)
at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:541)
at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:506)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:369)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:506)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:229)
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:144)
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:161)
... 30 more
Caused by: java.sql.SQLException: Nicht unterstütztes SQL92-Token in Position: 20
at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:1306)
at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:1192)
at oracle.jdbc.driver.OracleSql.getSql(OracleSql.java:326)
at oracle.jdbc.driver.OracleParameterMetaData.getParameterMetaData(OracleParameterMetaData.java:46)
at oracle.jdbc.driver.OraclePreparedStatement.getParameterMetaData(OraclePreparedStatement.java:11621)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getParameterMetaData(OraclePreparedStatementWrapper.java:1552)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:162)
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:120)
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:1)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617)
... 48 more

For oracle procedure/function parameters it should be variable name followed by in/out followed by data type.
E.g "out1 out integer"

The only way I made it "work" was like that:
<to uri="sql-stored: CALL HELLOWORLD(:#testValue,:#result)"/-->
With that - no IN, INOUT, OUT or type argument and "CALL" - it is at least possible to execute the stored procedure in the oracle db.
Unfortunately, I am still struggeling to map the return value op the stored procedure back to camel header oder body variable.

Related

Spring Batch - Sporadic issues with Custom FileItemWriter

We have multiple jobs running in Linux environment where jobs run in parallel. We process files with multi-hundred thousands of records in each of these batches. Following is our job steps.xml. This job runs daily but it fails sporadically. It runs 95% of times without any issues but when it fails it fails with below error. Can someone please check what is wrong with our configuration and tell how to address this?
Error:
"org.springframework.batch.item.ItemStreamException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter': Initialization of bean failed; nested exception is java.lang.IllegalStateException: **Not allowed to access field 'outputFile2': java.lang.IllegalAccessException: Class org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1 can not access a member of class com.xxx.xx.std.StdFileItemWriter with modifiers "private"**
at org.springframework.batch.jsr.item.CheckpointSupport.open(CheckpointSupport.java:65)
at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:96)
at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:310)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.jsr.job.flow.support.state.JsrStepState.handle(JsrStepState.java:53)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.jsr.job.flow.JsrFlowJob.doExecute(JsrFlowJob.java:82)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
at org.springframework.batch.core.jsr.launch.JsrJobOperator$2.run(JsrJobOperator.java:675)
at java.lang.Thread.run(Thread.java:809)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.com.xxx.xx.batchsync.BatchsyncExtractFileItemWriter': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Not allowed to access field 'outputFile2': java.lang.IllegalAccessException: Class org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor$1 can not access a member of class com.xxx.xx.std.StdFileItemWriter with modifiers "private"
at org.springframework.beans.factory.support.AbstractAutowireCapa"
Steps.xml:
enter code here
<step id="#{jobParameters['STEPNAME']}-Step1">
<properties>
<property name="JOB_FILE_NAME" value="BatchsyncExtract"/>
<property name="JOBNAME" value="#{jobParameters['JOBNAME']}"/>
<property name="STEPNAME" value="#{jobParameters['STEPNAME']}"/>
<property name="APPL" value="#{jobParameters['APPL']}"/>
<property name="BANK" value="#{jobParameters['BANK']}"/>
<property name="ODATE" value="#{jobParameters['ODATE']}"/>
<property name="PREVENT_JOB_RESTART" value="#{jobParameters['PREVENT_JOB_RESTART']}"/>
<property name="BATCH_ROOT" value="#{jobParameters['BATCH_ROOT']}"/>
<property name="WSBATCH_HOME" value="#{jobParameters['WSBATCH_HOME']}"/>
<property name="BATCH_LOG_FOLDER" value="#{jobParameters['BATCH_ROOT']}/batch/logs"/>
<property name="BUSINESS_MAIN" value="com.xxx.xx.BatchsyncExtractBusinessmain"/>
<property name="PROGRAM_NAME" value="IV-IpBatchsyncExtract"/>
<property name="TODAY" value="#{jobParameters['TODAY']}"/>
....
<property name="PARTITION" value="#{jobParameters['WSBATCH_HOME']}/partinfo/BatchsyncExtract_LdbidIpIdPartition_#{jobParameters['BANK']}.xml"/>
<property name="CHUNKSIZE" value="#{jobParameters['CHUNKSIZE']}" />
</properties>
<listeners>
<listener ref="com.xxx.xx.std.StdStepListener">
</listener>
<listener ref="com.xxx.xx.std.StdChunkListener">
</listener>
</listeners>
<chunk checkpoint-policy="custom" >
<reader ref="com.xxx.xx.BatchsyncExtractInputBDS">
</reader>
<processor ref="com.xxx.xx.std.StdJobStepCursorBased"/>
<writer ref="com.xxx.xx.BatchsyncExtractFileItemWriter">
<properties>
<property name="outputFile1" value="#{jobParameters['BATCH_ROOT']}/batch/import/#{jobParameters['APPL']}/batchsync_extract_#{jobParameters['BANK']}_#{jobParameters['ODATE']}_#{jobParameters['RUN']};default;default" />
<property name="outputFile2" value="#{jobParameters['BATCH_ROOT']}/batch/import/#{jobParameters['APPL']}/batchsync_extract_totals_#{jobParameters['BANK']}_#{jobParameters['ODATE']}_#{jobParameters['RUN']};default;default" />
</properties>
</writer>
<checkpoint-algorithm ref="com.xxx.xx.batch.utils.CustomCheckPointAlgoritmn">
<properties>
<property name="chunkSize" value="#{jobParameters['CHUNKSIZE']}" />
<!--property name="timeInterval" value="#{jobParameters['TIMEINTERVAL']}" /-->
</properties>
</checkpoint-algorithm>
</chunk>
</step>

BeanDefinitionStoreException IOException while accessing the application context file

writing a simple spring program to read the bean from the filepathxmlapplication context, but getting the below exception.
but i am sure in can access the xml bean definition file.
public void testConnection() {
try{
List <LnkConnectionResponse> connResponse = new ArrayList <LnkConnectionResponse> ();
log.info ("before xml resource");
ApplicationContext context = new FileSystemXmlApplicationContext("M:/My Documents/workspace-sts-3.7.0.RELEASE/LDODashBoard/src/main/webapp/WEB-INF/mvc-database.xml");
log.info ("before get bean");
LnkConnectionWrapper linkConnectionArray = (LnkConnectionWrapper)context.getBean("linkConnectionArray");
xml bean 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:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:lang="http://www.springframework.org/schema/lang"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
<util:list id="dbnameList" list-class="java.util.ArrayList">
<value>LDMDB</value>
<value>GCMMDB</value>
<value>CVDBCHECKOUT</value>
<value>CVEMEADBCHECKOUT</value>
<value>LDMDB</value>
<value>OPUSDB</value>
<value>CDRDB</value>
<value>TLMDB</value>
</util:list>
<util:list id="urlList" list-class="java.util.ArrayList">
<value>ldmUnprocessedLink</value>
<value>gcmmLink2</value>
<value>dbCheckout</value>
<value>dbCheckoutEMEA</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
<value>dbCheckout</value>
</util:list>
<util:list id="QueryList" list-class="java.util.ArrayList">
<value>select count( * ) from futures.EXMAN_STAGING where REGION = 'LONDON' and process_time_stamp is null</value>
<value>select count( * ) from futures.EXMAN_STAGING where REGION = 'LONDON' and process_time_stamp is null</value>
<value>select name from v$database } select market from cv_welcome where rownum < 2</value>
<value>select market from cvision.cv_welcome where rownum < 2</value>
<value>select 'X' from dual</value>
<value>select 'X' from dual } select GET_PREV_BIZ_DATE from dual </value>
<value>select dummy from dual } Select PREV_BUSINESS_DATE From gmirpt.SD_GMI_PROCDATE Where REGION_IND = 'ATL'</value>
<value>select 'X' from dual</value>
</util:list>
<bean id="DBQueryBean" class="com.connection.impl.DBQueryImpl">
<property name="DBName">
<ref bean="dbnameList"/>
</property>
<property name="UrlName">
<ref bean="urlList"/>
</property>
<property name="QueryString">
<ref bean="QueryList"/>
</property>
</bean>
<bean id="LdmDatabaseBean" class="com.connection.impl.LDMConnectionImpl">
<property name="dbQuery" ref="DBQueryBean"/>
</bean>
<bean id="tlmWebConnectlink" class="com.implementation.LnkConnectionCheck">
<property name="urlIDDesc" value="TLMWebConnect" />
<property name="urlIDGroup" value="tlmlink" />
<property name="urlLink" value="https://tlmapp.csintra.net/WebConnect/login/login.jsp" />
<property name="urlDescription" value="TLM Web Connnect" />
</bean>
<bean id="linkConnectionArray" class="com.implementation.LnkConnectionWrapper">
<property name="lnkConnectionCheck">
<list>
<ref bean="tlmWebConnectlink" />
</list>
</property>
</bean>
</beans>
Exception logs
INFO TestLnkConnection - before xml resource INFO
FileSystemXmlApplicationContext - Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext#61d83ac7:
startup date [Thu Dec 17 06:48:07 GMT+08:00 2015]; root of context
hierarchy INFO XmlBeanDefinitionReader - Loading XML bean definitions
from file [M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml]
ERROR TestLnkConnection - Exception Received here!!!
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from file [M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml]; nested exception is java.io.FileNotFoundException: M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml
(The system cannot find the path specified) at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:343)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
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:129)
at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
at
org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:140)
at
org.springframework.context.support.FileSystemXmlApplicationContext.(FileSystemXmlApplicationContext.java:84)
at
com.implementation.TestLnkConnection.testConnection(TestLnkConnection.java:47)
at
com.implementation.TestLnkConnection.main(TestLnkConnection.java:73)
Caused by: java.io.FileNotFoundException: M:\My
Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml
(The system cannot find the path specified) at
java.io.FileInputStream.open(Native Method) at
java.io.FileInputStream.(FileInputStream.java:146) at
org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:114)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
... 14 more
If you look at the log your problem is the FileNotFoundException.
java.io.FileNotFoundException: M:\My Documents\workspace-sts-3.7.0.RELEASE\LDODashBoard\src\main\webapp\WEB-INF\mvc-database.xml (The system cannot find the path specified)
You need to ensure you are properly referencing the file in your web application as well as making sure its is in the correct location.

EhCache Jgroups Replication

In my sping based project (spring version 4.1.5.FINAL), I'm using ehcache-core version 2.6.10, ehcache-jgroupsreplication versione 1.7 and jgroups 3.1.0.FINAL
This is my XML ehcache configuration:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="webCache" >
<diskStore path="java.io.tmpdir/webCache"/>
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties="udp.xml"/>
<cache name="it.test.cache.CustomCache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="600"
timeToLiveSeconds="6000"
overflowToDisk="true">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true,replicateUpdatesViaCopy=false,replicateRemovals=true" />
</cache>
</ehcache>
This is my upd.xml configuration:
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
<UDP
mcast_port="${jgroups.udp.mcast_port:45588}"
tos="8"
ucast_recv_buf_size="200K"
ucast_send_buf_size="200K"
mcast_recv_buf_size="200K"
mcast_send_buf_size="200K"
max_bundle_size="64K"
max_bundle_timeout="30"
ip_ttl="${jgroups.udp.ip_ttl:2}"
enable_diagnostics="true"
thread_naming_pattern="cl"
timer_type="new"
timer.min_threads="4"
timer.max_threads="10"
timer.keep_alive_time="3000"
timer.queue_max_size="500"
thread_pool.enabled="true"
thread_pool.min_threads="2"
thread_pool.max_threads="8"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="true"
thread_pool.queue_max_size="10000"
thread_pool.rejection_policy="discard"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Run"/>
<PING />
<MERGE3 max_interval="30000"
min_interval="10000"/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout="1500" />
<BARRIER />
<pbcast.NAKACK use_mcast_xmit="true"
retransmit_timeout="300,600,1200"
discard_delivered_msgs="true"/>
<UNICAST/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true" join_timeout="3000"
view_bundling="true"/>
<UFC max_credits="2M"
min_threshold="0.4"/>
<MFC max_credits="2M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K" />
<pbcast.STATE_TRANSFER />
</config>
In my spring xml context I have the following (I'll put just a fragment of my spring context file):
<bean id="settaSystemProps" name="settaSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="getProperties" />
</bean>
</property>
<property
name="targetMethod" value="putAll" />
<property
name="arguments">
<util:properties>
<prop key="jgroups.logging.log_factory_class">it.test.cache.replication.jgroups.log.logback.impl.LogbackLogImpl</prop>
<prop key="java.net.preferIPv4Stack">true</prop>
</util:properties>
</property>
</bean>
<bean id="webCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" depends-on="settaSystemProps">
<property name="configLocation" value="classpath:webCoMiEhCacheCfg.xml"/>
</bean>
Sadly, by using this configuration, I'm not able in sending/receiving messages in the cluster
When I start my tomcat I see the following print (and it's not using my custom log):
feb 27, 2015 10:31:18 AM org.jgroups.logging.JDKLogImpl error Grave:
failed sending message to cluster (65 bytes): java.lang.Exception:
dest=/228.8.8.8:45588 (68 bytes), cause: java.io.IOException: Invalid
argument
feb 27, 2015 10:31:19 AM org.jgroups.logging.JDKLogImpl error
Grave: failed sending message to cluster (65 bytes):
java.lang.Exception: dest=/228.8.8.8:45588 (68 bytes), cause:
java.io.IOException: Invalid argument
feb 27, 2015 10:31:28 AM
org.jgroups.logging.JDKLogImpl error Grave: failed sending message to
cluster (65 bytes): java.lang.Exception: dest=/228.8.8.8:45588 (68
bytes), cause: java.io.IOException: Invalid argument feb 27, 2015
10:31:28 AM org.jgroups.logging.JDKLogImpl error Grave: failed sending
message to cluster (65 bytes): java.lang.Exception:
dest=/228.8.8.8:45588 (68 bytes), cause: java.io.IOException: Invalid
argument
Can anybody tell me where I'm wrong? What I need is to synchronize EhCache on a cluster formed by 2 nodes
Can anybody provide to me a working configuration sample?
thank you
Angelo
What's the output when you start an instance ? I think you might still be using IPv6. Can you use -Djava.net.preferIPv4Stack=true instead of defining this in the XML ?

apache-camel apache-cxf IllegalStateException: Could not register object under bean name 'cxf': there is already object bound

Camel Version: 2.12.2,
CXF Version: 2.7,
Apache Tomcat: 7
I have the following camel-cxf.xml :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s0="http://www.huawei.com/bme/cbsinterface/cbs/businessmgr"
xmlns:s1="http://www.huawei.com/bme/cbsinterface/cbs/accountmgr"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
<cxf:cxfEndpoint id="oneEndpoint"
address="${endpoint.address}"
serviceName="s1:WebService"
serviceClass="WebserviceClass"
endpointName="s1:WebSericePort_http"
wsdlURL="classpath:wsdl/WebService.wsdl">
<cxf:inInterceptors>
<ref bean="loggingInInterceptor" />
<ref bean="setSoapVersionInterceptor"/>
</cxf:inInterceptors>
<cxf:inFaultInterceptors>
<ref bean="loggingInInterceptor" />
<ref bean="setSoapVersionInterceptor"/>
</cxf:inFaultInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outFaultInterceptors>
</cxf:cxfEndpoint>
<http-conf:conduit name="*.http-conduit">
<http-conf:client
Connection="Keep-Alive"
ConnectionTimeout="60000"
ReceiveTimeout="90000"/>
</http-conf:conduit>
</beans>
In my camel-context I have two processors that use the cxf endpoint to invoke two different operations. To do that I use a producerTemplate which uses "cxf:bean:oneEndpoint" as a uri.
The project is a web application deployed in Tomcat 7.
The processors consume from two different queues. After deployment both queues are propagated with a message. The problem is that one of the processors will throw an exception upon invoking the send method on the producer template. The other will work fine. The exception is:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint:
cxf://bean:oneEndpoint due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oneEndpoint': Initialization of bean failed;
nested exception is java.lang.IllegalStateException: Could not register object [org.apache.cxf.bus.spring.SpringBus#4b0af74c] under bean name 'cxf':
there is already object [org.apache.cxf.bus.spring.SpringBus#24c0fe59] bound
Full stacktrace can be found here: http://pastebin.com/cDsQZ9r3
The second time the queues receive a message at the same time, everything works fine.
Any ideas?
PS. My web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/META-INF/spring/*.xml</param-value>
</context-param>
</web-app>
Routes & Processors:
<route id="route1" errorHandlerRef="eh1">
<from uri="{{queue1}}" />
<setHeader headerName="operationName">
<constant>Operation_1</constant>
</setHeader>
<process ref="FirstProcessor" />
<choice>
<when>
<simple>${in.headers.STATUS} == 'OK'</simple>
<inOnly uri="{{result_queue}}" />
</when>
<otherwise>
<inOnly uri="{{nok_result_queue}}" />
</otherwise>
</choice>
</route>
<route id="route2" errorHandlerRef="eh2">
<from uri="{{queue2}}" />
<setHeader headerName="operationName">
<constant>Operation_2</constant>
</setHeader>
<process ref="SecondProcessor" />
<choice>
<when>
<simple>${in.headers.STATUS} == 'OK'</simple>
<inOnly uri="{{result_queue}}" />
</when>
<otherwise>
<inOnly uri="{{nok_result_queue}}" />
</otherwise>
</choice>
</route>
<property name="producerTemplate" ref="firstProcessorTemplate" />
<property name="producerTemplateUri"
value="cxf:bean:oneEndpoint?headerFilterStrategy=#headerFilterStrategy" />
<property name="producerTemplate" ref="secondProcessorTemplate" />
<property name="producerTemplateUri"
value="cxf:bean:oneEndpoint?headerFilterStrategy=#headerFilterStrategy" />
The problem is that both queues are getting a message at the same time so both of them are trying to initialise the SpringBus at the same time.
The problem is that in BusWiringBeanFactoryPostProcessor it this code:
if (!context.containsBean(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) {
SpringBus b = new SpringBus();
ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)context;
cctx.getBeanFactory().registerSingleton(name, b);
b.setApplicationContext(context);
}
So when two beans both try and initialise the SpringBus in two different threads, they can both enter the if statement at the same time leading to the exception.
The solution is to define a SpringBus in the application context so neither bean will try create a new SpringBus as one already exists.
Please share the routes definition which consumes messages from two different queues. Also you can look for option of using multicasting to have parallel processing in consuming messages from both queues and proceed with further opertion.<route>
<from uri="cxf:bean:oneEndpoint"></from>
<recipientList>
<simple>direct:${header.operationName}</simple>
<log message="Got ${header.operationName}" />
</recipientList>
</route>
Your routes (route1 and route) can be renamed as same as webservice operation name. Our code is also something similar to yours. We haven't faced problem with this approach.

One of '{"http://www.mulesoft.org/schema/mule/jdbc":abstract-query}' is expected

I am trying implement XA Transaction with oracle database connector in Mule Studio. When I try to deploy this mule application on MuleStudio server I am getting below exception.
Exception:
"Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'url' of bean class [oracle.jdbc.xa.client.OracleXADataSource]: Bean property 'url' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?"
Mule Configuration xml file:
<jdbc-ee:oracle-data-source name="Oracle_Data_Source" user="system" password="manager" url="jdbc:oracle:thin:#//localhost:1521/xe" transactionIsolation="UNSPECIFIED" doc:name="Oracle Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="oracleJdbcBean" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<jbossts:transaction-manager doc:name="Transaction Manager"/>
<spring:beans>
<spring:bean id="oracleJdbcBean" name="oracleJdbcBean" class="oracle.jdbc.xa.client.OracleXADataSource">
<spring:property name="user" value="system"/>
<spring:property name="password" value="manager"/>
<spring:property name="url" value="jdbc:oracle:thin:#localhost:1521:xe"/>
</spring:bean>
</spring:beans>
<flow name="oraclexatransactionFlow1" doc:name="oraclexatransactionFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="testTable" doc:name="HTTP"/>
<ee:xa-transactional action="ALWAYS_BEGIN" doc:name="Transactional">
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="testQuery" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<xa-transaction action="ALWAYS_JOIN"/>
<jdbc-ee:query key="testQuery" value="select * from test"/>
</jdbc-ee:outbound-endpoint>
</ee:xa-transactional>
</flow>
I have followed the above configuration for other application to make xa transaction work with oracle database but I am getting different exception as below:
Caused by: org.xml.sax.SAXParseException; lineNumber: 195; columnNumber: 55; cvc-complex-type.2.4.a: Invalid content was found starting with element 'xa-transaction'. One of '{"http://www.mulesoft.org/schema/mule/jdbc":abstract-query}' is expected.
Please correct me if I configured anything wrong.
Url property should probably be
<spring:property name="url" value="jdbc:oracle:thin:#//localhost:1521/XE"/>
Uppercase of "URL" worked for me to resolve the first problem i.e.,
<spring:property name="URL" value="jdbc:oracle:thin:#localhost:1521:xe" />
And the second problem was resolved by placing the "xa-transaction" element before the query as below.
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="testQuery" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<xa-transaction action="NONE" />
<jdbc-ee:query key="testQuery" value="select * from test" />

Resources