[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] OSGi & RMI

Do you have a zip file somewhere so I can try to run it?

Edward Yakop

On 5/13/07, Patrick Bakker <patrick@xxxxxxxxxxxx> wrote:
I'm experimenting with the best way to modularize an application using Swing
to communicate to stateless session beans. I'm using Java SE 5 + JBoss
4.2.0.CR2 + Eclipse 3.2.2.
I know its some kind of classloader/isolation issue with OSGi/RMI because I
can construct a simple Java application that works fine.

Suppose I have 5 bundles (I'm using Eclipse bundles rather than OSGi but I'm
using Swing not SWT) & their important classes:
  BeanRegistrar (singleton)

For JBoss I use an ant script to create jar from the packages in
example.clientserver and example.server to create example.server.jar which I
drop in the deploy directory:

public class ExampleBean implements IExample, IExampleRemote
   public void doSomething()

public interface IExample
  public void doSomething();

public interface IExampleRemote extends IExample

For the client I have everything packaged as individual bundles. When
example.client needs a bean it starts another thread which calls
BeanRegistrar.lookup(String jndiName) to get a reference to a remote bean.

public class Task extends Thread
  boolean inSwing;
  TaskCallback callback;

  public void Task(TaskCallback callback)
    this.callback = callback;
    inSwing = false;

   public void run()
    if (inSwing)
      IExampleRemote example = (IExampleRemote)
BeanRegistrar.lookup(IExampleRemote.DEFAULT_JNDI_NAME );

      inSwing = true;

If I collapse this entire example down to a simple Java application instead
of bundles it works fine.
If I run it as an Eclispe RCP, I get:

java.lang.ClassCastException: $Proxy0 cannot be cast to
    at example.client.Task.run(Task.java:xx) <-- stops at the line with

I've googled around extensively and OSGi/RMI issues come up in several
places but the closest anybody gets to answering anything is to hint that
this may be problematic and the conversation ends just before anybody says
anything useful. A few other documents mention the Eclipse Buddy policy
extension. I've experimented with it but have not had any success yet. Also,
I'm not sure exactly what I'm trying to do so I'm basically just guessing at
possible combinations.

I am running the program under the default Java security manager with the
following permissive policy:
    permission java.security.AllPermission;

I do that by supplying VM arguments to the run program option in Eclipse:

Can anybody help me get to the bottom of this?

_______________________________________________ equinox-dev mailing list equinox-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/equinox-dev