Posted By:
baba_bangali
Posted On:
Saturday, January 1, 2005 02:11 PM
hi ppl, i getting the same problem again and again...let me first give the code interface, import java.rmi.*; import java.rmi.Remote; import java.rmi.RemoteException; public interface FormTemplateInterface extends Remote { public String formAssignmentTemplate() throws RemoteException; public String formHomeworkTemplate() throws RemoteException; public String formTermexamTemplate() throws RemoteException; public String formQuizTemplate() throws RemoteException; public String formOralTemplate() throws RemoteException; public String formSolutionTemplate() throws RemoteException;
More>>
hi ppl, i getting the same problem again and again...let me first give the code
interface,
import java.rmi.*;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface FormTemplateInterface extends Remote
{
public String formAssignmentTemplate() throws RemoteException;
public String formHomeworkTemplate() throws RemoteException;
public String formTermexamTemplate() throws RemoteException;
public String formQuizTemplate() throws RemoteException;
public String formOralTemplate() throws RemoteException;
public String formSolutionTemplate() throws RemoteException;
public String formCorrectedTemplate() throws RemoteException;
}
the server class,
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.Naming;
import java.io.*;
import java.io.FileReader;
import java.io.BufferedReader;
public class FormTemplates extends UnicastRemoteObject implements FormTemplateInterface
{
private String line;
private String code;
public FormTemplates() throws RemoteException
{
super();
}
public String formAssignmentTemplate()
{
try
{
FileReader fr = new FileReader("c:/tomcat/webapps/applications/info/assignment.template");
BufferedReader br = new BufferedReader(fr);
while( (line=br.readLine()) != null)
{
code = code+line;
}
}
catch(IOException ioe){}
return code;
}
public String formHomeworkTemplate()
{return null;}
public String formTermexamTemplate()
{return null;}
public String formQuizTemplate()
{return null;}
public String formOralTemplate()
{return null;}
public String formSolutionTemplate()
{return null;}
public String formCorrectedTemplate()
{return null;}
public static void main(String args[]) throws Exception
{
if(System.getSecurityManager() == null) System.setSecurityManager( null );
FormTemplates form = new FormTemplates();
Naming.rebind("//localhost/FormTemplateInterface", form);
}
}
and the client ,
import java.rmi.*;
import java.rmi.Naming;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileReader;
public class GenerateTest
{
private String str;
private String selection;
private int i;
private String code;
public GenerateTest()
{}
public String generateTest( ) throws java.rmi.NotBoundException
{
try{
if(System.getSecurityManager() == null) System.setSecurityManager(null);
FormTemplateInterface form = (FormTemplateInterface)Naming.lookup("//localhost/FormTemplateInterface");
FileReader fr = new FileReader("c:/tomcat/webapps/applications/info/exam.info");
BufferedReader br = new BufferedReader(fr);
while( (str = br.readLine()) != null )
{
if(str.startsWith("exam"))
{
String exam = str.substring(4);
selection=exam;
if(exam.equals("assignment")) code = form.formAssignmentTemplate();
else if(exam.equals("homework")) code = form.formHomeworkTemplate();
else if(exam.equals("termexam")) code = form.formTermexamTemplate();
else if(exam.equals("quiz")) code = form.formQuizTemplate();
else if(exam.equals("oral")) code = form.formOralTemplate();
else if(exam.equals("solutionmanual")) code = form.formSolutionTemplate();
else if(exam.equals("correctedexam")) code = form.formCorrectedTemplate();
}
}
}catch(IOException ie){}
return code;
}
}
.
I am compiling and running the programs in the following steps,
javac FormTemplateInterface.java
javac FormTemplates.java
rmic FormTemplates
javac GenerateTest.java
start rmiregistry
java -Djava.rmi.server.codebase=file:/c:/tomcat/webapps/applications/web-inf/classes FormTemplates
At this point its giveing me the following error,
java.rmi.ServerException: RemoteException in thread main nestd exception is
jav.rmi.UnmarshalException: error unmarshalling arguments, nested exception is
java.rmi.ClassNotFoundException: FormTemplates_Stub
I have no idea why this is happening. The interface.java, server.java and client.java files are in the same directory ...../classes. So when i run rmic even the stubs are created in the same directory. but when i start the server using java and java.rmi.server.codebase giving the path to this directory it gives error of stub not found.
I tried using
-Djava.rmi.server.codebase=http://localhost/applications/web-inf/classes
-Djava.rmi.server.codebase=http://localhost:8000/applications/web-inf/classes
(thts the port my server is running on)
-Djava.rmi.server.codebase=http://131.123.36.10:8000/applications/web-inf/classes
but still its giving me the same error.
I would greatly appreciate if someone can help.
Thanks in advance.
<<Less