Touchpad freezes on Medion MD96500

Submitted by Jochus on Mon, 31/12/2012 - 14:03 | Posted in: Windows
Posted in




Today, I had to fix a very old Medion laptop of a friend on which the touchpad stopped working after a while working on the laptop. After booting, the touchpad could be used for +- 5 minutes, but afterwards the only way to move the mouse pointer was by attaching an external USB mouse.

I fixed the issue by installing the following driver: http://www1.medion.de/downloads/download.pl?id=3031&type=treiber&filena…. After a reboot, the touchpad kept working.

Creating a custom JSF deployer in JBoss AS 6.X

Submitted by Jochus on Sun, 30/12/2012 - 18:47 | Posted in: Java
Posted in

JBoss AS 6.X gets shipped with Mojarra 2.0.3 (b5), but I wanted to do some testing with Mojarra 2.0.9. To be able to use this JSF implementation, you need to create a custom JSF deployer:

~ $ cd /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ mkdir Mojarra-2.0.9
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ cd Mojarra-2.0.9/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9 $ mkdir META-INF jsf-libs

In the META-INF folder, create the following file: web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="<a href="http://java.sun.com/xml/ns/javaee"&#10">http://java.sun.com/xml/ns/javaee"&#10</a>;   xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"&#10">http://www.w3.org/2001/XMLSchema-instance"&#10</a>;   xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10</a>;   version="2.5">
   <!-- ======================== Introduction ============================== -->
   <!-- This document defines default values for the Mojarra-2.0 JSF config  -->
   <!--                                                                      -->
   <!-- WARNING:  Do not configure application-specific resources here!      -->
   <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
 
   <!-- =========== Common Context Params ================================== -->
 
   <!-- Regular expression to determine if two different URLs actually point -->
   <!-- to the same jar file.  This keeps faces-config files from being      -->
   <!-- read twice.                                                          -->
   <context-param>
     <param-name>com.sun.faces.duplicateJARPattern</param-name>
     <param-value>^tmp\d+(\S*\.jar)</param-value>
   </context-param>
 
   <!-- JBossInjectionProvider provides resource injection for managed beans. -->
   <!-- See JSF 1.2 spec section 5.4 for details.                             -->
   <context-param>
     <param-name>com.sun.faces.injectionProvider</param-name>
     <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
   </context-param>
 
   <!-- ================== Common filter Configuration ==================== -->
 
 
   <!-- ================== Common Listener Configuration ==================== -->
   <!-- Configures JSF 2.0 -->
   <listener>
     <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener</listener-class>
   </listener>
 
</web-app>

In jsf-libs:

  • Copy the file jboss-faces.jar from the 2.0.3 folder
  • Download the JSF libraries from: http://javaserverfaces.java.net/download.html
  • This should result in something as:
    /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9/jsf-libs $ ls -al
    total 4952
    drwxr-xr-x  5 jochen  staff      170 Nov  7 16:58 .
    drwxr-xr-x  4 jochen  staff      136 Nov  7 16:44 ..
    -rw-r--r--@ 1 jochen  staff     6148 Nov  7 16:58 .DS_Store
    -rw-r--r--@ 1 jochen  staff  2502592 Nov  7 16:45 javax.faces-2.0.9.jar
    -rw-rw-r--@ 1 jochen  staff    21804 Aug 16  2011 jboss-faces.jar



Open the file: /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/META-INF/jsf-integration-deployer-jboss-beans.xml:

  • Extend the property jsfConfigurations:
        <property name="jsfConfigurations">
          <map keyClass="java.lang.String" valueClass="java.lang.String">
            ...
            <entry>
              <key>Mojarra-2.0.9</key>
              <value>${jboss.server.home.url}deployers/jsf.deployer/Mojarra-2.0.9</value>
            </entry>
            ...
          </map>
        </property>
  • Add the following bean:
      ...
      <bean name="JSFUrlIntegrationDeployer-209" class="org.jboss.jsf.deployer.JSFUrlIntegrationDeployer">
        <property name="JSFConfigName">
          <value>Mojarra-2.0.9</value>
        </property>
        <property name="JSFImplManagementDeployer">
          <inject bean="JSFImplManagementDeployer"/>
        </property>
      </bean>
      ...



Finally, to let your web application use the correct JSF deployer, make a reference in your WEB-INF/web.xml of your application (using the context-param: org.jboss.jbossfaces.JSF_CONFIG_NAME) :

	<context-param>
		<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
		<param-value>Mojarra-2.0.9</param-value>
	</context-param>

Enabling syntax highlighting in vim

Submitted by Jochus on Thu, 27/12/2012 - 22:24 | Posted in: Mac
Posted in


$ cd /usr/share/vim
$ sudo vim vimrc

