Creating an interceptor which logs every entry/method call on an EJB

Submitted by Jochus on Tue, 11/08/2015 - 22:39 | Posted in: Java
Posted in

I needed to log all the calls to all methods made to a certain EJB (because I wanted to know which methods were called from which place). The reason was locks I received on a stateless session bean. I could use a debugger, but because I'm talking about a lot of functions and a lot of calls, I created a LogInterceptor:

package be.jochenhebbrecht.ejb.interceptor;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class LogInterceptor{
	public Object intercept(InvocationContext context) throws Exception {
                // Log to console before executing method
		System.out.println("Entering method:" + context.getMethod().getName());
                // Execute method
		Object result = context.proceed();
                // Log to console after executing method
		System.out.println("Leaving method: " + context.getMethod().getName() );
		return result;

To use the interceptor, simply add the following code

package be.jochenhebbrecht.ejb;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import be.jochenhebbrecht.ejb.interceptor.LogInterceptor;
public class SomeStatelessEJB{
	public String foo(String bar) {
            // Do something ...

Running Jaspersoft iReport Designer on Mac OS X with Java 7.0 (update 71-b14)

Submitted by Jochus on Mon, 10/08/2015 - 22:45 | Posted in: Mac
Posted in

  • Go to your applications folder /Applications
  • Right click on Jaspersoft iReport Designer and select Show package Contents
  • Navigate to /Contents/Resources/ireport/etc/ and open ireport.conf
  • Edit the default JDK location by changing the jdkhome property

Running JBoss AS 6.1.0.Final on Java 7.0 (update 71-b14)

Submitted by Jochus on Mon, 10/08/2015 - 22:37 | Posted in: Java
Posted in

After changing my JAVA_HOME variable to the JDK 7, I got this exception while starting JBoss AS 6.1.0.Final

21:58:17,438 WARN  [AbstractKernelController] Broken callback: ClassSingleCallbackItem@114fb0a{name=interface org.jboss.wsf.spi.metadata.DescriptorProcessor whenRequired=ControllerState@90ccda{Installed} dependentState=ControllerState@90ccda{Installed} attributeName=setProcessor
owner=AbstractKernelControllerContext@6bedc9{ metadata=AbstractBeanMetaData@6bf2bf{name=WSDescriptorDeployer bean=org.jboss.webservices.integration.deployers.WSDescriptorDeployer properties= classLoader=BeanMetaDataDeployer$DeploymentClassLoaderMetaData@bbb128{classloader=null} constructor=null autowireCandidate=true installCallbacks=[method=setProcessor, method=setParser]}name=WSDescriptorDeployer target=org.jboss.webservices.integration.deployers.WSDescriptorDeployer@1f7a8d0 state=Installed depends=AbstractDependencyInfo@10dfdb7{}} signature=org.jboss.wsf.spi.metadata.DescriptorProcessor}: java.lang.ClassCastException: org.jboss.wsf.stack.cxf.deployment.jms.JMSDescriptorProcessorImpl cannot be cast to org.jboss.wsf.spi.metadata.webservices.WebservicesDescriptorProcessor
at org.jboss.webservices.integration.deployers.WSDescriptorDeployer.setProcessor( [:6.1.0.Final]

JBoss AS 6.x is EOL for a very long time, but I just wanted to give it a try. I still don't understand the exact reason on how I fixed it, but the problem is the processor which is trying to be set WSDescriptorDeployer. You need to disable this setProcessor callback by editing the file $JBOSS_HOME/server/default/deployers/jbossws.deployer/META-INF/stack-agnostic-jboss-beans.xml

<!-- deployers -->
<bean name="WSDescriptorDeployer" class="org.jboss.webservices.integration.deployers.WSDescriptorDeployer">
    <!-- incallback method="setProcessor"/ -->
    <property name="processor"><inject bean="WSDescriptorProcessor"/></property>
    <incallback method="setParser"/>

Repairing the TCP/IP stack when no network connection after installing AVG

Submitted by Jochus on Mon, 10/08/2015 - 22:19 | Posted in: Windows
Posted in

  • Start > All Programs > Accessories and right click on Command Prompt, select Run as Administrator to open a command prompt. In the command prompt window that opens, type type the following commands, each followed by the Enter key:
    • Reset WINSOCK entries to installation defaults:
      $ netsh winsock reset catalog
    • Reset IPv4 TCP/IP stack to installation defaults:
      $ netsh int ipv4 reset reset.log
    • Reset IPv6 TCP/IP stack to installation defaults.
      $ netsh int ipv6 reset reset.log
    • Reboot the machine

Searching for a string in an all tables, rows and columns of a database

Submitted by Jochus on Tue, 14/04/2015 - 20:37 | Posted in: Database
Posted in

Script has been developed and tested for SQL Server (version 2012)

    @search_string  VARCHAR(100),
    @table_id       INT,
    @column_name    SYSNAME,
    @sql_string     VARCHAR(2000)
SET @search_string = 'FOOBAR'
DECLARE tables_cur CURSOR FOR SELECT name, object_id FROM sys.objects WHERE TYPE = 'U'
OPEN tables_cur
FETCH NEXT FROM tables_cur INTO @TABLE_NAME, @table_id
    DECLARE columns_cur CURSOR FOR SELECT name FROM sys.columns WHERE object_id = @table_id AND system_type_id IN (167, 175, 231, 239)
    OPEN columns_cur
    FETCH NEXT FROM columns_cur INTO @column_name
        SET @sql_string = 'IF EXISTS (SELECT * FROM ' + @TABLE_NAME + ' WHERE [' + @column_name + '] LIKE ''%' + @search_string + '%'') PRINT ''' + @TABLE_NAME + ', ' + @column_name + ''''
        FETCH NEXT FROM columns_cur INTO @column_name
    CLOSE columns_cur
    DEALLOCATE columns_cur
    FETCH NEXT FROM tables_cur INTO @TABLE_NAME, @table_id
CLOSE tables_cur
DEALLOCATE tables_cur

Dropping a constraint when the name can vary from database to database

Submitted by Jochus on Tue, 14/04/2015 - 20:14 | Posted in: Database
Posted in

DECLARE @col_name VARCHAR(255)
DECLARE @command  VARCHAR(1000)
SET @column_name = '$YOUR_COLUMN_NAME'
SELECT @command = 'ALTER TABLE ' + @TABLE_NAME + ' DROP CONSTRAINT ' + FROM sys.tables t JOIN sys.default_constraints d ON d.parent_object_id = t.object_id JOIN sys.columns c ON c.object_id = t.object_id AND c.column_id = d.parent_column_id WHERE = @TABLE_NAME AND = @column_name
EXECUTE (@command)

OS X 10.10 Yosemite and environment variables

Submitted by Jochus on Tue, 14/04/2015 - 18:59 | Posted in: Mac
Posted in

In previous releases of OS X (Mavericks, Mountain Lion, Lion, ...), environment variables are configured in the /etc/launchd.conf file.

As of OS X Yosemite, this is no longer working. To configure environment variables, you can do the following

$ nano ~/Library/LaunchAgents/my.startup.plist


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "<a href="">
<plist</a> version="1.0">
    <string>launchctl setenv $VARIABLE_NAME $VARIABLE_VALUE</string>

ClickOnce application cannot be started when served by old Apache HTTPD (plain XML in browser)

Submitted by Jochus on Fri, 13/03/2015 - 19:42 | Posted in: Windows
Posted in

I recently stumbled into an issue of which a ClickOnce application was not started when trying to open it using a browser (doesn't matter if it was Internet Explorer, or Google Chrome, or ...). An XML file was always visible in the browser.

After doing some reach, I noticed the .application file was served as content type: text/plain

We have an older version of Apache HTTPD running (2.2.8, with a release of 2008-01-19). In the $APACHE_HOME/conf/mime.types file, there was no mentioning of the content type for files with extension: application. In a more recent version of Apache HTTPD, the mime.types already takes care of these files.

After adding the following lines (and restarting the Apache HTTPD server), the problem was solved

application/x-ms-application 		        application
application/manifest 			        manifest
application/octet-stream 		        deploy

SQL Server 2012 auto identity column value jump issue

Submitted by Jochus on Fri, 06/03/2015 - 20:48 | Posted in: Database
Posted in


From SQL Server 2012 version, when a SQL Server instance is restarted, it can be possible the table's identity value is jumped and the actual jumped value depends on identity column data type. If it is integer (int) data type, then the jump value is 1000 and if big integer (bigint), then jump value is 10000. From our application point of view, this increment is not acceptable for all the business cases specially when the value shows to the client. This is the special case/issue ships with only SQL Server 2012 and older versions have no such issue.


  • Using Sequence
    • Remove identity column from tables
    • Create a sequence without cache feature and insert a number from that sequence
    • CREATE SEQUENCE Id_Sequence
          AS INT
          START WITH 1
          INCREMENT BY 1
          MINVALUE 0
          NO MAXVALUE
          NO CACHE
    • Register -t272 to SQL Server startup parameter
      • Open SQL Server configuration manager
      • Select SQL Server 2012 instance
      • Right click => Properties
      • Choose tab: "Startup parameters"
      • Register parameter -t272 in the field: "Specify a startup parameter"
      • Restart the SQL Server 2012 instance