🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #446

Re: RMI

#446
From: John McGrath [TeamB]
Date: Tue, 19 Aug 2003 04:01
36 lines
2687 bytes
On 8/18/2003 at 6:04:35 AM, Oliver Young wrote:

> > What seems to be happening is that the application ClassLoader is
> > trying to load the dory2.StopDory class.  It does not find it on the
> > class path so it is trying to load it from the RMI codebase.
> Well, it should load it from RMI, that is why I'm using RMI.
> 
> > The reason this is happening before your main program runs is
> > probably because you have a class (static) variable initialization
> > that requires the class to be loaded.
> Could you, please, tell me what to do? I'm not fluent with RMI.

If you want the classes to be loaded from the RMI codebase, you have to
install a SecurityManager, normally an RMISecurityManager.  I presumed
you were doing this, but I should mention this because you did not show
that in the code snippet you posted.

You also need to make sure that the RMISecurityManager is installed
*before* your program tries to load a class from the RMI codebase.
This is more of a Java Language issue than an RMI issue.

Your main class needs to be loaded before the main method can be run
and when that happens, all static initializers are evaluated and all
static blocks are executed.  This occurs *before* your main method is
run.

I presume your code declares and initializes a static variable of one
of your own class types.  This causes that class to be loaded before
the main() method runs.  All you need to do is to move the
initialization.  You can initialize the variable in the main() method,
after the RMI Security Manager is installed.

-- 
Regards,

John McGrath  [TeamB]
Technical Details
Message-ID: <3f41a123$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!128.230.129.106!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f3b90c4$1@newsgroups.borland.com> <3f3e844b$1@newsgroups.borland.com> <3f40a50c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,304739c9281f7628
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2003-08-18 21:10:22 PST
From: "John McGrath  [TeamB]" <ng-b@jpmcgrath.net>
Subject: Re: RMI
Newsgroups: borland.public.jbuilder.java.api
References: <3f3b90c4$1@newsgroups.borland.com> <3f3e844b$1@newsgroups.borland.com> <3f40a50c@newsgroups.borland.com>
User-Agent: XanaNews/1.15.3.1
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
NNTP-Posting-Host: 141.151.11.48
Message-ID: <3f41a123$1@newsgroups.borland.com>
Date: 18 Aug 2003 21:01:39 -0700
X-Trace: newsgroups.borland.com 1061265699 141.151.11.48 (18 Aug 2003 21:01:39 -0700)
Lines: 36
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!128.230.129.106!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail