Estou com um problema com RMI! Minha aplicação servidora está funcionando corretamente. Com o código abaixo ele apresenta erro. Já tentei de tudo e não consegui descobrir onde é:
[code]package clientermi;
/**
*
-
@author instalador
*/
import java.awt.BorderLayout;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.swingBean.actions.ApplicationAction;
import org.swingBean.descriptor.GenericFieldDescriptor;
import org.swingBean.descriptor.XMLDescriptorFactory;
import org.swingBean.gui.JActButton;
import org.swingBean.gui.JBeanPanel;
public class FuncionarioForm {
private MyInteface remoteService;
private String remoteString;
/*public FuncionarioForm() throws RemoteException, SQLException {
try {
remoteService = (MyInteface) Naming.lookup("rmi://127.0.0.1/Financeiro");
remoteString = remoteService.getMensagem();
System.out.println(remoteString);
} catch (Exception e) {
throw new RuntimeException(e);
}
}*/
public void init() throws RemoteException, SQLException {
try {
remoteService = (MyInteface) Naming.lookup("rmi://127.0.0.1/Financeiro");
remoteString = remoteService.getMensagem();
System.out.println(remoteString);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void Executa(){
// Cria componente de formulário
GenericFieldDescriptor descriptor = XMLDescriptorFactory
.getFieldDescriptor(Funcionario.class, "clientermi\funcionarioForm.xml", "FuncionarioForm");
final JBeanPanel<Funcionario> panel = new JBeanPanel<Funcionario>(
Funcionario.class, descriptor);
JActButton botaoExibir = new JActButton("Cadastrar",
new ApplicationAction() {
public void execute() {
Funcionario func = new Funcionario();
panel.populateBean(func);
StringBuilder builder = new StringBuilder();
builder.append("Nome: " + func.getNome() + "\n");
builder.append("Cpf: " + func.getCpf() + "\n");
builder.append("Empresa: " + func.getEmpresa() + "\n");
builder.append("Cargo: " + func.getCargo() + "\n");
builder.append("Renda Bruta: " + func.getRendaBruta() + "\n");
builder.append("Renda LÃquida: " + func.getRendaLiquida() + "\n");
builder.append("Margem Consignável: " + func.getMargemConsignavel() + "\n");
try {
//JOptionPane.showMessageDialog(panel, );
// func = remoteService.getAddFunc(func);
func = remoteService.getAddFunc(func);
} catch (RemoteException ex) {
Logger.getLogger(FuncionarioForm.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(FuncionarioForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
JPanel panelButton = new JPanel();
panelButton.add(botaoExibir);
// Cria Frame para exibição da tela
JFrame frame = new JFrame("Formulário de Cadastro de Funcionário");
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.NORTH);
frame.getContentPane().add(panelButton, BorderLayout.SOUTH);
frame.setVisible(true);
}
public static void main(String[] args) throws RemoteException, SQLException {
FuncionarioForm f = new FuncionarioForm();
f.Executa();
}
}
[/code]
Segue o erro:
run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at clientermi.FuncionarioForm$1.execute(FuncionarioForm.java:78)
at org.swingBean.actions.ApplicationAction.executeActionChain(ApplicationAction.java:10)
at org.swingBean.gui.JActButton.actionPerformed(JActButton.java:21)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)