Reputation: 587
I'm running Java 6 on Weblogic 11g.
I'm working on a Web Service projects that uses an EJB to communicate with a database. Currently I'm working on error-handling, and thus I tried undeploying the EJB before invoking the web service. My EJBClientHelper-class looks like this:
package mypackage.elkom.utils;
import java.io.Serializable;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import mypackage.elkom.ejb.beans.session.remote.ElkomRemote;
public class EJBClientHelper implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private ElkomRemote elkomRemote;
private static final String ELKOM_JNDI = "ElkomBean#mypackage.ejb.beans.session.remote.ElkomRemote";
private Context ctx;
private void prepareEjb3Connection() throws PropsFileException, NamingException {
// Here's code for getting the ejbProviderURL from propsfile //
props.put("java.naming.factory.initial", weblogic.jndi.WLInitialContextFactory");
props.put("java.naming.provider.url",ejbProviderURL);
ctx = new InitialContext(props);
}
public void setElkomRemote(ElkomRemote elkomRemote) {
this.elkomRemote = elkomRemote;
}
public ElkomRemote getElkomRemote() throws NamingException, PropsFileException {
prepareEjb3Connection();
if(elkomRemote == null) {
elkomRemote = (ElkomRemote)ctx.lookup(ELKOM_JNDI);
}
return elkomRemote;
}
}
But, when i use the getElkomRemote(); I get this message insted of NamingException:
SEVERE: The object identified by: '678' could not be found. Either it was has not been exported or it has been collected by the distributed garbage collector.;
nested exception is: java.rmi.NoSuchObjectException: The object identified by: '678' could not be found.
Either it was has not been exported or it has been collected by the distributed garbage collector.
javax.ejb.EJBException: The object identified by: '678' could not be found. Either it was has not been exported or it has been collected by the distributed garbage collector.;
nested exception is: java.rmi.NoSuchObjectException: The object identified by: '678' could not be found.
Either it was has not been exported or it has been collected by the distributed garbage collector.
java.rmi.NoSuchObjectException: The object identified by: '678' could not be found. Either it was has not been exported or it has been collected by the distributed garbage collector.
Anyone know why I get this message instead of NamingException? And perhaps how to fix it?
Upvotes: 0
Views: 3774
Reputation: 7197
There are three Exception categories:
Α system exception may occur due to a code bug or a misconfigured resource such as a misconfigured JNDI lookup. If an enterprise bean faces a system error it normally throws a javax.ejb.EJBException. The container wraps the EJBException in a RemoteException and finally the RemoteException is passed back to the client. That's what happened in your case and that's why you received a RemoteException.
The system exceptions cannot be handled from the client applications and should be thrown as unchecked exceptions.
For more detailed information you can see the following articles:
I hope this helps you.
Upvotes: 1