newbie RMI User

P

Paul Foreman

I have just got an applet I am developing to use the RMI method to get
information from a server.

I was using JBuilder and using try and catch statements for each of the
methods that needed the remote information. So there were several methods
which invoked the RMI method Naming.lookup. All seemed well until I tried to
use the applet in a browser. When I did this I got a 'notinited' message and
the applet failed to load.

By trial and error the applet appears to work when there is only one method
that calls the RMI code.

Is this a genuine limitation in the use of RMI?
Is there a standard way of coding the use of RMI such that many methods can
access one RMI Naming.Lookup set of code?

I hope that I have made my question clear enough. Any advice would be
appreciated.

Regards

Paul
 
A

Andrew Thompson

I have just got an applet I am developing to use the RMI method to get
information from a server.

I was using JBuilder and using try and catch statements for each of the
methods that needed the remote information. So there were several methods
which invoked the RMI method Naming.lookup. All seemed well until I tried to
use the applet in a browser. When I did this I got a 'notinited' message and
the applet failed to load.

<http://www.physci.org/codes/javafaq.jsp#appletie>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

paul.foreman

Andrew,
Thanks for the pointer to IE settings and selecting Java (sun).
I checked my current IE setting which already had Java(sun) selected for
applets.

I did not make it clear that when my applet only had one use of the RMI
Naming.lookup method the applet did run within my browser. It was only when
I re-introduced more than one method in the same applet, that called on the
same remote server that I had a problem. Basically the applet had three
buttons which when pressed called the remote server. Each button invoked a
different remote method on the same server.

Is there any way of getting more information from my PC on why the applet is
failing?

Regards

Paul
 
A

Andrew Thompson


Hi Paul, could you put your replies directly after
the relevant line and trim unnecessary text,
such as signatures?
<http://www.physci.org/codes/javafaq.jsp#netiquette>

See further comments in that style (in-line with trimming)

Can we see you applet? What is the URL?
If it is on a restricted intranet, can you haul
a failing example of it out onto a public URL?

[ I should have asked that first, but forgot
because I was so sure I was right, ..dope me. ]

What *exactly* are you doing in these catch
statements? Do you print the stack trace?

And for that matter, what is an (SHORT)
example code that displays the problem?

<http://www.physci.org/codes/javafaq.jsp#exact>
I do not mean the message you get in the status
bar at the bottom of the browser, the message
in the Java console.
Thanks for the pointer to IE settings and selecting Java (sun).
I checked my current IE setting which already had Java(sun) selected for
applets.

That is confusing to me..
OK, it seems our not inited message is
not the typical
I did not make it clear that when my applet only had one use of the RMI
Naming.lookup method the applet did run within my browser. It was only when
I re-introduced more than one method in the same applet, that called on the
same remote server that I had a problem. Basically the applet had three
buttons which when pressed called the remote server. Each button invoked a
different remote method on the same server.

I have not dabbled in RMI. Hopefully an
RMI guru (or at least somebody more exp.
than myself) will jump right in.
Is there any way of getting more information from my PC on why the applet is
failing?

Well.. You know about the Java console?
Tools | Sun Java Console
...if you are printing stack traces, it should
give you the exact line number the problem occurs.

Now.. did you notice how I cleverly answered your
questions by bombarding you with many more?
Almost makes me seem like I have a
clue what is going on here. ;-)

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

paul.foreman

Andrew,
I have trimmed my repy and changed my question a little,
based on more information.
Can we see you applet? What is the URL?
If it is on a restricted intranet, can you haul
a failing example of it out onto a public URL?
The applet is not on the internet yet - I am not yet sure how I am going to
do this. I hope we can progress without it being directly visible.
The message in the Java Console was: "Problem with RMI URL
java.rmi.UnmarshalException: error unmarshalling return; nested exception
is: java.lang.ClassNotFoundException: access to class loader
denied"
The first few lines of the stack trace were:

Dump thread stack ...
----------------------------------------------------
Full thread dump Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode):