Add the following lines below: set backspace=2

set ai                  " auto indenting
set history=100         " keep 100 lines of history
set ruler               " show the cursor position
syntax on               " syntax highlighting
set hlsearch            " highlight the last searched term
filetype plugin on      " use the file type plugins
 
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

Creating a Java heapdump in JBoss AS 6.x

Submitted by Jochus on Wed, 12/12/2012 - 23:12 | Posted in: Java
Posted in


If you want to create a heapdump from your application running in a JBoss AS 6.X J2EE container, you can easily perform the dump operation by some MBean in the JMX console.

  • Browse to: http://localhost:8080/jmx-console/
  • Search for com.sun.management and click on type=HotSpotDiagnostic
  • Scroll to the bottom of the page and provide the parameter /tmp/heap.dump in the textfield p0, which is actually the location to which the dump will be written. If you want to perform a garbage collection before dumping, leave p1 on value true
  • Push the button Invoke. A dump file will be available at /tmp/heap.dump. This file can easily be viewed by a tool like Java VisualVM



Also, remember that you can easily create a heap dump automatically when JBoss is going OutOfMemory. Just add the following Java arguments in your run.conf file

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heap.dump

How to re-enable the Apple-provided Java SE 6 applet plug-in

Submitted by Jochus on Mon, 10/12/2012 - 15:08 | Posted in: Mac
Posted in


After the latest Java update on Mac OS X 10.7, I was unable to use the Java plugin in my Chrome browser (I'm not really into Java applets, but the Java applet in JIRA to attach screenshots is very easy and useful to use in combination with Cmd + Shift + 4 buttons).

To fix this issue, follow the steps written below:

  • Open Terminal, located in the Utilities folder.
  • Enter this command, then press the Return or Enter key:
    $ sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
  • Enter this command, then press the Return or Enter key:
    $ sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
  • Enter this command, then press the Return or Enter key:
    $ sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plug



Source: http://support.apple.com/kb/HT5559

FCCU virus verwijderen

Submitted by Jochus on Sat, 08/12/2012 - 19:29 | Posted in: Windows
Posted in


Gisterenavond bij iemand langs geweest omdat die het bovenstaande scherm kreeg. De PC zit volledig blok, je kan nergens meer naar toe. Zelfs via "Veilige modus" lukte het niet meer.

Hardnekkig virus/malware, maar ik heb het er op deze manier afgekregen:

  • Download Windows Offline Defender en maak een startup cd/dvd of usb stick
  • Start daarna de pc op met de Windows Offline Defender disk
  • Scan u computer op malware met de Windows Offline Defender software
  • Herstart uw PC en kies voor een normale startup. Het virus zal nu niet meer opkomen, maar het is wel nog steeds aanwezig op de PC
  • Scan daarna u computer met MalwareBytes AntiMalware om het FCCU virus te verwijderen of te detecteren
  • Scan nogmaals met ComboFix! om deze malware nog dieper te detecteren en te verwijderen

Windows Offline Defender en MalwareBytes hebben er voor gezorgd dat de PC terug "vrij" kwam.
De ComboFix! heeft de "Veilig modus" terug hersteld.

... geef mij toch Mac OS X :-) ...

Discovering long running queries/dead lock situation in SQL Server

Submitted by Jochus on Mon, 26/11/2012 - 22:54 | Posted in: Java
Posted in

I recently came across this situation on a M$ SQL Server 2008 database:

I was doing an update operation on a certain table. While doing this update, a clustered index was being read. To be able to read from that index, a lock was obtained on a non-clustered index. The update operation went perfectly.
Now, in the same transaction, I was doing a select query which needed a lock on a non-clustered index. Unfortunately for me, this lock was already taken by the update statement and it would only be released when the transaction completed.

More details on this issue can be found on this blogpost.

At first, I knew there was a deadlock, but I didn't know on which resources/queries. This query helped me a lot while debugging:

SELECT DTL.resource_type,  
   CASE   
       WHEN DTL.resource_type IN ('DATABASE', 'FILE', 'METADATA') THEN DTL.resource_type  
       WHEN DTL.resource_type = 'OBJECT' THEN OBJECT_NAME(DTL.resource_associated_entity_id, SP.[dbid])  
       WHEN DTL.resource_type IN ('KEY', 'PAGE', 'RID') THEN   
           (  
           SELECT OBJECT_NAME([object_id])  
           FROM sys.partitions  
           WHERE sys.partitions.hobt_id =   
             DTL.resource_associated_entity_id  
           )  
       ELSE 'Unidentified'  
   END AS requested_object_name, DTL.request_mode, DTL.request_status,  
   DEST.TEXT, SP.spid, SP.blocked, SP.status, SP.loginame 
