Maven Tips

Como indico que el about, estoy trabajando en una empresa llamada Unience, y en ella he tenido el placer de conocer entre otros profesionales excepcionales, a Pablo,  y gracias a el he descubierto una herramienta que me ha cambiado la vida como es Maven

Bueno pues estas son los comandos basicos de Maven para poder empezar a crear proyectos:

Crear una carpeta base de Proyecto

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Con este comando se crea una carpeta llamada my-app con una carpeta src creada dentro y un fichero pom.xml Como esta carpeta quiero que sea simplemente contenedora del resto de modulos de mi proyecto(ejb,jar, war….), lo que hacemos es:

  • Borrar carpeta src
  • Abrir el fichero pom.xml y cambiar el packaging de jar a pom.
crear Proyecto Web

 mvn archetype:create -DgroupId=com.jdg -DartifactId=music4all-web -DarchetypeArtifactId=maven-archetype-webapp 

crear proyecto Jar


mvn archetype:create -DgroupId=com.test.core -DartifactId=test-core -Dpackage=jar 

Amazon Ec2: Configurando Linux(Debian,Ubuntu)

PreCondicion: Tener JAVA_HOME configurado correctamente.

Una vez que te has dado de alta como usuario de Amazon WebServices y como usuarios de Amazon Ec2, llega el momento el configurar el entorno para poder hacer uso de sus APIS y comandos.

Amazon va continuamente actualizando sus APIS para ampliar funcionalidades, por lo que necesitaba algo que me permitiera estar siempre con la ultima version disponible en el sistemas.

EL siguiente script hace todo lo necesario para desde cero poder tener tu sistema listo para interactuar con los servicios de Amazon Ec2.


#!/bin/bash
sudo apt-get install ruby rubygems libopenssl-ruby debootstrap dpkg

RDIR=”`pwd`”
PREDIR=$RDIR/mydir
rm -d -f -r soft
mkdir soft
cd soft
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-ami-tools.zip
cd ec2-ami*
export EC2_AMITOOL_HOME=”`pwd`”
cd ..
unzip ec2-api-tools.zip
cd ec2-api*
export EC2_HOME=”`pwd`”
cd ..
cd ..
export EC2_CERT=$PREDIR/cert-MYCERTIFICADO-GENERADO-POR-AMAZON.pem
export EC2_PRIVATE_KEY=$PREDIR/pk-PRIVATE-KEY-GENERADA-POR-AMAZON.pem
export EC2_USER_ID=MI-NUMERO-DE-USUARIO

export PATH=$PATH:$EC2_HOME/bin:$EC2_AMITOOL_HOME/bin
export AWS_ACCESS_KEY=MY-ACCESS-KEY
export AWS_SECRET_KEY=MY-SECRET-KEY

export EC2_GSG_KEYPAIR=my-keypair
export UPLOAD_BUCKET_NAME=se-uploaf-bcket
export RUBYLIB=$RUBYLIB:/usr/lib/site_ruby/

guarda el código anterior en un fichero llamado por ejemplo config-ec2.sh y dale permisos de ejecucion con

chmod +x config-ec2.sh

luego:

source config-ec2.sh

una vez se ejecute si todo ha ido bien prueba a escribir el siguiente comando.

ec2-describe-images --all

si te aparece la lista de Amis disponibles.. enhorabuena ya puedes empezar a disfrutar de esta herramienta revolucionaria que es Amazon EC2

XUBUNTU o cómo dar vida a un equipo viejo.

Llevo algun tiempo eliminando la necesidad de utilizar Windows en mi vida, y poco a poco voy instalando en los equipos que tengo linux Ubuntu 8.04 para ser exactos.  lo habia echo en los dos portatiles que tengo Dell Precision M70 y Del Precision M4300, en este ultimo no estoy muy contento con el rendimiento que estoy obteniendo sobre todo con Compiz, pero dentro de lo malo es una gozada instalar Ubuntu y tenerlo casi todo instalado..

Tenía casi retirado un clónico P4 2Ghz y 1gb de ram, con 7 añitos de antiguedad, y pense que estaria bien volver a darle algo de vida al cacharro, sin embargo esta vez quise probar algo diferente, y ahi es donde ha entrado XUbuntu, xubuntu es una distribucion basada en ubuntu Hardy heron 8.04, pero especificamente diseñada para ordenadores con menor rendimiento, su Desktop no es gnome si no Xfce, un desktop diseñado para un consumo minimo de memoria.

solo puedo decir que el sistema va genial, vuela, y simplemente echaba en falta algunos paquetes que echaba de menos los cuales he añadido(openoffice, amarok, vlc media, flash player, skype)..por lo demas tiene todo lo necesario para utlizar una maquina para navegar(Firefox), revisar el correo(ThunderBird), bajarse cosas del bittorrennt(transmision), comunicacion (Pidgin), graficos(gimp)…..grabador cds ty dvd.(brasero)….

Una delicia.

java AWT problems in Ubuntu 8.04

