Basically, the code I have is here below. Take into account that this is a "test" state of the code. The original problematic was a call on init() to a different class that threw a checked exception. This throw was catched by a try/catch block, then the application failed when trying to create the exception. All that has been removed for clarity's sake, as the problem was in the "MyCustomRuntimeException" creation.
@Component
public class ClassName {
public ClassName() {
//minor, non problematic operations.
}
@PostConstruct
public void init() {
throw new MyCustomRuntimeException("AAAAAAAH");
}
}
MyCustomRuntimeException is defined like this:
public class MyCustomRuntimeException extends RuntimeException {
public MyCustomRuntimeException (String message) {
super(message);
}
}
And, I'm getting an "UnsatisfiedDependencyException" when creating a class that uses this class. The console points towards the line where the new MyCustomRuntimeException is being thrown, and I don't really get what's going on.
Also, "MyCustomRuntimeException" started as a regular exception, but I saw that I should throw a RunTimeException instead because the @PostConstruct forbids checked exceptions to be thrown. And I've also tried to throw a standard RunTimeException with no luck.
So, I'm clueless here. Any ideas on why I can't throw this exception?