FROM sys.dm_tran_locks DTL  
   INNER JOIN sys.sysprocesses SP  
       ON DTL.request_session_id = SP.spid   
   --INNER JOIN sys.[dm_exec_requests] AS SDER ON SP.[spid] = [SDER].[session_id] 
   CROSS APPLY sys.dm_exec_sql_text(SP.sql_handle) AS DEST  
WHERE SP.dbid = DB_ID()  
   AND DTL.[resource_type] <> 'DATABASE' 
ORDER BY DTL.[request_session_id];

It lists the queries which are being blocked and it also tells you on which queries they are blocked (see columns spid and blocked).

Eventually, I solved the issue by handling the transaction at bean level (my bean was container managed and update / select queries where in the same bean). Before the update, I manually started a transaction. After the update was successful, I committed the transaction. Finally, I got a resultdata (select query) - without any transaction, as I didn't need a transaction for this query.

Creating a TIF file with a resolution of X ppi from a PDFBox PDPage

Submitted by Jochus on Sun, 25/11/2012 - 22:54 | Posted in: Java
Posted in

In order to have the correct ppi in the TIF file, you need to specify IIOMetadata for the TIF file and pass it to the constructor of the IIOImage.
In the example below, you can see the creation of this metadata in the function: createMetadata()

...
PDDocument document = null;
 
try {
	// Set main options
	int imageType = BufferedImage.TYPE_BYTE_BINARY;
	int resolution = X;
	int maxPage = Integer.MAX_VALUE;
 
	// Create TIFF writer
	ImageWriter writer = null;
	ImageWriteParam writerParams = null;
	try {
		TIFFImageWriterSpi tiffspi = new TIFFImageWriterSpi();
		writer = tiffspi.createWriterInstance();
		writerParams = writer.getDefaultWriteParam();
		writerParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
		writerParams.setCompressionType("CCITT T.6");
		writerParams.setCompressionQuality(1.0f);
	} catch (Exception ex) {
		throw new BusinessException("Could not load the TIFF writer", ex);
	}
 
	// Create metadata for Java IO ImageWriter
	IIOMetadata metadata = createMetadata(writer, writerParams, resolution);
 
	// Load the pdf file
	document = PDDocument.load(file.getFile());
	List<PDPage> pages = (List<PDPage>) document.getDocumentCatalog().getAllPages();
 
	// Loop over the pages
	for (int i = 0; i < pages.size() && i <= maxPage; i++) {
		// Write page to image file
		File outputFile = null;
		ImageOutputStream ios = null;
		try {
			outputFile = new File(file.getFile().getCanonicalPath() + "." + i);
			ios = ImageIO.createImageOutputStream(outputFile);
			writer.setOutput(ios);
			writer.write(null, new IIOImage(pages.get(i).convertToImage(imageType, resolution), null, metadata), writerParams);
		} catch (Exception ex) {
			throw new BusinessException("Could not write the TIFF file", ex);
		} finally {
			ios.close();
		}
 
		// do something with TIF file
	}
} catch (Exception ex) {
	throw new BusinessException("Error while converting PDF to TIFF", ex);
} finally {
	try {
		if (document != null) {
			document.close();
		}
	} catch (Exception ex) {
		log.error("Error while closing PDF document", ex);
	}
}
...
 
// Internal methods
 
private IIOMetadata createMetadata(ImageWriter writer, ImageWriteParam writerParams, int resolution) throws IIOInvalidTreeException {
	// Get default metadata from writer
	ImageTypeSpecifier type = writerParams.getDestinationType();
	IIOMetadata meta = writer.getDefaultImageMetadata(type, writerParams);
 
	// Convert default metadata to TIFF metadata
	TIFFDirectory dir = TIFFDirectory.createFromMetadata(meta);
 
	// Get {X,Y} resolution tags
	BaselineTIFFTagSet base = BaselineTIFFTagSet.getInstance();
	TIFFTag tagXRes = base.getTag(BaselineTIFFTagSet.TAG_X_RESOLUTION);
	TIFFTag tagYRes = base.getTag(BaselineTIFFTagSet.TAG_Y_RESOLUTION);
 
	// Create {X,Y} resolution fields
	TIFFField fieldXRes = new TIFFField(tagXRes, TIFFTag.TIFF_RATIONAL, 1, new long[][] { { resolution, 1 } });
	TIFFField fieldYRes = new TIFFField(tagYRes, TIFFTag.TIFF_RATIONAL, 1, new long[][] { { resolution, 1 } });
 
	// Add {X,Y} resolution fields to TIFFDirectory
	dir.addTIFFField(fieldXRes);
	dir.addTIFFField(fieldYRes);
 
	// Return TIFF metadata so it can be picked up by the IIOImage
	return dir.getAsMetadata();
}