With the base java configuration that comes with Ubuntu some Java programs doesn work properly, like Jmeter, JProfiler…

to solve this  you have to run the following command, and select a different JRE (Sun one for example) instead the one that comes with the Base ubuntu installation. In the case you don have other java runtime installed…

sudo update-alternatives --config java
sudo apt-get install sun-java5-bin

Launching an EC2 image….

  1. Launch the ami selected .. in this case I am using and Fedora 8 base I have design for testing.. this image will be available for public use shortly.
    ec2-run-instances ami-62dc390b -k gsg-keypair When the command finish we get the instance-id Amazon assigned us
  2. Now we need to see the state of our instace for that we make
    ec2-describe-instance When executing this command we get something likeRESERVATION r-fdd13994 595199202159 default
    INSTANCE i-debf4eb7 ami-62dc390b ec2-67-202-32-41.compute-1.amazonaws.com domU-12-31-38-00-40-15.compute-1.internal
    running gsg-keypair 0 m1.small 2007-12-19T20:39:02+0000
    We are ready to connect with the instance.
  • Autorize Network Access
  • ec2-authorize default -p 22
    ec2-authorize default -p 80
    <Opening this ports we can now access it throw SSH and configure the machine as we need

  • Revoke Network Access
  • ec2-revoke default -p port

    We can find more information about this in http://developer.amazonwebservices.com/connect/entry.jspa?externalID=992&categoryID=87

    Problems with Ec2 tools and Ruby 1.8.6

    When you try to bundle and Ec2 image using the next command,

    ec2-bundle-image -i /mnt/image/$IMAGE_NAME -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $AWS_ACCOUNT_NUMBER

    and you have just installed the last version of Ruby 1.8.6, is possible you get the next error:


    Creating bundle manifest...
    Error: private method `gsub' called for 51:Fixnum
    ec2-bundle-image failed.

    This error can be fixed in this way,

    go to the instalation of ruby in your system and open /usr/lib/ruby/1.8/rexml/text.rb

    This could have been fixed at the rcov side, but since it *did* used to work
    with rexml, I consider this a backwards-compatibility failure. The fix is
    trivial:

    --- rexml/text.rb.orig 2007-10-22 08:00:04.000000000 +0100
    +++ rexml/text.rb 2007-10-22 08:00:33.000000000 +0100
    @@ -286,7 +286,7 @@
    EREFERENCE = /&(?!#{Entity::NAME};)/
    # Escapes all possible entities
    def Text::normalize( input, doctype=nil, entity_filter=nil )
    - copy = input
    + copy = input.to_s
    # Doing it like this rather than in a loop improves the speed
    #copy = copy.gsub( EREFERENCE, '&' )
    copy = copy.gsub( "&", "&" )

    (Note that there are other places in this file which might benefit from a
    to_s as well)

    The second is almost certainly a bug in REXML: it’s a misnamed local
    variable.

    --- rexml/document.rb.orig 2007-10-22 08:02:36.000000000 +0100
    +++ rexml/document.rb 2007-10-22 08:03:01.000000000 +0100
    @@ -183,7 +183,7 @@
    output = Output.new( output, xml_decl.encoding )
    end
    formatter = if indent > -1
    - if transitive
    + if trans
    REXML::Formatters::Transitive.new( indent, ie_hack )
    else
    REXML::Formatters::Pretty.new( indent, ie_hack )

    Instalar la última version de Java en Linux

    vamos a http://java.sun.com/javase/downloads/index.jsp y nos bajamos la versión de Java que queramos instalar.. normalmente la ultima .. no? :-D

    nos bajamos el fichero y lo copiamos en el directorio que deseemos, personalmente me gusto mucho dejar en /opt … pero es a libre decisión de cada uno

    por lo tanto tenemos el siguiente fichero

    /opt/jdk-6u3-linux-i586-rpm.bin

    escribimos lo siguiente:


    chmod a+x /opt/jdk-6u3-linux-i586-rpm.bin
    ./jdk-6u3-linux-i586-rpm.bin

    creamos un fichero llamado java.sh en /etc/profile.d

    con las siguientes lineas

    JAVA_HOME=/usr/java/jdk1.6.0_03
    export JAVA_HOME

    y cambiamos el modo de ese fichero

    chmod a+x /etc/profile.d/java.sh

    la proxima vez que iniciemos la maquina tendremos el JAVA_HOME configurado.

    Instalar MySQL en Fedora 8

    Antes de nada es importante tener privilegios de administrador para instalarlo.

    Abrimos una consola y escribimos.


    yum install mysql
    yum install mysql-server

    y para arrancarlo, simplemente escribimos


    service mysqld start

    podemos probar si MySql ha arrancado correctamente escribiendo


    mysqlshow

    +———–+
    | Databases |
    +———–+
    | mysql |
    | test |
    +———–+

    Ahora queda poner un password a la BD para que no sea accesible por todo el mundo, asi­ que tecleamos:

    mysqladmin -u root -p password