Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Binding remote objects using Servlets

0 views
Skip to first unread message

Rajkumar Chandrasekaran

unread,
Nov 22, 2004, 4:34:26 AM11/22/04
to
Hi,

I am using weblogic 8.1 for app. development. I have 4 startup classes which binds the objects so that they can be invoked remotely. these classes are given in the startup class tag in the config.xml file. I have to remove these startup classes because of our folder structure problems. If i call the same class using a servlet and the servlet is configured as a startup servlet i am getting the following exception

Completed Loading Serialized Catalog: Mon Nov 22 12:16:22 GMT+05:30 2004
ReferenceDataServerImpl.main: an exception occurred:
weblogic.rmi.ConnectIOException: An unexpected exception occurred
at weblogic.rmi.Naming.toWeblogicRmiException(Naming.java:244)
at weblogic.rmi.Naming.rebindInternal(Naming.java:176)
at weblogic.rmi.Naming.rebind(Naming.java:162)
at com.bellatlantic.eo.service.common.referencedata.ReferenceDataServer

Folloing are excerpts from my code

public static void main(String args[]) {


try {
ReferenceDataServerImpl rd = new ReferenceDataServerImpl();
Naming.rebind("ReferenceDataServer", rd);
Debug.out("ReferenceDataServerImpl created and bound in the registry " +
"to the name ReferenceDataServer");

The servlet which invokes the above method is as follows:-

public class Startup extends HttpServlet {

public Startup()
{
String args[]={};
ReferenceDataServerImpl.main(args);


Please let me know your suggestions and comments and also let me know if i am wrong somewhere

Hussein Badakhchani

unread,
Nov 23, 2004, 4:05:11 AM11/23/04
to
Hello,

So iuf I understand you correctly your startup classes worked perfectlt well but now you cannot use them so you wrote a servlet to do the same task that trys to reuse them but you get the error.

I would try copying the code from the startup class into the servlets init() method rather than calling the old startup classes main method then ditch your startup class.

If you really want/need to resuse your start classes delegate the tasks to different public methods rather than doing everything in main() then again call these methods on your startup class from your servlets init method.

e.g.

Startup class

public static void main(String args[]) {

Mystartup start = new Mystartup();
start.rebind();
}

public void rebind() {

try {
ReferenceDataServerImpl rd = new ReferenceDataServerImpl();
Naming.rebind("ReferenceDataServer", rd);
Debug.out("ReferenceDataServerImpl created and bound in the registry " +
"to the name ReferenceDataServer");

}

Servlet

init() {

Mystartup start = new Mystartup();
start.rebind();
}

Cheers,
Hoos

Rajkumar Chandrasekaran

unread,
Nov 23, 2004, 9:09:42 AM11/23/04
to
Hi,

Tried that out as well. Still the same error is occuring


Thanks
Rajkumar

Hussein Badakhchani

unread,
Nov 23, 2004, 9:24:39 AM11/23/04
to
Rajkumar,

Can we establish whether or not you can bind anything at all to the JNDI tree from your servlet. Try binding and undinding a simple Object to the JNDI tree from your servlet. If you can get this working we can be sure there is nothing funny going on.

Hoos

Rajkumar Chandrasekaran

unread,
Nov 24, 2004, 8:57:19 AM11/24/04
to
hi,

No hoos i am not able to bind anything as a remote object from my servlet or jsp for that matter. Can u tell where i could go wrong


Thanks
Rajkumar

Hussein Badakhchani

unread,
Nov 24, 2004, 11:51:53 AM11/24/04
to
Rajkumar,

Can you anser the following:

1) Do your startup classes work with this code?

2) Is the ReferenceDataServer accesible to your client and accepting connections on port 1099?

3) if the answer to 2 is yes can use see anything in the ReferenceDataServer showing clients trying to connect?

Cheers,
Hoos

Rajkumar Chandrasekaran

unread,
Nov 30, 2004, 12:22:26 AM11/30/04
to
The code is working properly with the startup classes.

But there is no port opened on port 1099

Thanks
Rajkumar

Rajkumar Chandrasekaran

unread,
Nov 30, 2004, 12:24:27 AM11/30/04
to
hi,

I have one more question, does weblogic servlet container has any limitations to the fact of binding of remote objects

Please clarify

Thanks
Rajkumar

Hussein Badakhchani

unread,
Nov 30, 2004, 3:04:31 AM11/30/04
to
> I have one more question, does weblogic servlet
> t container has any limitations to the fact of
> binding of remote objects

I don't think so but I will have a root around, see this:

http://www.cs.unc.edu/Courses/jbs/lessons/java/java_rmi/RMIHelloServlet.html

Hoos

Hussein Badakhchani

unread,
Nov 30, 2004, 2:00:40 PM11/30/04
to
Hello Rajkumar,

I am a little confused here. The javax.rmi.Naming class is used to bind objects to an RMI registry. The registry typically runs on port 1099, hence my asking you to check for any thing listening on this port.

The method you describe binds objects to the JNDI tree using the t3 protocol, perhaps you read [url=http://e-docs.bea.com/wls/docs81/jndi/jndi.html]WLS JNDI Docs[/url]
So I guess you are binding your RMI implementation Object to the JNDI tree then the rest of your code (will) look it up from the JNDI tree and use in the usual way. I still don't fully understand why your original code did not work except that you are now binding this object rather than rebinding which implys your original code may have failed in a Servlet because the object you were looking for was never bound.

Any way now that it does work before you rush off changing all your code can you check that it needs changing at all. If it does then to answer your second question carrying out JNDI lookups (incuding creating contexts etc) certainly does have a performance hit. Also as you have found out the hard ward way because your code directly does all the lookups explicitly you end up with hard to manage code. Fortuantly there is a well known design pattern that addresses both of these issues see
[url=http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html]Service Locator[/url]

This link talks about EJBs but it is perfectly applicable to what your doing.

Good luck,
Hoos

Hussein Badakhchani

unread,
Nov 30, 2004, 2:20:52 PM11/30/04
to
Ahh,

I found this:

"In addition, WebLogic RMI is fully integrated with WebLogic Java Naming and Directory Interface (JNDI). Applications can be partitioned into meaningful name spaces by using either the JNDI API or the Registry interfaces in WebLogic RMI."

Can you try in your servlet to use javax.rmi.Naming.bind (not rebind) to bind your object and see if this works.

How are you looking up the Object, using JNDI method (ctx.lookup) or RMI method Naming.lookup?

Hoos

0 new messages