Skip to Content

Problem with passing my own exceptions from EJB webservices

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 31, 2007 at 05:04 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.