Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to instantiate my middle tier class??see code

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Headache I am try to instantiate this class below

this is the first line of codes in my client application it keeps on throwing remote exception yet I am connecting locally any suggestions I can get my application to work with another middle tier but I was extending data I dont want to that>........

//global variable
private DataClient myInstance11;

public client()
{
try
{
myInstance11 = new dataConnectImpl("C:\\scjd\\starting\\client\\db.db");
}
catch(RemoteException e)
{
System.out.println("OH not again");
}
.
.
.
.
//end client class
exception "OH not again" is being thrown all the time ???
//here is my middle tier class to handle local and Remote see below it has all the methods of the DataClient Interface see Below...............................

import java.io.*;
import java.util.*;
import suncertify.db.Data;
import suncertify.db.DataClient;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class dataConnectImpl extends UnicastRemoteObject implements DataClient
{
private Data InstanceOne;
public dataConnectImpl(String dbName)throws DatabaseException,RemoteException
{
super();
try
{
System.out.println("Im here before");
InstanceOne = new Data(dbName);
System.out.println("Im here after");
}
catch(Exception ex)
{
System.out.println("Error Creating Instance in DataClientLocal");
}
}
public FieldInfo [] getFieldInfo()throws RemoteException
{
FieldInfo[] info = null;
try
{
info = InstanceOne.getFieldInfo();
}
catch(Exception e)
{
}
return info;
}
.
.
.
.
.
.
.
.
}end class
Thanks in advance Lisa
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here my interface for the previous error
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
import java.rmi.Remote;
import suncertify.db.DataInfo;
import suncertify.db.FieldInfo;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException,RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException,RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria)throws DatabaseException, RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getRecordCount() throws RemoteException;
}
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try:
1) myInstance11 = new dataConnectImpl("C:\scjd\starting\client\db.db");
2) All data methods in the interface regarding data class should throw DatabaseException.
Hope to help.
Ruilin
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tryed it no luck
Thanks AnyWay
Lisa
 
Marcela Blei
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa: I was trying to send you an e-mail but you haven�t got one in your profile because this isn�t so important for being in a post.
I am seing a lot of posts from you with java code, I recomend you to use the code tag "[code]" (see the UBB help at the left of you window when you are editing a message) it will be more readable.
Thanks
 
Glenn Opdycke-Hansen
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I, too, got stuck with rmi. I tried to fix the code based on some textbooks. However, the information may have been dated--there are changes in the latest jdks with respect to rmi.
I then decided to focus on the latest rmi tutorial from sun. After getting that to work, next I plan to make the appropriate changes in the assignment code.
Also, the posted code does not follow the coding standards. Class names should start with a upper case character and instances should start with a lower case character.

------------------
--glenn
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
Please check the file permission setting in your policy file.
I got everything work now.
In the code you should use:
1) myInstance11 = new dataConnectImpl("C:\scjd\starting\client\db.db");
In the policy file you should use "C:\\scjd\\starting\\client\\db.db";
Please try.
Ruilin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic