Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP client for EJB, cannot lookup.
RCP client for EJB, cannot lookup. [message #547536] Sun, 18 July 2010 15:08 Go to next message
Hu Jin is currently offline Hu JinFriend
Messages: 1
Registered: July 2010
Junior Member
Hi there,

I am trying to build a RCP client for an ejb application. Thus, I need to access remote ejb from the rcp client.

I use the following code to do the lookup:

Properties prop=new Properties();
prop.putContext.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
prop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
Context context = new InitialContext(prop);


However, I always get the exception at "InitialContext", the exception is:

Caused by: java.lang.ClassNotFoundException: org.apache.openejb.client.RemoteInitialContextFactory

I have double checked and confirm openejb-client-3.1.2.jar is in Java Build Path and RemoteInitialContextFactory is included in this jar file. The server is Geronimo.

Is there any special way to specify the classpath in RCP application? I have run out of the ideas, please help

Cheers,
Jin

[Updated on: Sun, 18 July 2010 15:08]

Report message to a moderator

Re: RCP client for EJB, cannot lookup. [message #547759 is a reply to message #547536] Mon, 19 July 2010 14:30 Go to previous messageGo to next message
Martin Klinke is currently offline Martin KlinkeFriend
Messages: 80
Registered: July 2009
Member
Jin,

please note, that this is just a work-around, but it may help in your
case. You could try setting the context class loader to the class loader
of the current thread, i.e.

ClassLoader old = Thread.currentThread().getContextClassLoader();
try {

Thread.currentThread().setContextClassLoader(this.getClass() .getClassLoader);
//new InitialContext...
} finally {
Thread.currentThread().setContextClassLoader(old);
}

You may then experience further problems when loading/deserializing
instances that are returned from EJB methods. This may happen, if you
have a "generic" Geronimo bundle G and a custom bundle C with your
project-specific classes. As C depends on G, G cannot see C's classes by
default. So you have to specify a BuddyPolicy in G (dependent or
registered). See here for details on the BuddyPolicy
http://www.eclipsezone.com/articles/eclipse-vms/

HTH,
Martin Klinke
http://www.martinklinke.com

Am 18.07.2010 17:08, schrieb Hu Jin:
> Hi there,
>
> I am trying to build a RCP client for an ejb application. Thus, I need
> to access remote ejb from the rcp client.
> I use the following code to do the lookup:
>
>
> Properties prop=new Properties();
> prop.putContext.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.RemoteInitialContextFactory");
> prop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
> Context context = new InitialContext(prop);
>
>
> However, I always get the exception at "InitialContext", the exception is:
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.openejb.client.RemoteInitialContextFactory
>
> I have double checked and confirm openejb-client-3.1.2.jar is in Java
> Build Path and RemoteInitialContextFactory is included in this jar file.
> The server is Geronimo.
>
> Is there any special way to specify the classpath in RCP application? I
> have run out of the ideas, please help
>
> Cheers,
> Jin
Re: RCP client for EJB, cannot lookup. [message #547761 is a reply to message #547759] Mon, 19 July 2010 14:34 Go to previous message
Martin Klinke is currently offline Martin KlinkeFriend
Messages: 80
Registered: July 2009
Member
Thinking about it, another more trivial cause for the CNFE may be that
org.apache.openejb.client.RemoteInitialContextFactory has a further
dependency that is not contained in your class-path...

Martin

Am 19.07.2010 16:30, schrieb Martin Klinke:
> Jin,
>
> please note, that this is just a work-around, but it may help in your
> case. You could try setting the context class loader to the class loader
> of the current thread, i.e.
>
> ClassLoader old = Thread.currentThread().getContextClassLoader();
> try {
>
> Thread.currentThread().setContextClassLoader(this.getClass() .getClassLoader);
>
> //new InitialContext...
> } finally {
> Thread.currentThread().setContextClassLoader(old);
> }
>
> You may then experience further problems when loading/deserializing
> instances that are returned from EJB methods. This may happen, if you
> have a "generic" Geronimo bundle G and a custom bundle C with your
> project-specific classes. As C depends on G, G cannot see C's classes by
> default. So you have to specify a BuddyPolicy in G (dependent or
> registered). See here for details on the BuddyPolicy
> http://www.eclipsezone.com/articles/eclipse-vms/
>
> HTH,
> Martin Klinke
> http://www.martinklinke.com
>
> Am 18.07.2010 17:08, schrieb Hu Jin:
>> Hi there,
>>
>> I am trying to build a RCP client for an ejb application. Thus, I need
>> to access remote ejb from the rcp client.
>> I use the following code to do the lookup:
>>
>>
>> Properties prop=new Properties();
>> prop.putContext.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.RemoteInitialContextFactory");
>> prop.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
>> Context context = new InitialContext(prop);
>>
>>
>> However, I always get the exception at "InitialContext", the exception
>> is:
>>
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.openejb.client.RemoteInitialContextFactory
>>
>> I have double checked and confirm openejb-client-3.1.2.jar is in Java
>> Build Path and RemoteInitialContextFactory is included in this jar file.
>> The server is Geronimo.
>>
>> Is there any special way to specify the classpath in RCP application? I
>> have run out of the ideas, please help
>>
>> Cheers,
>> Jin
>
Previous Topic:How to call Java RCP based application from Java Swing
Next Topic:How to create Section with toolbar?
Goto Forum:
  


Current Time: Thu Apr 25 07:09:38 GMT 2024

Powered by FUDForum. Page generated in 0.02937 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top