sybase concurrent process/multi-threading

Encountered a multi-threading issue on this stored procedure

CREATE PROCEDURE dbo.spc_get_next_sequence_no
 		(@codedesc			varchar(30),
 		 @next_id			integer OUTPUT)

		select @next_id = next_id from next_number where code_desc = @codedesc

        update next_number set next_id = next_id + 1 where code_desc = @codedesc


table next_number is a record of sequence number for different purpose

code_desc	next_id
receipting_number	732215
receipting_batch_id	2521
conso_tax_extract	230
conso_dist_extract	79
Manual Journal	8933
receipt_number	101891
complaint_num	7
complaint_record_no	128

(I know we should use Sybase sequence, or create table with identity. But this is a legacy database, which I have no control.)

the issue was, there are more than one thread comes in and both threads get the same next_id,

the solutions are two parts:
1. make the SP atomic (begin transaction.. commit transaction)
2. lock the SP (to make it synchronized; update statement first plus the begin and commit transaction)

refer to:

CREATE PROCEDURE dbo.spc_get_next_sequence_no
 		(@codedesc			varchar(30),
 		 @next_id			integer OUTPUT)
        update next_number set next_id = next_id + 1 where code_desc = @codedesc
		select @next_id = next_id from next_number where code_desc = @codedesc


JSP Class file not generated on JRun server

Another team encounter this problem. For updated JSP, it’s been translated and generated into java file. However, the class file not built.

it seems i have been some time away from JSP, or just not been thinking clearly on this issue before jumping in.

i was trying to regenerate the jsp block by block, which finally identified the error block. Without this block, it would compile into classes. So obviously it’s a coding issue.

and it’s actually quite an obvious error:

<%= dataModel.formValidation.getJSObjectCode() ; %>

Quick JDK Default XPath XML parser

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

	public void quickParseCBISResposne() {

		XPath xpath = XPathFactory.newInstance().newXPath();
		String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
				+ "<ApplicationTransactionId xmlns=\"\">"
				+ "<transactionId>6426072</transactionId>"
				+ "<allPriced>false</allPriced>"
				+ "</ApplicationTransactionId>";

		Document document = null;
		try {
			DocumentBuilder builder = DocumentBuilderFactory.newInstance()
			document = builder
					.parse(new InputSource(new StringReader(response)));
		} catch (Exception e) {
			// throw new
			// RuntimeException("The UK New Cash response message could not be parsed. \n\n"
			// + message, e);

		try {
			xpath.evaluate("//transactionId", document);
//xpath.evaluate("//*[local-name() = 'transactionId']", document);//this would ignore name space
		} catch (XPathExpressionException e) {
			// TODO Auto-generated catch block


Quick note if log is not working in apache camel

the reason simply because apache camel is using slf4j,

the slf4j library thus need to be on the classpath.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AnnotationTypeConverterLoader implements TypeConverterLoader {
    public static final String META_INF_SERVICES = "META-INF/services/org/apache/camel/TypeConverter";
    private static final transient Logger LOG = LoggerFactory.getLogger(AnnotationTypeConverterLoader.class);

3045 [main] INFO org.apache.camel.impl.converter.AnnotationTypeConverterLoader - Found 3 packages with 15 @Converter classes to load
3065 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 169 core type converters (total 169 type converters)
3070 [main] INFO org.apache.camel.impl.converter.AnnotationTypeConverterLoader - Loaded 2 @Converter classes

the library could be either slf4j-simple.jar or slf4j-log4j.jar:

http url connection for spring web service template

there is always a “NOT FOUND [404]” issue when parsing the response from web service, or sometimes even when sending the web service; when using spring web service template.

the problem then turns out due to the default http url connection provided by JVM. When i change the connnection to spring provided common http message sender based on Jakata common httpClien, it starts working well.

By the way, JVM provided http url connection sender works well on windows machine. Only when i deploy the application to UNIX, it starts complaining the 404 issue.

anyway, with the spring common http message sender, it works well whether windows or UNIX.

Another thing to note is, when using Spring Web Service template. We just need to pass the SOA message content to webServiceTemplate.sendSourceAndReceiveToResult(). as spring web service template will wrap it using the SOAP envelop.

if we provide envelop again, it also throws 404 issues.