Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / September 2003

Tip: Looking for answers? Try searching our database.

[Help] Client call EJB (why doesnt works?)

Thread view: 
Matteo Piccioni - 28 Sep 2003 11:01 GMT
hi, first of all sorry for bad english.
I write a client and an ejb running under JOnAS 3.2
If client and ejb are on the same machine, all works.

If i try to move the client in another machine i get errors.

The old version of my client (HelloWorld.java) is:
....
Context context = new InitialContext();
Object ref = context.lookup("JNDIName");
enterprise1Home = (Enterprise1Home) PortableRemoteObject.narrow(ref,
Enterprise1Home.class);
...

Then i try to specify the host were is the ejb and jonas, so the client
became:

...
...
Properties p = new Properties();

p.put("java.naming.factory.initial","org.objectweb.jeremie.libs.services.registry.jndi.JRMIInitialContextFactory");

// I put 127.0.0.1 for test...but it doesn't works
p.put("java.naming.provider.url","jrmi://127.0.0.1:2000");

p.put("java.naming.factory.url.pkgs","org.objectweb.jonas.naming");
InitialContext ctx = new InitialContext(p);
Object obj = ctx.lookup("JNDIName");

enterprise2Home = (Enterprise1Home) PortableRemoteObject.narrow(obj,
Enterprise1Home.class);

Enterprise1 ent1 = enterprise2Home.create();

System.out.println(ent1.ejbmethod());
...
...

(I need to set che IP of the server in the client. In my next version of
client, the IP will have to change (reading a txt file).)

In carol.properities I set:
carol.protocols=jeremie

If i run the client in this way:
jclient -cp C:\..\JOnAS-3.2\ejbjars\autoload\EjbModule.jar HelloWorld

I get the following exceptions:

javax.naming.NamingException: registry context error: look up. Root
exception i
s java.rmi.MarshalException: error during marshalling/unmarshalling by stub;
nes
ted exception is:
java.rmi.MarshalException: exception preparing marshaller; nested
except
ion is:
java.net.ConnectException: Connection refused: connect
at
org.objectweb.jeremie.libs.services.registry.RegistryImpl_OWStub.look
up(RegistryImpl_OWStub.java:159)
at
org.objectweb.jeremie.libs.services.registry.jndi.JRMIRegistryContext
.lookup(JRMIRegistryContext.java:160)
at
org.objectweb.jeremie.libs.services.registry.jndi.JRMIRegistryContext
.lookup(JRMIRegistryContext.java:187)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at HelloWorld.main(HelloWorld.java:40)
Caused by: java.rmi.MarshalException: exception preparing marshaller; nested
exc
eption is:
java.net.ConnectException: Connection refused: connect
at
org.objectweb.jeremie.libs.stub_factories.std.RefImpl.prepareInvocati
on(RefImpl.java:298)
at
org.objectweb.jeremie.libs.services.registry.RegistryImpl_OWStub.look
up(RegistryImpl_OWStub.java:123)
... 4 more
Caused by: java.net.ConnectException: Connection refused: connect
at
org.objectweb.jonathan.libs.resources.tcpip.IPv4ConnectionFactory.new
CltConnection(IPv4ConnectionFactory.java:210)
at
org.objectweb.jonathan.libs.resources.tcpip.JConnectionMgr.newCltConn
ection(JConnectionMgr.java:118)
at
org.objectweb.jonathan.libs.protocols.tcpip.TcpIpProtocol$CltSessionI
dentifier.bind(TcpIpProtocol.java:323)
at
org.objectweb.david.libs.protocols.giop.GIOPProtocol$GIOPCltSessionId
entifier.bind(GIOPProtocol.java:536)
at
org.objectweb.jeremie.libs.stub_factories.std.RefImpl.prepareInvocati
on(RefImpl.java:294)
... 5 more

Can someone explain me what I have to do?
Thanks very much!

Matteo
Johann Burkard - 28 Sep 2003 18:54 GMT
> I write a client and an ejb running under JOnAS 3.2
> If client and ejb are on the same machine, all works.

You mean, client and EJBs run in the same VM or on the same machine
only? There's a difference.

> // I put 127.0.0.1 for test...but it doesn't works
> p.put("java.naming.provider.url","jrmi://127.0.0.1:2000");

So, if the URL is correct, it still doesn't work? 127.0.0.1 is localhost.

> java.net.ConnectException: Connection refused: connect

To me, that looks like the client cannot contact the EJB server. Do you
have a firewall? Is the IP address right?

Johann
Signature

Sie kam nur ab und zu aus ihrem Minderwertigkeitskomplexloch gekrabbelt,
um mich wie ein kleines Kind zu tadeln oder
zurechtzuweisen, damit die anderen° sie weiter am Arsch lecken.
("Marco Desloovere" in <66rajv80g93lr2b4of3rpq4tv71sg7a5cq@4ax.com>)

Matteo Piccioni - 28 Sep 2003 20:12 GMT
>> I write a client and an ejb running under JOnAS 3.2
>> If client and ejb are on the same machine, all works.
[quoted text clipped - 13 lines]
>
> Johann

thanks 4 answer me, now it works and I did client in this way:

--------------------
Properties p = new Properties();

// USING JEREMIE

p.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.objectweb.jeremie.libs.services.registry.jndi.JRMIInitialContextFactory");

p.setProperty(Context.PROVIDER_URL, "jrmi://37.6.129.133:2000");

p.setProperty(Context.URL_PKG_PREFIXES,"org.objectweb.jonas.naming");

InitialContext ctx = new InitialContext(p);

Object obj = ctx.lookup("JNDINameEnterprise1");

enterprise2Home = (Enterprise1Home) PortableRemoteObject.narrow(obj,
Enterprise1Home.class);

Enterprise1 ent1 = enterprise2Home.create();
--------------------

Now it works, but I have to set a timeout to lookup (for example 10
seconds).
If the server on the host is down, or if the host not exist I have to
wait too much time.
In wich way i can set timeout?
I found this but doesn't works:

Can you help me?
Thanks
Johann Burkard - 29 Sep 2003 19:22 GMT
[new Properties]

> Now it works, but I have to set a timeout to lookup (for example 10
> seconds).
> If the server on the host is down, or if the host not exist I have to
> wait too much time.
> In wich way i can set timeout?

I think the ContextFactory might be responsible for setting connection
timeouts, maybe the documentation of
org.objectweb.jeremie.libs.services.registry.jndi.JRMIInitialContextFactory
helps you? If not, ask on their mailing lists.

Johann
|\/|`/ /-\|°|°`/_ ()\/\/|\|`/_ `/()|_||2 |3()><3|\|


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.