Deploying to JBoss AS 6.X through Maven

Submitted by Jochus on Wed, 02/01/2013 - 23:40 | Posted in: Java
Posted in


In your POM file, add the following plugin:

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>jboss-maven-plugin</artifactId>
     <version>1.5.0</version>
     <configuration>
         <jbossHome>${jbossHome}</jbossHome>
         <port>${jbossPort}</port>
         <serverName>${jbossServerName}</serverName>
         <fileName>target/my-webapp.war</fileName>
     </configuration>
</plugin>

In your settings.xml file (which is user dependent), add the following properties:

           ...
           <profile>
               <id>inject-application-home</id>
               <properties>
                   <jbossHome>/Applications/jboss-6.1.0.Final/</jbossHome>
                   <jbossPort>8080</jbossPort>
                   <jbossServerName>default</jbossServerName>
               </properties>
           </profile>
       </profiles>
       <activeProfiles>
           <activeProfile>inject-application-home</activeProfile>
       </activeProfiles>

To deploy, you can execute the command:

$ mvn jboss:hard-deploy
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-webapp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- jboss-maven-plugin:1.5.0:hard-deploy (default-cli) @ my-webapp ---
[INFO] Copying /Users/jochen/Documents/workspace/TestDeployWebapp/my-webapp/target/my-webapp.war to /Applications/jboss-6.1.0.Final/server/default/deploy/my-webapp.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.498s
[INFO] Finished at: Wed Jan 02 11:32:48 CET 2013
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------

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.