Archiv der Kategorie: Java

Using JBoss EJB 3 with Eclipse RCP [Part 3]

Creating the RCP-Plugins

Using the menus File > New > Project we will create our RCP. All details you can find in the following 4 screenshots:

RCP Plugin Projekt anlegen
RCP Plugin Projekt anlegen
RCP Plugin Projekt anlegen
RCP Plugin Projekt anlegen

Creating the JBoss-Client-Plugin

Our plugin with the JBoss-Classes will be created similar to the RCP-plugin. But in this case we are using „Plug-in from existing JAR archives“.

Create JBoss-Client-Plugin

In the next dialog we are choosing Add external and select all JARs in the %JBOSSHOME%/client folder. The auth.conf file should not be selected!

Create JBoss-Client-Plugin
Create JBoss-Client-Plugin

Now we need to define the dependency between the two plugins and create a Buddy-Policy. I’ll show that to you in part 4.

Using JBoss EJB 3 with Eclipse RCP [Part 2]

The Demo-EJB

As a simple example EJB, which will be used in our RCP, we will use a small EJB 3.0 stateless session bean. It’s a typical „Hello World“ bean:

MyTestStatelessSessionRemote.java
[java]
package bz.jmc.blog.tutorial.rcp_with_jboss.ejb;

import javax.ejb.Remote;

@Remote
public interface MyTestStatelessSessionRemote {

public String sayHello();

}
[/java]
MyTestStatelessSessionBean.java
[java]
package bz.jmc.blog.tutorial.rcp_with_jboss.ejb;

import javax.ejb.Stateless;

@Stateless
public class MyTestStatelessSessionBean implements MyTestStatelessSessionRemote {

public String sayHello() {
return „Hello World! I’m an Stateless-Session-Bean“;
}

}
[/java]
This Bean will be packaged in a JAR-file called MyTestStatelessSession.jar and needs to be deployed to JBoss. After deployment JBoss should echo something like this:
[code]
11:31:25,651 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 1m:21s:287ms
11:39:01,958 INFO [Ejb3Deployment] EJB3 deployment time took: 88
11:39:02,027 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=MyTestStatelessSession.jar, name=MyTestStatelessSessionBean, service=EJB3 with dependencies:
11:39:03,276 INFO [EJBContainer] STARTED EJB: bz.jmc.blog.tutorial.rcp_with_jboss.ejb.MyTestStatelessSessionBean ejbName: MyTestStatelessSessionBean
11:39:03,697 INFO [EJB3Deployer] Deployed: file:/Users/jmc/Applications/jboss-4.0.4.GA/server/default/deploy/MyTestStatelessSession.jar
[/code]

In the next part I’ll show you how to create our simple RCP application.

Using JBoss EJB 3 with Eclipse RCP [Part 1]

I got a lot of hits to my article about how to connect an Eclipse Rich Client Project to JBoss and EJB 3. Most of these hits came from people outside of germany and they left right after entering the page. So I think that there is some interest in an english version of this article.

Our goal

We want to create an Eclipse Rich Client Project (RCP for now on) consisting of the RCP-plugin and a second plugin containing the JBoss client JARs. To keep things simple, the EJB-Classes will be hold directly in the RCP-Plugin. In a later article I will show how to extract the business-classes in an extra plugin to ensure better maintainablity.

The problem

The OSGI-Classloader from Eclipse creates an extra Classpath for any plugin it loads. Classes from other plugins are therefore invisible. This behavior is pretty good in generel because it allows Eclipse e.g. to enable or disable plugins at runtime. But sometimes it is necessary to give plugin A access to classes in plugin B. This can be archived by declaring a dependency between A and B.

But for our problem we need access in both directions. Our RCP needs „to see“ the JBoss classes and JBoss needs access to our EJBs. And because this is not possible you will get a lot of

Javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: bz.jmc.blog.tutorial.rcp_with_jboss.ejb.MyTestStatelessSessionRemote (no security manager: RMI class loader disabled)]

and other errors.

The solution

As mentioned above, you can’t set a dependency in both directions. We need another solution for this particular problem and this solution is called „Buddy Classloading“. So it is possible to „open“ one plugin for others. Other Plugins can register as a buddy and give access to their classes.

In some upcoming articles I will create a small tutorial project with screenshots, illustrating the buddy classloading solution.

Druckerprobleme unter Java in Ubuntu 6.10

Möglicherweise steht jemand ebenfalls mal vor dem Problem unter Ubuntu 6.10 aus einer Java-Anwendung heraus drucken zu wollen. Leider ist dies erstmal nicht möglich, das Java-Programm meldet immer eine Exception:

[java]java.awt.print.PrinterException: Printer is not accepting job.[/java]

Die Ursache ist allerdings leicht zu beheben:

  1. Im Verzeichnis /etc/cups eine Datei client.conf anlegen. In dieser Datei muss „ServerName localhost“ eingetragen werden.
  2. Es wird noch ein SymLink von /usr/lib/libcups.so.2 auf /usr/lib/libcups.so benötigt: sudo ln -s /usr/lib/libcups.so.2 /usr/lib/libcups.so

Anschliessend einmal die Java-Anwendung neu starten und dem drucken sollte nichts mehr im Wege stehen.

JSR 223 (Scripting for the JavaTM Platform) legt Final Draft vor

Java Community Process LogoIch habe gerade gesehen, das am 10. August 2006 der Finale Entwuf für die Integration von Skript-Sprachen in die Java EE Platform vorgelegt wurde. Zu finden ist das Ganze auf den Seiten des Java Community Process.

Ziel des JSR ist die Integration von Skript-Sprachen zur Erstellung von Web-Content in die Java EE Plattform. Die Implementation erfolgt am Beispiel von PHP 5. Mitglieder der Expertengruppe sind unter anderem Zend, IBM, Oracle und Sun.

Damit soll es in der Zukunft möglich werden z.B. PHP und Java zu integrieren.