In the response of Sun Engineers, I got another useful information, and Samples / RMI-IIOP / Simple under the installation directory of Sun ONE Application Server has an example of a complete ordinary application call EJB.
Hurry and practice, follow the documentation step by step, it is very easy and pleasant, except for EJB STUB, and use the application server installation directory to AppServ-ext.jar.
The same problem occurred in the section of "Local or Remote RMI / IIOP-BASED CLIENT WITHOUT ACC (Application Client Container", and the program is dead, there is no reaction.
What is this? In my determination, I really followed the document step by step, I have a kind of feeling that I have no reason.
When I was bored, I swept a look. Troubleshooting:
If you have any problems with running applications, look at the log of the Server.
Ok? Yes! I watched the Client side and didn't think of the Server end at all. Open the log of Server, an exception makes me bright:
Com.iplanet.ias.cis.connection.connectException: com.iplanet.IAS.CIS.Channel.tcp.tcpnativeException: -5973: endpoint.jni_getvalidaddressNative: Pr_GethOstbyAddr () Failed
At com.iplanet.ias.cis.connection.connection.
At com.Iplanet.ias.cis.connection.serverConnection.accept (ServerConnection.java: 251)
At com.sun.corba.ee.internal.iip.listenerthread.run (listenerthread.java: 77)
Caused by: com.iplanet.ias.cis.channel.tcp.tcpnativeException: -5973: endpoint.jni_getvalidaddressnative: pr_gethostbyaddr () Failed
At com.Iplanet.ias.cis.connection.endpoint.getValidaddressnative (NativeMethod)
At com.iplanet.ias.cis.connection.endpoint.getvalidaddress (endpoint.java: 239)
At com.iplanet.ias.cis.connection.endpoint.
At com.iplanet.ias.cis.connection.endpoint.GetendPoint (endpoint.java: 73)
At com.iplanet.ias.cis.connection.endpoint.GetendPoint (endpoint.java: 78)
At com.Iplanet.ias.cis.channel.tcp.tcpchannel.getperendpoint (tcpchannel.java: 74)
At com.Iplanet.ias.cis.connection.connection.
... 2 more
Although this exception is alone, I can't learn what the problem is, but this is more likely to be a lot more. Ask Sun Engineers to ask again. Soon, I got a reply. Obviously, this issue is already a light car ripping for Sun's engineers. When the RMI communicates, the host address resolution is required, as long as the two machines are in the host name and IP in the HOSTS configuration file in two machines. On WinXP, this file is C: / Windows / System32 / Drivers / etc Directory in the directory of Hosts, on Solaris, this file is / etc / hosts. Add IP and hostnames to the file xxx.xxx.xxx.xxx Hostname
Run, bingo, success! The answer to the Sun engineer really effectively. Just I want to pass, I use IP direct connection, what is the relationship with the host name. Obviously, this is unhappy, because when deploying in the future, this must be written in the installation manual, increase complexity, involve not just the deployment of the application itself.
Try your example again. Obviously, how many deviations in front of my thoughts have not joined EJB stubs, but not the fundamental reason, address analysis is the fierce of my code. Ok, join EJB Stub and AppServ-ext.jar, run, I finally saw the long-awaited greetings. In this call, I didn't use the two parameters of ORB, which is probably one of the differences between J2EE RI and Sun One Application Server! But later facts, this is not an insurmountable divide. The original exception appears in the Server end, why should the client end? So I dropped the mapping of the Client End IP and hostname, using IP calls no problem, when using the host name, throw an exception that cannot be connected to ORB. No problem, the same as I expected.
Make persistent efforts, try to call in the servlet. Because the servlet is eventually running on the application server, I saved AppServ-ext.jar, only EJB Stub. programming,
With parameters, deployment ... and problems, how do it prompt me
Finally got the problem of remote calling EJB on Sun One Application Server, and one parameter originally set has caused my interest. The front setting has such a sentence: env.put ("java.naming.factory.initial", "com.sun.jndi.cosnaming.cnctxfactory"); this com.sun.jndi.cosnaming.cnctXFactory is not a J2EE package Instead, it exists in rt.jar, in other words, it is J2SE. Is it available on J2EE RI? With this problem, I turned out the previous example, changed the parameters, remove the two parameters of ORB. Run, Hello is coming. It can be called so much. I know so, why bother?
Summary, it is a collection of experience and lessons! The parameters of the J2EE RI and Sun ONE Application Server General call remote EJB are: java.naming.factory.initial = com.sun.jndi.cosnaming.cnctxfactory java.naming.provider.ur = IIOP: // Host: port If you use SUN One Application Server, calling remote EJB to add mapping of the calling end IP and host names in the HOSTS configuration file on the machine deploying EJB. If the call end is used in the IIOP parameter, the IP and host names of the machine to deploy EJBs are required to be added in their HOSTS configuration file. On WinXP, the Hosts profile is a directory of C: / Windows / System32 / Drivers / etc; in Solaris, this file is / etc / hosts. The way to add IP and hostname mapping in the file is xxx.xxx.xxx.xxx Hostname
It is also a problem, although it is exhausted, but also feeling pleasant! The victory after fighting is always the most wonderful.