I am calling EJB3 service deployed in my jBoss 4.2.3 server from a standalone Java program (using jnp lookup). I have made all my data object Serialized. I have successfully called methods of my EJB but I am losing data from object on client side. I debuged the EJB side within an Application Server and I can see I have data in my objects.
I am calling my EJB using following code;
public void doStuff () {
// Component and its JNDI
ResourceProviderServiceBeanRemote componentEJB;
String JNDI_NAME_REMOTE = "ResourceProviderService/ResourceProviderServiceBean/remote";
// Setup Environment
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099"); // remote machine IP
Context context = null;
try {
context = new InitialContext(environment);
Object factoryObj = context.lookup(JNDI_NAME_REMOTE); //ejb-name
componentEJB = (ResourceProviderServiceBeanRemote) factoryObj;
UserContextCallBack userContext = new UserContextCallBackImpl(new UserDetails("username", "password", ""));
componentEJB.setUserContextCallBack(userContext);
QueryDetails query = new QueryDetails();
query.setName("anything");
List<String> cols = new ArrayList<String>();
List<Row> rows = new ArrayList<Row>();
ResponseDetails responseDetails = new ResponseDetails();
componentEJB.doQuery(query, cols, rows, responseDetails);
System.out.println(responseDetails);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Note: I can see data populated in ‘cols’, ‘rows’ and ‘responseDetails’ on server side but client side remain the same empty initialise objects.
Am I missing anything?
—
SJunejo
It was a silly mistake, I found out that all the objects are passed by value when calling a methods on any RMI interface. I have to have some Return Type and that’s what it is missing. So I am upting my code as follows;
Hope this will help some one (silly) like me 🙂