A stand-alone java client can't talk to remote EJBs

Hi there,

Please forgive me if you're already bored with this question. But this question hasn't been really answered.

Now I'm using j2eesdk1.2.1 with 'doc' folder installed. I try to run the "Converter" example. Everything goes fine when I run the ConverterClient.class on the same machine of my EJBs. As I want to run my java client (ConverterClient.class) on another machine, I copy all necessary files including ConverterClient.class, ConverterAppClient.jar, I also set a suitable 'classpath' and I also include my j2ee.jar in the classpath. In the Dos promt, I type this command line(as told by developer's guide):

java -Dorg.omg.CORBA.ORBInitialHost= <myhostname> ConverterClient

I get the following exceptions:

"Can't find SerialContextProvider"

......

Should we change something about that ConverterClient.java? Actually, this question has been asked time and time again, and I've tried most of the suggestions in the forum, but the question is still there. Can anybody help me or tell me where to get the help?

Thanks for your patience.

Regards, Lizz

[1159 byte] By [rainbowC] at [2007-9-26 3:47:03]
# 1

Hi,

try to call the constructor with a Properties instance!

java.util.Properties properties= new java.util.Properties ();

properties.setProperty(Context.INITIAL_CONTEXT_FACTORY ,"the name of your contextFactory"

);

properties.setProperty(Context.PROVIDER_URL ,"url of your server incl. port number"

);

Context context = new InitialContext (properties);

->

Object ob = context.lookup (...);

babbela at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hello:

Your error is probably related with initial context factory property. When you set this property, your context factory looks for a class that maybe related with your application server provider. I have weblogic, and for example when I set context factory, I look for a weblogic class (weblogic.jndi.WLInitialContextFactory)

For example:

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

Be sure that you have this context factory in your CLIENT classpath. Sometimes when I invoke my jvm from command line I lose the classpath. You can try to run your client specifying your classpath explictly with the cp virtual machine option. For example:

java -cp <your jar-zip-or-class file directory> Client

Good luck

David

BayoD at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Thanks guys, I'll try your suggestions and come back again.Regards, Lizz
rainbowC at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Hi guys,

I failed and come back again. According to your suggestions, I added something like this to my ConverterClient.java:

prop.setProperty (Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");

prop.setProperty (Context.PROVIDER_URL,"iiop://<myServer>:<myPort>");

I still get the error

javax.naming.CommunicationException: Can't find out SerialContextProvider"

..........

As you see, I use 'com.sun.enterprise.naming.SerialInitContextFactory' to be my service provider and this class is contained in my j2ee.jar that I've already put into my classpath. The problem is about the URL. Is it an 'iiop' protocal? I couldn't find out any info about this sort of service provider. Can anyone help me?

Thanks in advance, Lizz

rainbowC at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Hi guys,

I've got it at last, I'm really happy.

Now I can work with the Converter example in j2sdkee1.2.1 doc and run the ConverterClient on a different machine from the server host. There're some lessons and tips for this success.

1. As you guys tell me, in the ConverterClient.java, I replaced the line:

initial = new InitialContext();

by the following code:

Properties prop = new Properties();

prop.setProperty (Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");

prop.setProperty (Context.PROVIDER_URL,"IIOP://<hostname>:1050");

System.err.println("Attempting to create context...");

initial = new InitialContext(prop);

Ha, there's a tricky point about the hostname. When you deploy your program please always deploy it to some IP address. Even if you want to deploy to your 'local machine', you must 'add server' to the IP address of your 'local machine'. Remember don't add your application to "localhost".

Finally on your client machine:

set classpath=.;%j2ee_home%\lib\j2ee.jar;ConverterAppClient.jar

java -Dorg.omg.CORBA.ORBInitialHost=<hostname> ConverterClient

That's it. It works well.

Thanks for all the help, Lizz

rainbowC at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Hello.

Well I am in the similar situation, I am tryin to run Converter example and SavingsAccount in a local machine throug a windows terminal (w XP) with the following command:

appclient -client SavingsAccountAppClient.jar

and I got this error:

javax.naming.CommunicationException: Can't find SerialContextProvider [Root exce

ption is org.omg.CORBA.COMM_FAILURE:vmcid: SUN minor code: 201 completed: N

o]

at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav

a:133)

at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:290

)

