Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Chat

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 
Office Hours Transcripts Index

Office Hours:
Introduction to the JavaBeansTM API
August 26, 1999

This is a moderated forum.

Moderator (MDR-rohaly): Tim Rohaly of the MageLang Institute

MDR-rohaly: Hello, I'm Tim Rohaly, from the MageLang Institute, and I'd like to welcome you once again to the Java Developer ConnectionSM and to this discussion forum. Today we are holding office hours for the on-line training short course Introduction to the JavaBeansTM I encourage you to ask any questions about the course material or the practical excercises. I will also be happy to answer any questions about JavaBeans in general. I will be running this as a *moderated* forum, meaning that your questions are automatically sent to me first; I will forward the questions to the group one at a time. So don't panic if your question doesn't appear right away! You may also initiate a private discussion with me if you have questions about how this session is running. This forum is scheduled for 11AM to 12AM PDT, and since it is just 11AM now, I'll now open the floor to questions.

edo: Can you contrast JavaBeans with Enterprise JavabeansTM?

MDR-rohaly: JavaBeans and EJB are two very distinct technologies. The thing they have in common is the concept of a 'component'. JavaBeans components are typically clientside and often (but not necessarily) GUI-oriented. Enterprise JavaBeans, on the other hand, are typically serverside. EJBs are much more complex to develop, but on the other hand they fill a much larger role in enterprise application architecture.

jayug: Hi, Can I ask you a question on RMI? Thanks.

MDR-rohaly: Well, this is not really an RMI chat, but since there isn't anything else going on, sure, why not.

jayug: Thanks, I am trying to run the RMI example from the Java tutorial. It claims that stubs can be downloaded from the server to the client. But, I don't have any success. If I copy the stub to the client, a non-remote object that needs to be passed from the client to the server does NOT succeed. I get a serversideException of ClassNotFoundException, even though the server has an interface to this non-remote object. Please clarify.

MDR-rohaly: jayug, you are having the same problems that all first-time RMI users seem to have. From your message it is not exactly clear what you are trying to do - are you trying to dynamically download the stub from the server to the client, or are you trying to pass non-remote objects?

MDR-rohaly: Have you tried looking at the RMI FAQ It has a lot of answers to questions like these.

jayug: According to the example, the stub on the serverside, is supposed to download dynamically onto the clientside. Then the client invokes a remote method passing a non-remote object as its arg. The server has an interface to this arg, executes the method on the serverside and passes the result to the client as another object. Anyway, the basic problem seems to be passing objects. I know for sure that the client bounds to the server. Also the stub is known to the registry through -Djava.rmi.server.codebase parameter. I don't know why it does not get downloaded to the client. I think, I went through this FAQ. But, I'll check it once again. Thanks. But, if it's a simple common problem, please explain.

MDR-rohaly: jayug, I haven't used the example in the RMI tutorial, but you know that objects are passed either as remote objects (by remote reference) or as serialized objects (by value). I will assume you are using the code from the tutorial unmodified, and that the tutorial code does indeed work. What you are likely seeing is simply a matter of configuration, where the class files are installed, what CLASSPATH you are using, where the http server is located and whether it has access to the classes that need to be dynmically downloaded, etc. These issues are not always simple, but they are straightforward. The faq does have a lot of suggestions about this stuff. *My* suggestion would be to try to run your code using different folders/machines/user account than the ones you used to compile your code. This way, the chance of having a misconfiguration is minimized. It looks like your server probably has annotated the object with the wrong codebase, so the client is trying to load the serialized object's class definition locally rather than from across the network. But without the exact errors and without stepping through what you have done and your environment, that is only a guess.

Bill: Hi, just getting back into programming after 20 years and looking into the Java programming language. I have also used workshop in addition to JavaBeans API, how do they compare/relate? And any suggestions for rookies in the Java programming language. Thanks.

