IllegalStateException: Cannot obtain inMethodFlag for: getPrimaryKey - java

Can anyone tell me why following exception comes?
java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.IllegalStateException: Cannot obtain inMethodFlag for: getPrimaryKey
How to avoid it?

According to the AllowedOperationsFlags API it will be thrown when the getPrimaryKey() has been called at a wrong time, e.g. during ejbCreate(). It's hard to suggest a solution without more context about your particular problem and/or a SSCCE.

Related

Facing exception org.springframework.oxm.UncategorizedMappingException:

Actually, I am facing below exception
ERROR : XML Read or Write is not done properly.
org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: my_ClassName nor any of its super class is known to this context.
While making request that is throwing exception XMLMappingException. There is no code change in existing I just added new wsdl(converted to jar in proper place)but facing issue.
If anyone knows answer this question.
I tried the stack overflow solutions regarding this issue, solutions are not matching to my problem statement.

Java only get Exception name without StackTrace

how can I get the exception name without getting the stack trace?
I am using exception.toString() to convert the thrown exception into a string, but I only want the exception name likeNullPointerException and not the entire stack trace.
How can I solve this?
exception.getClass().getSimpleName();
Class#getSimpleName()
NOTE: this will not work in case if your exception is an anonymous class (although I have personally never seen an anonymous exception in any production code)

playframework : NullpointerException when startup

I'm using Play 1.2.7, somehow I found my project become weird, when I start the application, and visit any valid URL, it shows an NullPointerException:
Oops: NullPointerException
An unexpected error occured caused by exception NullPointerException: null
play.exceptions.UnexpectedException: Unexpected Error
at play.Play.start(Play.java:563)
at play.Play.detectChanges(Play.java:637)
at play.Invoker$Invocation.init(Invoker.java:198)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:266)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:478)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:426)
at play.Play.start(Play.java:523)
... 3 more
And then I try to refresh the page, 2 or 3 time later, it become normal. What's going on here?
play doesn't support the following format in one class
public class A{
------
}
class B{
--
}
so make two different class instead of putting both in single class or use nested class.
It is a known bug: http://play.lighthouseapp.com/projects/57987/tickets/1379-unexpectedexception .
Maybe you use nested classes and Play has problems with it.

Throwing custom exception from Jackson Serializer in Java

I was wondering if anyone could help - I am writing a custom Json serializer, extending from JsonSerializer, and I want to wrap any exceptions that could be thrown in my own custom exception, extended from IOException. However, whenever I run any unit tests (using junit) to confirm that the exception is thrown it is failing, saying that -
Expected: (exception with message a string containing "Unable to serialize!" and an instance of com.cybersource.profile.serializer.MySerializerException)
got: <com.fasterxml.jackson.databind.JsonMappingException: Unexpected IOException (of type com.cybersource.profile.serializer.MySerializerException): Unable to serialize!>
Any idea how to get around this, or is it not possible to throw a custom exception?
Got it sorted - turns out for a custom exception you shouldn't extend from IOException, but JsonProcessingException!

How to find cause of exception if type is Throwable

Give this method here:
public SomeClass(Throwable stackTrace) {
super();
this.stackTrace = stackTrace;
}
How can I find out what class type stacktrace originally was before being passed in?
stacktrace.getClass().getName()
or
stacktrace instanceof CLASS_YOU_WANT_TO_TRY
You make this determination by handling exceptions as explicitly as possible. That includes not ever, EVER, catching Throwable and handling exceptions as near to the code that threw it as possible. I'm not sure what you're trying to do by constructing a POJO with a Throwable but it's probably not a path that will lead you to much enlightenment.

Categories

Resources