File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Weird RMI Error: Incompatible types for storing into array of arrays or objects... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Weird RMI Error: Incompatible types for storing into array of arrays or objects..." Watch "Weird RMI Error: Incompatible types for storing into array of arrays or objects..." New topic
Author

Weird RMI Error: Incompatible types for storing into array of arrays or objects...

TNguyen
Greenhorn

Joined: Apr 02, 2001
Posts: 6
Can someone please help me with an RMI error? I am currently stompted because I am getting the following RMI error when I try to start my DBServer with these commands:

D:\SUN\Certification\JavaDevelopersExam\Assignment>rmic suncertify.db.DataServicesImpl
D:\SUN\Certification\JavaDevelopersExam\Assignment>java suncertify.db.DBServer
Exception in thread "main" java.lang.VerifyError: (class: suncertify/db/DataServicesImpl, method: searchFlights signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[[Ljava/lang/String;) Incompatible types for storing into array of arrays or objects at suncertify.db.DBServer.main(DBServer.java:36)

I have a Remote interface with the following method:
public interface IDataServices extends Remote
{
...
public String[][] searchFlights(String userID,
String origAirport,
String destAirport)
throws RemoteException;
...
}

My DataServicesImpl remote object extends UnicastRemoteObject and implements the method in the Remote interface above. I bind this object in my DBServer code as follows:
public class DBServer
{
public static void main(String[] args) throws IOException, RemoteException
{
System.setSecurityManager( new RMISecurityManager() );
try
{
...
String URL = "rmi://" + serverDNSName + ":" + portNum + "/" + IDataServices.SERVERNAME;
IDataServices remoteObj = new DataServicesImpl();
Naming.rebind(URL, remoteObj);
...
}
catch (...) { ... }
}
}
Could someone please let me know what I am doing wrong here? Just for kicks, I tried changing the signature of my searchFlights() method to "public boolean searchFlights();" and successfully recompiled my code. But I got the exact same error when I re-ran my DBServer.
Thank you for all your help.
Timothy Nguyen

------------------
asad ali
Greenhorn

Joined: Dec 12, 2000
Posts: 20
Looks like you are returning an array of array from searchFlights method. Please show the code where you are creating and populating the array of array in the method. It will help identify the problem.
TNguyen
Greenhorn

Joined: Apr 02, 2001
Posts: 6
Hi Asad,
Thank you for your help as I am totally stompt and I cannot move on without fixing this. Here is the code for the searchFlights() method:
public class DataServicesImpl extends UnicastRemoteObject implements IDataServices
{
...
...
public String[][] searchFlights(String userID, String origAirport, String destAirport) throws RemoteException
{
String[][] retRecords = null;
...
//Do the search.
DataInfo[] searchResults = myDataSource.criteriaFind( searchCriteria );

//Put the search results in the retRecords array.
int recsFound = 0;
for (int i=0;i<searchResults.length;i++)>
{
if ( searchResults[i] != null )
{
retRecords[recsFound] = searchResults[i].getValues();
recsFound++;
}
}
...
return retRecords;
}
...
...
}

public class DataInfo implements Serializable
{
private String [] values;
...
...
public String [] getValues()
{
return values;
}
...
...
}
Thanks.
Timothy Nguyen
asad ali
Greenhorn

Joined: Dec 12, 2000
Posts: 20
You are declaring two dimensional array of String which is referenced by retRecords. However, you are not defining the size of the array.
Your code is failing at the following statement :
retRecords[recsFound] = searchResults[i].getValues();
searchResults[i].getValues() returns an array of Strings but the size of your two dimensional array is not defined.
Hence you need to define the size like :
retRecords = new String[searchResults.length][searchResults[0].length];
before the 'for' loop.
TNguyen
Greenhorn

Joined: Apr 02, 2001
Posts: 6
Hi Asad,
Awesome, that fixed it. Completely a Java fundamental problem and nothing relating to RMI. However, pretty weird that RMI choked on it.
Thanks alot.
Timothy Nguyen
 
 
subject: Weird RMI Error: Incompatible types for storing into array of arrays or objects...
 
Threads others viewed
Using a TravelAgency and a Flight class to implement business logic
UrlyBird RMI Interface
Problem at run time see code??????
Remote interface
VerifyError - Incompatible Types
jQuery in Action, 2nd edition