a cup of java

Here’s your cup of hot java & web 2.0 cookies. Enjoy it.

Posts Tagged ‘eclipse

A small JBoss 5.1 issue

with one comment

jbosscorp_logo

I don’t know whether I should call it an issue. But for me it was an issue. Recently I switched to JBoss 5.1.0 GA. But when I tried to run it, it was throwing the following exception:

[ClassLoaderManager] Unexpected error during load of:org.jboss.resource.metadata.repository.DefaultJCAMetaDataRepository
java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:63)
        at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:572)
        at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:532)
        at java.security.AccessController.doPrivileged(Native Method)

You will have this problem if you are working with JDK 1.5.x. You can switch to JDK 1.6.x and you can get it working fine. But my entire work setup required me to run my Eclipse Ganymede on 1.5 but JBoss on 1.6. So I wrote a batch file which look like this:

@echo off
echo Overriding the Jboss home and Java home ...
set JBOSS_HOME=D:\jboss-5.1.0.GA
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0
echo Jboss home: %JBOSS_HOME%
echo Java home: %JAVA_HOME%
call %JBOSS_HOME%\bin\run.bat -b 192.168.x.y

So I can have my Eclipse running on 1.5 with JBOSS_HOME set to JDK 1.5 and JBoss on 1.6. Hope this will be helpful for you in some way.

Written by Subinkrishna G

June 4, 2009 at 2:35 pm

Part 2 – OSGi: Creating a workspace

with 2 comments

< Part 1 -  OSGi: What, Why & How | OSGi tutorial home

To implement my OSGi based applications I am using Equinox (Eclipse Foundation). If you are using Eclipse IDE (which is based on OSGi) you don’ t need to download the OSGi core APIs as you can find it in the Eclipse_Home/plugins directory. If you are using Eclipse Ganymede, you will find a JAR org.eclipse.osgi_3.4.0.v20080605-1900.jar or a higher version. That’s all what we want (for now).

Equinox download: http://download.eclipse.org/eclipse/equinox/.


Workspace directory structure

The directory structure should look like this.

OSGiWorkspace
|-- configuration
|  |-- config.ini               - Framework configuration
|-- org.eclipse.osgi_3.4.2.jar  - Framework
|-- subin.orgi.simple.jar       - My bundle
|
|-- <other bundles, archives>

The config.ini is the place where we can configure the framework and bundle behavior. We can talk about it later.


Running the Equinox core

Copy org.eclipse.osgi JAR in to your workspace directory. You can start the OSGi framework by running the org.eclipse.osgi JAR file. Use the following command:

your/workspace/dir> java -jar org.eclipse.osgi_3.4.2.jar -console

This will start an OSGi console for us using which we can start, install, uninstall OSGi bundles.

osgi console

In the above screen shot you can see the OSGi console with the list of installed bundles. (I am using Equinox 3.4.2.)


Configuring the Equinox workspace
We can configure Equinox in various ways. I think its very early to mention all those things here. If you are really interested in knowing that, check this link.

Quick start guide: http://www.eclipse.org/equinox/documents/quickstart.php


Starting Equinox faceless
When we start Equinox core using the above command, it will launch an OSGi console. There is a way to start Equinox faceless (with out console). Try this command.

java -jar org.eclipse.osgi_3.4.2.jar -console 8281 -noExit

This will make Equinox to launch the OSGi console in port 8281 which we can access using Telnet on port 8281. Try this.

telnet localhost 8281

osgi console telnet

Read more on starting Equinox faceless: http://www.eclipsezone.com/eclipse/forums/t93976.rhtml


References

http://www.eclipse.org/equinox/documents/quickstart.php
http://www.eclipsezone.com/

Written by Subinkrishna G

March 6, 2009 at 9:25 am

Part 1 – OSGi: What, Why & How

without comments

What is OSGi?
OSGi is a Java-based service platform that can be remotely managed. OSGi has been developed by the OSGi Alliance (formerly known as the Open Services Gateway initiative) is an open standards organization founded in March 1999. The OSGi framework defines an application life cycle management model, a service registry, an Execution environment and Modules.

Read More: http://www.osgi.org/About/WhatIsOSGi
Download the specification: http://www.osgi.org/Release4/Download

OSGi Architecture (Source: Wikipedia)

osgi_framework

  • Bundles
    Bundles are normal jar components with extra manifest headers. The bundles are loosely coupled & highly cohesive.
  • Services
    The services layer connects bundles in a dynamic way by offering a publish-find-bind model for plain old Java objects (POJO).
  • Services Registry
    The API for management services.
  • Life-Cycle
    The API for life cycle management (install, start, stop, update, and uninstall bundles).
  • Modules
    The layer that defines encapsulation and declaration of dependencies (how a bundle can import and export code).
  • Security
    The layer that handles the security aspects by limit bundle functionality to pre-defined capabilities.
  • Execution Environment
    Defines what methods and classes are available in a specific platform.

Why should we use OSGi?
OSGi offers extreme modularity for the developer as the developers will be developing the modules as Bundles which can be plugged in to the application anytime from anywhere. This also enables the reusability and maintainability of the modules. We can even remove some of the modules for upgrade/bug fixes with out disturbing other modules.

Read more: http://www.osgi.org/About/WhyOSGi

How can we develop OSGi based applications?
We can develop an OSGi based application using any of the OSGi implementations. Three of the most widely used implementations are, Equinox (Eclipse Foundation), Apache Felix & Knopflerfish.

References
http://www.osgi.org
http://www.osgi.org/Specifications/HomePage
http://www.eclipse.org/equinox
http://felix.apache.org
http://www.knopflerfish.org/
http://en.wikipedia.org/wiki/OSGi

Written by Subinkrishna G

March 3, 2009 at 3:30 pm