the method in the stateless session bean:
public Iterator findByName(String firstName, String lastName) { return manager.createQuery("from Customer c where c.person.firstName = :firstName and c.person.lastName = :lastName") .setParameter("firstName", firstName) .setParameter("lastName", lastName) .getResultList() .iterator(); }
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException at $Proxy0.findByName(Unknown Source) at de.lechner.test.client.Client.main(Client.java:38) Caused by: java.rmi.ConnectException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is: java.io.EOFException at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:266) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:117) at org.jboss.remoting.Client.invoke(Client.java:201) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:39) .. .. ..
public class Client { public static void main(String[] args) throws Exception { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } InitialContext ctx = new InitialContext(); CustomerDAORemote customerDAO = (CustomerDAORemote) ctx.lookup(CustomerDAORemote.class.getName()); Customer cust = customerDAO.create(); cust.getPerson().setFirstName("test"); cust.getPerson().setLastName("jboss"); cust.getLoginData().setLogin("blah"); customerDAO.persist(cust); Iterator it = customerDAO.findByName("test","jboss"); // LINE 38: the error while (it.hasNext()) { cust = (Customer) it.next(); System.out.println(cust.getId()+ " "+cust.getPerson().getFirstName()+ " "+cust.getPerson().getLastName()+ " "+cust.getLoginData().getLogin()); } } }
ah - an iterator is not serializable .. java basics missing *g*