cancel
Showing results for 
Search instead for 
Did you mean: 

java Runtime Exception?

Former Member
0 Kudos

Hi all,

I am doing a java mapping for some scenario.

I want to throw a exception for some validations of field.

But in my code i used throw new RuntimeException(Message) which is not throwing an exception in runtime.

Is there some other way to throw the exception in runtime

Any solutions for this problem....

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The problem is solved.

The exception is always thrown from the catch block of execute method.

Don't exit(n) anywhere in the code

Edited by: hlbabu123 on Aug 24, 2009 7:59 AM

Former Member
0 Kudos

Hi

I am facing a same problem.

Could you please elaborate what did you do to resolve it?

Thank you

Former Member
0 Kudos

hi,

U need to throw exception in catch block of the execute method

because the exception ur java code is going to throw will be always catched in this catch block.

Never use any exit(n) in the code.

I think i made clear with my sentences,if u cannot follow still ,u just put the code u r using for throwing the exception

So that others can help u with it.

Former Member
0 Kudos

just use throw new RuntimeException(Message) dont use try and catch block.then it works fine

Former Member
0 Kudos

Thanks for ur answer..........

but in java mapping even if i call the exception

throw new RuntimeException(Message).... it is nt throwing the error....

i tried with

try

{

throw new RuntimeException(Message);

}

catch(Exception e)

{

throw new StreamTransformationException(Message,e);

}

also still i could not see any exception at all....

0 Kudos

Hi,

try the following way..call your method in the try block and in the respective catch block, you catch the Stream Transoformation Exception.

Ex:

try

{

//call for your method

}

catch(StreamTransformationException ste)

{

throw new StreamTransformationException(Message,ste);

}

Regards

Venkat

0 Kudos

Hi,

the following blog will give you the clear idea about how to handle the Runtime Exception in Java Mapping

/people/prasannakrishna.mynam/blog/2009/07/21/handling-and-tracing-runtime-exceptions-in-java-mapping

Regards

Venkat

Former Member
0 Kudos

Hi ,

I followed that blog but i could not trace out...

I have a function which will be called when ever there is validation fail

from that method i need to raise the exception..

void validationCheck(String Message)

{

try

{

int i=0;

i=i/i;

}

catch(Exception e)

{

throw new StreamTransformationException(Message,e);

}

so that i can create an exception which will come to catch and will throw the StreamTransformationException.... but still it is not

throwing the exception......

}

Any guess..........

0 Kudos

Hi,

you have to use throw new RuntimeException(msg), in try block.

Ex:

void validationCheck(String Message)
{

try
{
int i=0;
i=i/i;
*throw new RuntimeException(Message);*
}
catch(Exception e)
{
throw new StreamTransformationException(Message,e);
}

You have to throw the Runtime Exception for the paticular Condition.

Regards

Venkat