at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.

java:725)

at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j

ava:132)

at SavingsAccountClient.main(Unknown Source)

I am not trying to run in another machine all those examples are in the same local machine.

what is wrong ?

pls help.

McDouglas at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7

> I am not trying to run in another machine all those

> examples are in the same local machine.

> what is wrong ?

First, I would like to congratulate for resurrecting a 3.5 year old post and not reading the reply just above your post.

Second, read the documentation:

http://docs.sun.com/source/819-0079/dgacc.html#wp1022105

Make sure you follow the steps as mentioned!

x

xHacker at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 8

> > I am not trying to run in another machine all

> those

> > examples are in the same local machine.

> > what is wrong ?

>

> First, I would like to congratulate for resurrecting

> a 3.5 year old post and not reading the reply just

> above your post.

They are discussing different things. Lookups work differently in j2sdkee1.2.1 and SUN AS 8.

> Second, read the documentation:

> http://docs.sun.com/source/819-0079/dgacc.html#w

> p1022105

>

> Make sure you follow the steps as mentioned!

>

> x

Maris_Orbidans at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 9
> They are discussing different things. Lookups> work differently in j2sdkee1.2.1 and SUN AS 8.They atleast know how to type in normal font. :-)
xHacker at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 10

> > They are discussing different things. Lookups

> > work differently in j2sdkee1.2.1 and SUN AS

> 8.

>

> They atleast know how to type in normal font. :-)

Sir,

It's hard when you're latvian?

Sincerely,

Slappy

SlappyCracker at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 11
> It's hard when you're latvian?hard ? no,but I am not sure what you mean.
Maris_Orbidans at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 12
> It's hard when you're latvian?whether it's 'hard' or not doesn't depend on nationality.
Maris_Orbidans at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 13

> > It's hard when you're latvian?

At least it's not harder to be an indian.I mean a real indian who lives in his/her motherland.

I have heard terrible things about humans sacrified to gods in India. And recently stories about people dying due to lack of water because all water has been converted into Coke.

Maris_Orbidans at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 14

> > It's hard when you're latvian?

If you want to know - it was hard during soviet times when Latvia was occupied by Russia.

For example, it was forbidden to celebrate Christmas.Those persons who did were punished.Of course, they were not shot.But , let's say, kicked out of job.

Maris_Orbidans at 2007-6-29 12:29:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 15

> I have heard terrible things about humans sacrified

> to gods in India. And recently stories about people

> dying due to lack of water because all water has been

> converted into Coke.

Hoho! This was the best joke from you. I'll remember it for a long time to come.

BTW, can't you say everything in one reply?

x

xHacker at 2007-7-1 9:39:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 16
> It's hard when you're latvian?Slappy, you dumbarse. Now I'm reporting abuse on you!
xHacker at 2007-7-1 9:39:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 17

> > I have heard terrible things about humans

> sacrified

> > to gods in India. And recently stories about

> people

> > dying due to lack of water because all water has

> been

> > converted into Coke.

>

> Hoho! This was the best joke from you. I'll remember

> it for a long time to come.

I don't think it's a joke.

http://www.irc.nl/page/17832

Coca-Cola, which produces Coke, Fanta, Sprite, Thums Up and Limca, started bottling in March 2000. At its peak the plant produced a million bottles daily. Villagers allege that water levels dropped sharply and the remaining water caused dizziness, diarrhoea and skin rashes. They allege that Coca-Cola persuaded local farmers to use waste sludge containing cadmium and lead as a fertilizer.

Maris_Orbidans at 2007-7-1 9:39:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 18

> http://www.irc.nl/page/17832

>

> Coca-Cola, which produces Coke, Fanta, Sprite,

> Thums Up and Limca, started bottling in March 2000.

> At its peak the plant produced a million bottles

> daily. Villagers allege that water levels dropped

> sharply and the remaining water caused dizziness,

> diarrhoea and skin rashes. They allege that Coca-Cola

> persuaded local farmers to use waste sludge

> containing cadmium and lead as a fertilizer.

Lawyers exerting too much on their imagination, I guess. Nothing that I've ever seen or heard during my stay there.

Anyway, drop that topic. I don't want to talk about global politics or economics.

Someday, I'll stick something into Slappy's ****

xHacker at 2007-7-1 9:39:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...