How to set JMSXUserID in Websphere MQ using Spring JMS

Every time I work with MQ and Spring JMS I want to poke my eyes out with a dull instrument. It’s always a pain in the neck. My most recent challenge was trying to get the JMSXUserID field to flow through to the application on the other side of MQ.

First, I created a MessagePostProcessor to add the JMS header

public class MyMessagePostProcessor implements MessagePostProcessor  
{  
	private String userId;

	@Override  
	public Message postProcessMessage(Message msg) throws JMSException  
	{  
		msg.setStringProperty(JmsConstants.JMS_IBM_MQMD_USERIDENTIFIER, userId);  
		msg.setStringProperty("JMSXUserID", userId);  
		return msg;  
	}  
}  

But when I checked the queue with HermesJMS I could see that the JMSXUserID had been overwritten somewhere, so I fired up WireShark and watched for the message and confirmed that the message that was going over the wire already had the JMSXUserID field overwritten. This was a good thing - the issue was in the IBM MQ JMS client code.

[Read More]

Can not execute Sonar: Missing column: period in ALERTS

I recently encountered the following error in Sonar 3.5

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar
(default-cli) on project smartfx: Can not execute Sonar: Missing column:period in DB.ALERTS -> [Help 1]  
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project	myproject: 
Can not execute Sonar  
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:	203)  
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:	148)  
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:	140)  
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)  

A quick check of the database revealed that the ALERTS table does indeed contain a column named ‘period’.

[Read More]
Sonar 

SonarException: The project is already been analysing.

I was getting this error when running a Sonar analysis recently.

This was caused by the Jenkins/Sonar process getting killed while the project analysis is underway. Sonar now uses a database semaphore to prevent multiple builds running at the same time, but if the job gets terminated then the semaphores don’t get cleaned up.

To fix the problem: Log into the database and delete any rows in the ‘semaphores’ table.

[Read More]
Sonar 

Maven Release from Jenkins

I encountered this error while setting up a Jenkins job to automate our Maven release process.

[INFO] EXECUTING: cmd.exe /X /C "hg commit --message "[maven-release-plugin] prepare for next development iteration" c:\jenkins\jobs\Release\workspace\pom.xml"  
[DEBUG] abort: C:\Jenkins\jobs\Release\workspace\pom.xml not under root  
[ERROR] EXECUTION FAILED  
Execution of cmd : commit failed with exit code: -1.  
Working directory was:  
c:\jenkins\jobs\Release\workspace  
Your Hg installation seems to be valid and complete.  
Hg version: 2.0 (OK)  

Our Jenkins box runs on Windows. It turns out the Mercurial (HG) is case- sensitive in a way that hadn’t impacted our project in any way up until this point. Note the subtle differences in the first two log statements:

[Read More]