cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with passing my own exceptions from EJB webservices

former_member186148
Active Participant
0 Kudos

Hello SDN!

Here is a code:


	try{
		wdContext.currentMnRemoveTypeElement().setTypeId(typeId);
		wdContext.currentMnReqRemoveTypeElement().modelObject().execute();
		wdContext.currentMnRemoveTypeErrorPartElement();
		msgMgr.reportSuccess("Information deleted.");
	}catch(Exception ex){
		// print error message
	}

If I import web service as Web Service Model (DEPRECATED), model method execute() throws exception with type Exception, but if I'm using a Adaptive Web Service model, method execute() throws exception with type CMIException. This method connected with EJB method which throws DRException (it's my own type of exceptions extends Exception).

When I call this code an exception is occured, but type of ex is ClassCastException and error message is empty whereas I expect a DRException with my error message. I think that reason is failed to cast DRException toCMIException...

So how I can pass my own exception from EJB webservice to Adaptive Web Service model?

regards, Lev

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can throw the exception in the following way:

try{

// web-service method call

return "SUCCESS";

}catch(Exception ex){

return ex.getMessage();

// Or for cutomized mesg, instead of above line you can write:

return "YOUR MESSAGE";

// print error message

}

These changes you can do at the web-service end.

Hope this will solve your problem.

thanks & regards,

Manoj

Edited by: Manoj Kumar on Dec 31, 2007 10:39 AM

former_member186148
Active Participant
0 Kudos

Hello, Manoj!

Of course, your way will working but in my opinion there is wrong logic. I think that error (when occurs) and error descripton must be passed only from webservice method. Also I want to understand why webservice method throws so strange exceptions which cannot be casted to exceptions of my type. So I need that webservice method throws exceptions of my own type.

regards

Lev