Help coderanch get a
new server
by contributing to the fundraiser

Con Lu

Ranch Hand
+ Follow
since Aug 27, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Con Lu

I am new to J2EE, and have just been through Monson-Haefel, Roman, and JSP / Servlet books.
I have also been through a variety of examples, and have downloaded and run the Petshop example on Weblogic 6.1 .
It would be helpful, however to be able to analyse the code in detail together with explanations and diagrams of what is happening.
Is this material available. If not are there any other study texts available that build a complete application from the ground up ?
Any help much appreciated,
Con
I am going through the weblogic workbook for Monson-Haefels book.
I am using weblogic 6.1sp4, and am having problems deploying my first bean (Exercise 4.1).
All the steps seem okay until I target the EJB "titanejb" with the server "myserver".
I then get "Errors occurred while processing your request", and subsequently the CabinHomeRemote object and the titan-dataSource don't appear in the JNDI tree.
The exception is "Distributed Management [1 exception]".
Can anyone tell me what I am doing wrong?
Thanks in advance
20 years ago
I have already flushed the PrintWriter. Please see code below:-


// CLIENT CLASS CODE

[ June 13, 2003: Message edited by: Michael Morris ]
Just to add that the question above is regarding pre-1.4 code.
Thanks
1)I have written a SocketServer on one machine which
a.Waits for a connection from a client
b.Sends a message to the client using a PrintWriter
c.Receives a message from the client using a BufferedReader
2)On another machine I have a client program which
a.Creates a connection with the server
b.Receives the message from the server using a BufferedReader
c.Sends a message to the server using a PrintWriter
My intention was for the tasks executed in the following order:-
1a,2a,1b,2b,2c,1c
Instead, when run the following happens
1a,2a
And then the client stalls (blocking I think).
The following scenarios were tried to ascertain the problem (but to no avail)
A)If I keep the server code the same but comment out step 2b from the client code, the following happens (with 1b, 2b missing)
1a,2a,2c,1c
B) If I keep the server code the same but comment out step 2a from the client code the following happens (with 1c, 2c missing)
1a,2a,1b,2b
C)Keeping the client code the same but comment out step 1b from the server code only following occurs, (with 1b, 1c, 2b, 2c missing)
1a,2a
D)Keeping the client code the same but commenting out step 1c from server results in 1c missing ie
1a,2a,1b,2b,2c