"Java2D Disposer" daemon prio=10 tid=0x0B34FDB8 nid=0x8d4 in Object.wait()
[b67f000..b67fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <10843438> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <10843438> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-0" prio=7 tid=0x0B2F31D8 nid=0xb58 in Object.wait()
[b97f000..b97fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <10801A18> (a java.awt.EventQueue)
at java.lang.Object.wait(Unknown Source)
at java.awt.EventQueue.getNextEvent(Unknown Source)
- locked <10801A18> (a java.awt.EventQueue)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


When I ran the applet under JBuilder4 all worked fine. When I tried to run
the applet from a browser I now obtain the message above. It would appear
that the client is not finding the Class files in the Server application.
Even though this does not appear to be a problem when running under
JBuilder.
I have not dabbled in RMI. Hopefully an
RMI guru (or at least somebody more exp.
than myself) will jump right in.


Well.. You know about the Java console?
Tools | Sun Java Console
..if you are printing stack traces, it should
give you the exact line number the problem occurs.

Now.. did you notice how I cleverly answered your
questions by bombarding you with many more?
Almost makes me seem like I have a
clue what is going on here. ;-)
Andrew I do appreciate your help - answering your questions has helped me to
understand a bit more. Especially the existence of the Java console.
 
A

Andrew Thompson

The message in the Java Console was: "Problem with RMI URL
java.rmi.UnmarshalException: error unmarshalling return; nested exception
is: java.lang.ClassNotFoundException: access to class loader
denied"

Is you applet signed?

An applet running in JBuilder (or applet viewer)
has greater permission to access the local file-system
than one operating in a browser.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

Paul Foreman

Is you applet signed?
The applet is not signed - If this is needed then I will have to learn how
to do that.
An applet running in JBuilder (or applet viewer)
has greater permission to access the local file-system
than one operating in a browser.
The server and applet are being run on the same machine. Also I have created
a new Java security policy file which gives all permissions to everything,
as per the JBuilder tutorial. One question is would Jbuilder be using a
different instance of Java than my browser? I do have three instances of
Java J2RE1.4 installed on my PC, only one of them being in a JBuilder
directory.
Another area of concern is if the applet is pointing to the correct
directory for the server classes. The applet does run under Jbuilder, so I
have assumed that the necessary paths are in the Java classes, is it
possible that this is not the case? How would I check to verify?

Regards

Paul
 
A

Andrew Thompson

The applet is not signed - If this is needed then I will have to learn how
to do that.

(pauses) I am not certain Paul.
( Where are you bloody RMI people? The 'Remote'
does not mean you cannot talk to people! ;-)

I would expect a 'SecurityAccessException' in
circumstances like this, but it looks like that
might be 'wrapped up' inside the UnmarshalException,

OTOH the Java Glossary does not mention security in
<http://mindprod.com/jgloss/runerrormessages.html#UNMARSHALEXCEPTION>
and <http://mindprod.com/jgloss/applet.html#RESTRICTIONS>
only mentions RMI in terms of a remote server..
That does not apply here does it?

What is you are doing with classloaders?

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

paul.foreman

The latest and hopefully the most helpful error message from the Java
Console is:

java.lang.NoClassDefFoundError: tm421_2nd/FamilyViewer

at viewer2.Applet1.viewPerson_actionPerformed(Applet1.java:220)

The viewPerson_actionPerformed is a method in the applet which calls the
server via RMI. The file tm421_2nd/FamilyViewer directory contains the Java
class files that the applet is trying to use.

The server and applet are running on the same PC. I have a .java.policy file
which permits all.

I am really not sure what to try next.
 
A

Andrew Thompson

..error message from the Java Console is:

java.lang.NoClassDefFoundError: tm421_2nd/FamilyViewer

Try putting this..

Object o = new Object();
URL resource = o.getClass().getResource("/tm421_2nd/FamilyViewer.class");
System.out.println( "resource: " + resource );

at viewer2.Applet1.viewPerson_actionPerformed(Applet1.java:220)

...immediately before line 220.
I am really not sure what to try next.

See above, and show us your applet element,
exactly as you have it in the HTML.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

paul.foreman

Try putting this..

Object o = new Object();
URL resource = o.getClass().getResource("/tm421_2nd/FamilyViewer.class");
System.out.println( "resource: " + resource );
I have inserted the code above. When run in JBuilder it returned the path of
the server classes for FamilyViewer
"/C:/TM421_2nd/classes/tm421_2nd/FamilyViewer.class".
When run from the browser it returned a "null".
See above, and show us your applet element,
exactly as you have it in the HTML.
The HTML for the applet is shown below:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
HTML Test Page
</TITLE>
</HEAD>
<BODY>
viewer2.Applet1 will appear below in a Java enabled browser.<BR>
<APPLET
CODEBASE = "."
CODE = "viewer2.Applet1.class"
NAME = "TestApplet"
WIDTH = 400
HEIGHT = 500
HSPACE = 0
VSPACE = 0
ALIGN = middle</APPLET>
</BODY>
</HTML>

Thanks for the suggestions so far.

Regards

Paul
 
A

Andrew Thompson

I have inserted the code above. When run in JBuilder it returned the path of
the server classes for FamilyViewer
"/C:/TM421_2nd/classes/tm421_2nd/FamilyViewer.class".
When run from the browser it returned a "null".

You web-page based applet is not finding the class..
....
<APPLET
CODEBASE = "."
CODE = "viewer2.Applet1.class"

I forgot to ask, where is this web-page?
the codebase='.' will find your class at
(code base)/viewer2/Applet1.class

With no further information, the VM in the
browser is looking for the other class at..
(code base)/tm421_2nd/FamilyViewer.class

So, are the packages 'viewer2' and 'tm421_2nd'*
in the same directory?

* which, by the way, is an horrific name for
a package.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
P

paul.foreman

Andrew,
Just to let you know that I have got the applet working now.
Thanks for your suggestions and help over the weekend.

One of the problems was indeed the location of the class files for the
server. Also the reference I gave the RMI registery - it should have been a
html reference instead of a file reference.
So, are the packages 'viewer2' and 'tm421_2nd'*
in the same directory?

* which, by the way, is an horrific name for
a package.
Agreed :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top