MDR-rohaly: Bill, Java WorkshopTM is one of many development environments that facilitate writing and debugging Java programs. I think this is a good place to start, because it makes creating complex programs easier. All of the IDEs have built into them some ability to deal with JavaBeans. JavaBeans is the most convenient and portable way of specifying and using software components, and the job of an IDE is to try to make compartments of everything and to let the end-user manipulate these componets. So IDEs *use* components. IDEs often have components built into them (e.g. a palette of components that the user can use to build an application) and often allow you to create and add your own components. In this sort of environment, you can think of JavaBeans as a means of extending the capability of an IDE. Fundamental to an IDE, however, is hiding complexity from the client. So I think at some point it is very useful to break away from the IDE, develop things on your own using a text editor and command-line tools. Only then IMO do you get a real understanding of what happens underneath. Then you can always go back to using the IDE and reap its benefits.

jayug: Thanks, I'll try the FAQ.

MDR-rohaly: jayug, Let me also recommend the RMI mailing list. You can subscribe at
http://archives.java.sun.com/cgi-bin/
wa?SUBED1=rmi-users&A=1

If you read the traffic on this list for about a week you will see most common problems discussed at least once. There is also a searchable archive of the list at
http://archives.java.sun.com/archives/rmi-users.html
where you can usually find detailed answers to questions like this.

jon: rohaly, I have a question about beans usage with applets/servlets -- maybe you could comment or suggest some research directions. Suppose I have a servlet that invokes a JAVA Server PageTM, returning the data from a ResultSet in an EJB. On the JSP I have an applet that will then render the bean data. How would you recommend that I share the returned data from the EJB within the applet? I've read some about InfoBus, are there alternatives? Another approach might be to invoke the servlet request directly from the applet, and have the servlets return bean data in the response. Are there advantages/disadvantages to these approaches? Other suggestions?

MDR-rohaly: A couple of things... Your architecture sounds a little confused to me. I'm not sure what you mean by a servlet which invokes a JSP. If your goal is simply to present data to the client, then I would have the applet post a request to a servlet and have the servlet return the data. The details of where the servlet gets the data from shouldn't be visible to the client applet. In particular, if the servlet uses an applications server and EJBs to get results out of a relational database, then the applet should make a general query based on business rules and the servlet should function as middleware. EJBs can be a powerful tool to implmement this middleware to database interaction, but that has nothing to do with the applet. Other or more architectures may also be appropriate, but this is the approach I would try first.

Bill: Thanks, Rohaly, I ran this question by two guys who claimed to have years of Java programming experience the other night at Borders book store and neither had heard of workshop nor were familiar with beans, and I was beginning to wonder if I might of lost it. Out of the three stacks of Java books they had, I got the Sams Teach Yourself Java for $20, which mentioned Workshop once and finally got into the guts of beans after 189 pages. I guess now, I need to like you suggested spin a lot of programs, and I hope to be able to join your Thursday sessions, which has been helpful, thanks. Bill

MDR-rohaly: Bill, Don't forget to check out the JavaBeans Short course here on the JDC at
http://developer.java.sun.com/developer/
onlineTraining/Beans/JBeansAPI/shortcourse.html

There is a lot of other good training stuff here as well. I would also recommend the Java Tutorial which, despite it's name, discusses many advanced topics - it just assumes you started out knowing little, and takes you up to expertise. The Java Tutorial can be found online at
http://java.sun.com/docs/books/tutorial/

MDR-rohaly: Well, our time is up for this week. Thanks for coming to this session of the JavaBeans Short Course office hours. Please watch the JDC home page at http://developer.java.sun.com/ for announcements of future office hours and other live events. Bye.

MDR-rohaly: Last moderator (me) signing off. The forum is now unmoderated

Forum closed at Thu Aug 26 13:13:57 1999

Max number of users at any time: 4

coffeecup


Reader Feedback

Tell us what you think of this transcript.

Duke

Very worth reading Worth reading Not worth reading

If you have other comments or ideas for future articles, please type them here:


Print Button
[ This page was updated: 21-Sep-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary | Feedback | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.