August 16, 2012

Eclipse Keyboard Shortcut Does not Work on Ubuntu 12.04

When I installed Eclipse on Ubuntu 12.04 (or rather just unzipped the eclipse binary in my home folder and started the eclipse executable) some common Eclipse keyboard shortcut was not working, like Organize Import Ctrl+Shift+O or Inspect when debugging Ctrl+Shift+I. And the problem was that they were conflicting with the OS Ubuntu keyboard shortcut. To remove/edit the Ubuntu keyboard shortcut simply open Ubuntu Keyboard and walk through conflicting Eclipse keyboard short and either remove the Ubuntu keyboard shortcut or reassign them to other keyboard shortcut.

In the example below I simple removed the Ubuntu keyboard shortcut for Zoom in and Zoom out, since I don't need them.


August 15, 2012

How to Install Maven 3 on Ubuntu

So far there Maven 3 package is not yet available in the general Ubuntu repository, so you will have to do it manually. There are several way to do that, but I think the easiest way is to do it manually.

In short the installation follow:
$ cat /etc/environment
PATH="/home/magnus/bin/apache-maven-3.0.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_31
M2_HOME=/home/magnus/bin/apache-maven-3.0.4

August 13, 2012

How to install MySQL DataSource on JBoss EAP 6 and AS 7.

The interior of the JBoss EAP 6 and the community version JBoss AS 7, which EAP version is based on, has changed a lot in the latest version. In this blog I will walk you through how to install a MySQL DataSource, and by doing that I will touch two important differences with the new version of JBoss.
  • The changed classloading to a more OSGI like architecture.
  • The simplification of have only one configuration file.
First we will create a new module. A module in this sense is a package of classes that will be available to all our application through your JBoss node. This is a big differences compared with older JBoss version where all deployed archive where directly available to other deployed application when deployed in the deployment root folder.

You find module in $JBOSS_HOME/modules folder. To create a new module you need to do three things:
  1. Create a folder hierarchy for files.
  2. Copy module jar files.
  3. Create module configuration file – module.xml.
$ mkdir -p $JBOSS_HOME/modules/com/mysql/main
$ cp mysql-connector-java-5.1.19.jar $JBOSS_HOME/modules/com/mysql/mainmysql-connector-java-5.1.19.jar
$ touch $JBOSS_HOME/modules/com/mysql/main/module.xml
Now edit the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.19.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>
Now you are ready to use configure your DataSource. Here I will use the JBoss Standalone and not the Domain configuration. In short the main differences between Module and Standalone JBoss configuration is if you want to reuse your configuration through several JBoss instance you shoud use the Domain configuration approach. In this blog I will use the Standalone configuration, but the differences of doing the other way around is not big.

The configuration of the JBoss can be done in several way: 1. CLI 2. Web interface 3. or manually through editing xml file. Which way you choose is up to you, here I will show the result.

$JBOSS_HOME/standalone/configuration/standalone.xml:
        <subsystem xmlns="urn:jboss:domain:datasources:1.1">
            <datasources>
                ...
                <datasource jndi-name="java:jboss/datasources/YourProjectDS" pool-name="YourProjectDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/YourProjectDB</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>uid</user-name>
                        <password>pwd</password>
                    </security>
                </datasource>
                <drivers>
                    ...
                    <driver name="mysql" module="com.mysql"/>
                </drivers>
            </datasources>
        </subsystem>

August 1, 2012

Search JAR Files after Specific Class

Ones in a while I need to search in a lot of jar files after a specific class class and that is what this command:

$ find . -name "*.jar" -a -exec bash -c "unzip -l {} | grep Foo.class" \; -print