How to deploy to JBoss AS7 default ROOT context

If you want to deploy your app to the default ROOT context of JBoss AS7, you have to modify first your standalone.xml. Otherwise, you will raise this exception :

Caused by: java.lang.IllegalArgumentException: Child container with name already exists

By default, AS7 has an application already deployed to / context.

To fix this, set your enable-welcome-root="true" to enable-welcome-root="false". Which finaly gives you :

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
   <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
   <virtual-server name="default-host" enable-welcome-root="false">
      <alias name="localhost"/>
      <alias name="example.com"/>
   </virtual-server>
</subsystem>


That’s all ;)

Categories: Informatic, Java Tags: , ,

How to install MyPaint on Ubuntu 11

sudo add-apt-repository ppa:achadwick/mypaint-testing
sudo apt-get update
sudo apt-get install mypaint
Categories: Uncategorized Tags: , , ,

How to install Blender 2.59 on Ubuntu 11

sudo add-apt-repository ppa:cheleb/blender-svn
sudo apt-get update
sudo apt-get install blender
Categories: Uncategorized Tags: , , , ,

Java on Ubuntu 11

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-jdk
Categories: Uncategorized Tags: , ,

Hudson – clock of the subversion server appears to be out of sync.

WARNING: clock of the subversion server appears to be out of sync. This can result in inconsistent check out behavior.

This message seems pretty clear, to fix this we have to configure ntp. Let’s install the required packages :

apt-get install ntp ntpdate
 vim /etc/ntp.conf 

add server ntp.belnet.be

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#server 0.debian.pool.ntp.org iburst dynamic
#server 1.debian.pool.ntp.org iburst dynamic
#server 2.debian.pool.ntp.org iburst dynamic
#server 3.debian.pool.ntp.org iburst dynamic
server ntp.belnet.be

...

Restart ntp,

/etc/init.d/ntp restart

You can check your configuration and see the servers with which you are synchronized with the following :

ntpq -p
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
holem.belnet.be 193.190.198.43   2 u    2   64    1    9.181  -15.619   0.001

More on : http://www.debianadmin.com/ntp-server-and-client-configuration-in-debian.html

OSGi Hello World with NetBeans 6.9

November 2, 2010 1 comment

Since version 6.9, NetBeans offers the possibility to work with OSGi bundles. The creation of the project is relatively simple. You just need to go to new Project > Maven > Maven OSGi Bundle like this :

The generated pom.xml begins this way:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

 <modelVersion>4.0.0</modelVersion>
 <groupId>net.stephou.osgi</groupId>
 <artifactId>HelloWorld</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>bundle</packaging>
 <name>OSGiTest OSGi Bundle</name>

 <dependencies>
  <dependency>
   <groupId>org.apache.felix</groupId>
   <artifactId>org.osgi.core</artifactId>
   <version>1.4.0</version>
  </dependency>
 </dependencies>
...

We notice there is only one dependency to the OSGi core and that the packaging is “bundle”. The rest of the pom is the run-on-felix profile configuration for NetBeans.

To display a HelloWorld in Apache Felix console, we need to add a HelloWorld java class. So, right-click on the source package and go to New > Other > OSGI > Bundle Activator like this :

Here is the code for the class after adding something for the console :

package net.stephou.osgi;

import org.osgi.framework.BundleActivator;

import org.osgi.framework.BundleContext;

/**

*

* @author Stephou

*/

public class HelloWorld implements BundleActivator {

   public void start(BundleContext context) throws Exception {

     System.out.println("Hello OSGi World");

   }

   public void stop(BundleContext context) throws Exception { 

     System.out.println("Goodbye OSGi World");

   }
}

In the pom.xml, you can see the Bundle-Activator line has been added for the maven-bundle-plugin :

<plugin>
 <groupId>org.apache.felix</groupId>
 <artifactId>maven-bundle-plugin</artifactId>
 <version>2.0.1</version>
 <extensions>true</extensions>
 <configuration>
 <instructions>
   <Bundle-Activator>net.stephou.osgi.helloworld.HelloWorldActivator</Bundle-Activator>
 </instructions>
 </configuration>
 </plugin>

Just Build and Run your project in NetBeans and you’ll see the following in the console :

Welcome to Felix
================

Hello OSGi World

Congratulation ;)

Categories: Informatic, Java

Getting started with OSGi on Apache Felix

September 29, 2010 2 comments


To work with OSGi modules (or bundles), you’ll have to use, I let you guess …, an OSGi container. There a few open source containers including Apache Felix and Eclipse Equinox. The first one is used in application such as Glassfish v3, Service Mix 4, … and the second one in … Eclipse IDE of course.

Let’s start with downloading Apache Felix here and choose Felix Framework Distribution 3.0.3.

Unzip it and run the container (felix-framework-3.0.3/bin/felix.jar) with :

java -jar bin/felix.jar

You’ll have a g! prompt (fore felix console “gogo”) where you can enter the help command :

____________________________
Welcome to Apache Felix Gogo

g! help
felix:bundlelevel
felix:cd
felix:frameworklevel
felix:headers
felix:help
felix:inspect
felix:install
felix:lb
felix:log
felix:ls
felix:refresh
felix:resolve
felix:start
felix:stop
felix:uninstall
felix:update
felix:which
gogo:cat
gogo:each
gogo:echo
gogo:format
gogo:getopt
gogo:gosh
gogo:grep
gogo:not
gogo:set
gogo:sh
gogo:source
gogo:tac
gogo:telnetd
gogo:type
gogo:until
obr:deploy
obr:info
obr:javadoc
obr:list
obr:repos
obr:source
g!

List installed bundle

g! felix:lb
START LEVEL 1
 ID|State      |Level|Name
 0|Active     |    0|System Bundle (3.0.3)
 1|Active     |    1|Apache Felix Bundle Repository (1.6.2)
 2|Active     |    1|Apache Felix Gogo Command (0.6.1)
 3|Active     |    1|Apache Felix Gogo Runtime (0.6.1)
 4|Active     |    1|Apache Felix Gogo Shell (0.6.1)

Install bundles

g! felix:install file:bundle/helloworld.jar
Bundle ID: 18

Start installed bundles

g! felix:start 18
Hello World!

Stop Apache Felix

felix:stop 0

Don’t be surprised next time you launch Apache Felix, installed bundles will automatically be reloaded thanks to felix-cache.

To continue …

Follow

Get every new post delivered to your Inbox.