You don't want your remote application's classes to be resident in the
access webapp.  I'd suggest we go back to the original problem and try to
solve that; take the application classes out of examples/WEB-IF/classes.
(Aside-- While you're at it, it's worth taking an hour or two to download
Ant, look at the Application Developer docs and sample build.xml included in
the Tomcat distribution, and set up your own webapp to get out of /examples.
It's not that hard, and it makes development much smoother!)

        The original problem looks like the RMIClassLoader can't find the code for
MyAppStarter.  Are you passing or returning an instance of MyAppStarter as
an argument in the RMI call to the server app, or is the server object an
instance of MyAppStarter?  In either case, do you have the codebase property
set on the RMI server JVM?  The system property java.rmi.server.codebase
needs to refer to a set of URLs from which classes used in the RMI call can
be downloaded.  By extension, you need to have those classes available on
some sort of a server, typically ftp or http.  Tomcat'll do it!

        If the codebase is set properly and the download files are available, a
webapp in Tomcat can execute RMI calls on a remote object.  There's one
not-so-small detail left, though; the class loader (RMIClassLoader) that
wants to load the remote bytecode will refuse to work if there's no security
manager, so you need to run Tomcat with the security manager enabled, which
will also require setting up the security.properties file to allow whatever
permissions your application needs.  See the Security Manager HOWTO in the
Tomcat docs.  In your case, you didn't get RMIClassLoader's exception, so I
suspect the codebase problem.

        Note that it's a little awkward to set the codebase on a webapp, so it's
difficult (i.e. possible, but not elegant and not portable) to export remote
objects from a webapp.  I'd say this isn't a Tomcat limitation, so much as a
case of the servlet spec not being written with RMI in mind.  If you need to
support callbacks from the remote application, you need to employ a proxy
strategy.  You might want to look at jini.org for more information on the
proxy concept.

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.ca

>-----Original Message-----
>From: news [mailto:[EMAIL PROTECTED]]On Behalf Of Bill Barker
>Sent: November 27, 2002 00:47
>To: [EMAIL PROTECTED]
>Subject: Re: RMI and Tomcat
>
>
>This is starting to look like a classic case of bad design.
>But to get your
>app working, try adding servlet.jar to the CLASSPATH of rmiregistry.
>
>"Sarah L. Moore" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> Well, I just moved the application classes over to the
>> examples/WEB-INF/classes directory and re-ran my servlet.  I get a
>slightly
>> different message:
>>
>> java.rmi.ServerError: Error occurred in server thread;
>nested exception
>is:
>> java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
>>
>>  From the output of my application, it looks as though the
>application
>> begins to run, but it is the servlet that is throwing the
>above exception
>> upon the call to the RMI application.  I did a search for
>servlet.jar, and
>> it looks as though it is where it should be in the Tomcat directory
>> structure (i.e. catalina_home/common/lib).  Any other
>advice?  I'm at a
>> total loss.
>>
>> Thanks again!
>>
>> Sarah
>>
>> At 11:30 AM 11/27/2002 +0800, you wrote:
>> >Sorry, did not correctly see which class it was complaining
>about. Try
>and
>> >move MyApplicationStarter to the said directories.
>> >
>> >Sarah L. Moore wrote:
>> >
>> >>Thanks for your reply.  My servlet class is in
>> >>examples/WEB-INF/classes.  If I comment out the RMI step,
>the servlet
>> >>runs fine, so I'm left to think that the servlet location,
>etc. are OK,
>> >>but something relating to RMI is the culprit.
>> >>
>> >>At 11:01 AM 11/27/2002 +0800, you wrote:
>> >>
>> >>>" Cannot allocate servlet instance for path
>/examples/servlet/MyServlet
>> >>>" means that it can't find the requested servlet for that
>web app which
>> >>>implies that your servlet class isn't where it should be.
>Servlets &
>> >>>classes go in /examples/WEB-INF/classes or
>> >>>/examples/WEB-INF/lib for jar packages.
>> >>>
>> >>>Sarah L. Moore wrote:
>> >>>
>> >>>>Hello all.
>> >>>>
>> >>>>I am new to Tomcat, and am having a problem with RMI.  I
>have a Java
>> >>>>application that basically just sits on my server
>waiting for a data
>> >>>>vector to be passed to it from my servlet. However, when
>I run the
>> >>>>servlet and try to have it pass the data to the
>application through
>RMI, I get:
>> >>>>
>> >>>>javax.servlet.ServletException: Cannot allocate servlet
>instance for
>> >>>>path /examples/servlet/MyServlet
>> >>>>java.lang.NoClassDefFoundError: MyApplicationStarter
>> >>>>
>> >>>>The application resides in a directory on the root of the c drive
>(i.e.
>> >>>>c:\MyApplication), and the servlet I am working with is in
>> >>>>catalina_home/webapps/examples.  Could it be that my
>problem is due to
>> >>>>the fact that Tomcat can't locate the classes that are in the
>> >>>>c:\MyApplication directory?  How can I remidy that
>problem, if that
>is,
>> >>>>in fact, the problem.
>> >>>>
>> >>>>I am running Tomcat 4 with jdk 1.3.1 on Win2K.
>> >>>>
>> >>>>Please let me know if you need any more information. Any
>help would be
>> >>>>appreciated.
>> >>>>
>> >>>>Thanks!
>> >>>>
>> >>>>Sarah
>> >>>>
>> >>>>--
>> >>>>To unsubscribe, e-mail:
>> >>>><mailto:[EMAIL PROTECTED]>
>> >>>>For additional commands, e-mail:
>> >>>><mailto:[EMAIL PROTECTED]>
>> >>>
>> >>>
>> >>>
>> >>>--
>> >>>To unsubscribe, e-mail:
>> >>><mailto:[EMAIL PROTECTED]>
>> >>>For additional commands, e-mail:
>> >>><mailto:[EMAIL PROTECTED]>
>> >>
>> >>
>> >>
>> >>--
>> >>To unsubscribe, e-mail:
>> >><mailto:[EMAIL PROTECTED]>
>> >>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>> >>
>> >
>> >
>> >
>> >--
>> >To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>> >For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>
>
>
>
>--
>To unsubscribe, e-mail:
><mailto:tomcat-user->[EMAIL PROTECTED]>
>For
>additional commands,
>e-mail: <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to