aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Illegal state Exception :Can't overwrite cause Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Illegal state Exception :Can Watch "Illegal state Exception :Can New topic
Author

Illegal state Exception :Can't overwrite cause

Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
HI
Sorry for this lengthy post

I am using EJB 2.1 ,Struts and GlassFish Application server.

When i submit the form i am getting an exception

java.lang.IllegalStateException: Can't overwrite cause
at java.lang.Throwable.initCause(Throwable.java:320)
at com.sun.corba.ee.impl.presentation.rmi.ExceptionHandlerImpl.readException(ExceptionHandlerImpl.java:288)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readException(DynamicMethodMarshallerImpl.java:487)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:197)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
at com.HEMS.ejb._RegisterUserComponent_DynamicStub.registerUser(com/HEMS/ejb/_RegisterUserComponent_DynamicStub.java)
at com.HEMS.actions.RegisterUserAction.execute(RegisterUserAction.java:57)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)


My Stateless Session bean code has the following method which call the utility method that talks to DB:

public void registerUser(RegisterUserBean registerUserBean)throws HEMSException,Exception{
HEMSLogger.logDebug(RegisterUserEJB.class.getName(), "Calling registerUser()");
RegisterUserDBHelper.registerUser(registerUserBean);
}

Component Interface for this bean is :

public interface RegisterUserComponent extends EJBObject{

public ArrayList<StateListBean> getStateList() throws RemoteException;

public void registerUser(RegisterUserBean registerUserBean) throws RemoteException,HEMSException,Exception;
}

The Utility method that calls the DB is :

public static void registerUser(RegisterUserBean registerUserBean) throws HEMSException,Exception {
Connection con = null;
CallableStatement st = null;
String errMsg = null;
try {
con = HEMSDBHandler.getInstance().getConnection();
String sql = "{call PKG_USER.SP_REGISTER_USER(?,?)}";
st = con.prepareCall(sql);
st.setObject(1, registerUserBean);
st.registerOutParameter(2, Types.VARCHAR);
st.execute();
errMsg = st.getString(2);
if (errMsg != null) {
throw new HEMSException(errMsg);
}
} finally {
st.close();
if (con != null) {
con.close();
}
}
}
Part of my My Action class method is :

RegisterUserForm registerUserForm = (RegisterUserForm) form;
action = registerUserForm.getAction();
if (action != null && action.equals(HEMSConstants.REGISTER)) {
if (isTokenValid(request, true)) {
RegisterUserBean registerUserBean = new RegisterUserBean();
PropertyUtils.copyProperties(registerUserBean, form);
Context ct = new InitialContext();
Object obj = PortableRemoteObject.narrow(ct.lookup("RegisterUserEJB"), RegisterUserHome.class);
ct.close();
try {
RegisterUserHome home = (RegisterUserHome) obj;
RegisterUserComponent component = home.create();
component.registerUser(registerUserBean);
} catch (HEMSException hemsExp) {
HEMSLogger.logError(RegisterUserAction.class, HEMSException.getErrMsg(), hemsExp);
forward = "failure";
ActionErrors errors = new ActionErrors();
errors.add("saveError", new ActionMessage(HEMSException.getErrMsg()));
addErrors(request, errors);
}catch(Exception e){

}
resetToken(request);
setHeaders(response);
forward = "success";
It works fine If i catch the exception and did not rethrow it in the utility method .But if i rethrow the exception i am getting the above error.Please help



SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Why no one is replying for this message?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Illegal state Exception :Can't overwrite cause