NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
edwin
Joined: 17 Jan 2011 Posts: 7
|
Posted: Sat Jan 29, 2011 7:18 am Post subject: java.lang.NullPointerException when calling EJB from desktop client |
|
|
Hi,
I get a strange error that I can't resolve. Maybe someone can point me in the right direction.
I have the following:
1) Jframe that lists a table of countries
2) On double-click of a row a country for should be displayed
The list of countries get displayed but when I double-click the row it fails on calling the session bean method findCountry(id) with the following error message: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.
However if I move the same call to findCountry up to the country list the call works fine and this is what puzzles me.
The CountryForm class code is below.
| Code: |
package windows;
import ejb.MySessionRemote;
import entities.Country;
import javax.ejb.EJB;
/**
*
* @author edwin
*/
public class CountryForm extends javax.swing.JDialog {
@EJB
private static MySessionRemote mySession;
/** Creates new form CountryForm */
public CountryForm(java.awt.Frame parent, boolean modal, Long id) {
super(parent, modal);
initComponents();
if (id != 0) {
System.out.println(id);
Country country = mySession.findCountry(1);
fId.setText(country.getId().toString());
fCode.setText(country.getCode());
fName.setText(country.getDescription());
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
CountryForm dialog = new CountryForm(new javax.swing.JFrame(), true, null);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton bSave;
private javax.swing.JTextField fCode;
private javax.swing.JLabel fId;
private javax.swing.JTextField fName;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
// End of variables declaration
}
|
Does anyone have an idea why I would get this error on the call to mySession.findCountry(1)? The ejb injection should work find as it is done in the exact same way as in the CountryList class but still it seems that mySession is not available. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|