Solved

Java RMI Exception Problem

Posted on 2009-04-09
9
465 Views
Last Modified: 2013-12-14
I have a GUI which needs to pass variables to a class. If I try to make an instance of that class 'Asb asb = new Asb();'
 I get the error saying "unreported exception java.rmi.RemoteException; must be caught or declared to be thrown".
public class Asb extends UnicastRemoteObject implements Publisher,

		 Serializable
 

{
 

public Asb() throws RemoteException

     

   {

        

super();

            

     }
 

}

Open in new window

0
Comment
Question by:namsu55
9 Comments
 
LVL 13

Expert Comment

by:MicheleMarcon
ID: 24113663
As you have declared, the Asb() constructor throws RemoteException.

You need to do this:

try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
}
0
 

Author Comment

by:namsu55
ID: 24113805
Yeah that works, can you give me an example of system.out.println, where if connection is not made or not present (rmiregistry not turned on) throws an exception. From within the ABS class.
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24113821
throw(e);
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24113837
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:namsu55
ID: 24113842
try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
}
throw(e);

That doesnt work it says incompatible types.
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24113845
Actually you can declare the class throws exception:
See this example is very close to your question:
http://www.experts-exchange.com/Programming/Languages/Java/Q_20985361.html
0
 
LVL 12

Accepted Solution

by:
basav_com earned 250 total points
ID: 24113874
try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
throw(e);    ---->  You messed up the brackets
}
0
 

Author Comment

by:namsu55
ID: 24113897
It now says what it said before : "unreported exception java.rmi.RemoteException; must be caught or declared to be thrown".
0
 
LVL 17

Assisted Solution

by:Thomas4019
Thomas4019 earned 250 total points
ID: 24117024
I just use e.printStackTrace(); This causes it to print the Exception to the Console window.
try{

Asb asb = new Asb();

//your code here

}catch (RemoteException e){

e.printStackTrace();

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 39
Checkbox and ListView in Android Layout 4 56
rhino JavaScript import, load 25 67
MySQL  on Tomcat 8 30
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This video teaches viewers about errors in exception handling.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now