What is the problem? It seems like there is blocking going on somewhere. Is it not possible for a server and client to communicate backwards and forwards?
If necessary, please mention and I will post the code.
Thanks in advance,
I will firstly describe how my RMI example works fine WITHOUT a Security Manager. Then I will describe the problems when running WITH a Security Manager
WITHOUT A SECURITY MANAGER
The following files are included in directory C:\A\B\C\bank on machine C1
BankInterface.class
ASBBank.class (Remote object implementing BankInterface.class)
ASBBank_Skel.class
ASBBank_Stub.class
ATMServer.class
The following files are included in directory C:\D\E\F\bank on machine C2
BankInterface.class
ASBBank_Skel.class
ASBBank_Stub.class
ATMClient.class
Steps when run successfully without a security manager
On C1
1) Set classpath to c:\A\B\C
2) Go to c:\A\B\C
3) Type command: start rmiregistry 2010
4) Start server by: java bank.ATMServer C1:2010
On C2
1) Set classpath to c:\D\E\F
2) Go to c:\D\E\F
3) Type command: java bank.ATMClient C1:2010
Program works!!!
WITH A SECURITY MANAGER
When using a security policy file the following changes are made:-
On C1
1) ATMServer main method is changed to include following code:-
if(System.getSecurityManager() == null)
System.setSecurityManager(new
RMISecurityManager());
2) Create security policy file c:\security\java.policy as follows:-
grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept";
};
Steps when run unsuccessfully
On C1
1) Go to c:\A\B\C
2) Type command: start rmiregistry 2010
3) Start server by:
java
-Djava.security.policy=c:\security\java.policy bank.ATMServer C1:2010
4) Result:
Error – java.security.AccessControlException: access denied (java.net.SocketPermission C1 resolve)
QUERIES:
1)What am I doing wrong – how can I get the application to work?
2)Even if I got the server to work on C1, is it necessary to create a separate security policy for C2, as well as set a Security Manager in ATMClient similar to in ATMServer?
3)Could it be that other security policies (some also named java.policy) for other applications (such as WebLogic etc) on my machine are overriding my specific security policy file?
Any help would be very much appreciated, as I am getting really frustrated (as evidenced by my number of posts!?)
21 years ago
Can you use Tomcat to deliver classes when using
dynamic class loading?
How would you set this up?
Thanks in advance,
21 years ago
When running an RMI example
1) Do you have to specify a security policy file for
BOTH the client and server machines
2) If so, do you run the server and client by commands such as the following?
java -Djava.security.policy=c:\DirOnServer\wideopen.policy myRMIServer
java -Djava.security.policy=c:\DirOnClient\wideopen.policy myRMIClient
3) Do the commands above have to refer to policy files on their own machines or if they don't how do you refer to a policy file on another machine?
I am getting very confused, and any help would be much appreciated!
By the way, I am having problems getting examples on the Internet (such as Sun's)to work. Many examples seem to brush over compilation and setup (or where to put certain files etc)- especially those examples concerning web-servers, dynamic class loading, and security files. Does anybody have links to good step-by-step examples / resources?
Thanks
21 years ago
How would you set up Tomcat to provide dynamic class loading of stubs to clients?
Thanks
21 years ago
Do you have to use a web server when making use of dynamic class loading?
Thanks,
21 years ago
I am new to RMI, and have been working through the examples in Sun's docs.
When running the RMI activation example, problems first begin when I type the following at the command line:
rmid -J-Djava.security.policy=rmid.policy
After typing the above I get the following warning:-
"Activation.main: warning: sun.rmi.activation.execPolicy system property unspecified and no ExecPermissions/ExecOption Permissions granted; subsequent activation attempts may fail due to unsucessful ExecPermission/ExecOptionPermission permission checks. For documentation on how to configure rmid security, refer to
http://java.sun.com/j2se/1.4/docs/tooldocs/win32/rmid.html"
Note after this I continue to try and run the Setup program but unsuccessfully, the exception trace being a java.security.AccessControlException
Note that I am using Windows 2000. I have also compiled all the classes, stubs in the one directory from which I am running the registry,rmid etc . The policy file is in the same directory.
The policy file reads as follows:-
grant {
// Allow everything for now
permission java.security.AllPermission;
};

Any help would be much appreciated,
Thanks
21 years ago
Using the following code I can find the IP
address of my computer on my home network:
import java.net.*;
public class LocalHostDemo{
public static void main(String args[]){
System.out.println("Looking up local host");
try{
InetAddress localAddress = InetAddress.getLocalHost();
System.out.println("IP address : " + localAddress.getHostAddress());
}
catch(UnknownHostException uhe){
System.out.println("Error - unable to resolve localhost");
}
}
}
How can I find my computer's dynamic IP address provided by my ISP?
Thanks,
21 years ago
Thanks all for previous input,
What DOES Ba Miao Zhu Zhang mean (I am an overseas born Cantonese!)?
BTW, which skills would be the more commercially applicable for an entry - level programmer?
Those, learned while doing SCJD or SCAE?
It seems to me that experimenting with SCAE would gain me more exposure to commercial containers such as Websphere etc and databases.
SCJD seems to cover the practical basics such as sockets, RMI etc, and gives one the opportunity to apply those skills.
On a job, however, wouldn't it be more likely that having experience with J2EE is more important? I mean when would you be required to write your own database (ala SCJD)?
Of further interest - how stable is SCAE? It seems from reading here that changes are in the wind. What happens if you finish P1 and changes to P2 and 3 are initiated?
Any comments would be appreciated as I am still considering my next move with regards to Sun Java education.
Thanks,
I have been studying Java at home for the past year, and am a certified SCJP and SCWCD.
I have had no commercial programming experience,
however have managed to pass both previous exams with 91% pass rate.
The reason why I sat these exams was to improve my opportunities in finding employment as an entry-level programmer. (Note that I am an unemployed civil/structural engineer by profession).
Most jobs in NZ, seem to advertise for J2EE experience, and entry level positions are thin on the ground. My queries are as follows:-
1) Is J2EE Architect Exam P1 possible (like the other 2) to pass without any prior commercial programming experience?
2) Would sitting the exam be worthwhile for an introduction to the subject alone?
3) Is the J2EE Exam book by Bambara and Allen, suitable as an introductory textbook to the subject?
4) I have browsed through Ed Roman's Mastering EJB and Monson-Haefels Enterprise JavaBeans. What other reading do you suggest for sitting the exam?
5) Which freely available J2ee container would you recommend using for personal use?
6) Would passing Part 1 be useful for finding employment?
Much appreciated,
Con
I have the following directories:-
c:\ide-userdir\sampledir\StructuralCalc
Inside StructuralCalc I have the following:-
1) StructuralCalc\pics\BankOfChina.jpg
2) SplashPanel.java
3) TrySplashPanel.java
Inside SplashPanel.java I have the following code
JLabel jL1 = new JLabel(new ImageIcon("pics\\BankOfChina.jpg"));
SplashPane1 is then included in TrySplashPanel.java
Both files compile, but when I run TrySplashPanel, the program can't seem to locate the jpg.
Note that all files in Structural Calc have been set up as a project ie All the files begin with package StructuralCalc;
Any help would be much appreciated