I have the following in my build.gradle:
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent
implementation('org.springframework.boot:spring-boot-starter-parent:3.0.2')
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
implementation("org.springframework.boot:spring-boot-starter:3.0.2")
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-webflux
implementation("org.springframework.boot:spring-boot-starter-webflux:3.0.2")
But I get the following exception on startup.
Factory method 'tomcatReactiveWebServerFactory' threw exception with message: jakarta/servlet/Servlet
What dependency am i missing?
It looks like commenting out the following additional dependency is removing the above error:
implementation('org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2')
Related
I have JAX-RS application that works just fine on Liberty 19.0.0.10. The issue I am having appears to be a bug in Liberty runtime where it'd throw URISyntaxException exception if #PathParam has backslashes. The issue was discovered during security code scans.
I tried to absorb this issue with using pre-matching ContainerRequestFilter but I see the same exception even it's presumably processed before matching any resource.
I tried to use custom exception handler but still see the same error.
Trying to catch the exception inside getinfo function obviously does not work since the error happens before going into the function itself.
Using #Encoded annotation does not make any difference obviously.
[ERROR ] SRVE0777E: Exception thrown by application class 'java.net.URI.create:863'
java.lang.IllegalArgumentException: Illegal character in path at index 80: https://hotsauce/somepath/uuid/a=\dg=bc
at java.net.URI.create(URI.java:863)
at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.getBaseURL(AbstractJaxRsWebEndpoint.java:245)
at [internal classes]
Caused by: java.net.URISyntaxException: Illegal character in path at index 80: https://hotsauce/somepath/uuid/a=\dg=bc
at java.net.URI$Parser.fail(URI.java:2859)
at java.net.URI$Parser.checkChars(URI.java:3032)
at java.net.URI$Parser.parseHierarchical(URI.java:3116)
at java.net.URI$Parser.parse(URI.java:3064)
at java.net.URI.<init>(URI.java:599)
at java.net.URI.create(URI.java:861)
... 2 more
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: java.lang.IllegalArgumentException: Illegal character in path at index 80: https://hotsauce/somepath/uuid/a=\dg=bc
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5051)
at [internal classes]
Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 80: https://hotsauce/somepath/uuid/a=\dg=bc
at java.net.URI.create(URI.java:863)
at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.getBaseURL(AbstractJaxRsWebEndpoint.java:245)
... 1 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 80: https://hotsauce/somepath/uuid/a=\dg=bc
at java.net.URI$Parser.fail(URI.java:2859)
at java.net.URI$Parser.checkChars(URI.java:3032)
at java.net.URI$Parser.parseHierarchical(URI.java:3116)
at java.net.URI$Parser.parse(URI.java:3064)
at java.net.URI.<init>(URI.java:599)
at java.net.URI.create(URI.java:861)
... 2 more
This is a sample of the code
#Path("/somepath")
public class MyClass {
#GET
#Path("/uuid/{UUID}")
#Produces(MediaType.APPLICATION_JSON)
public Response getInfo(#PathParam("UUID") String uuid) {
try {
// request processing goes here
} catch (Exception e){
// URISyntaxException can't be handled here.
}
}
}
That stack occurs in 19.0.0.10, but should be fixed in more recent versions - the fix was made in the 19.0.0.11-12 timeframe, so if you can upgrade to a version of 20.0.0.1 or above, that should resolve this issue.
I am using serilog with asp net core 3
It is setup and logging exceptions automatically - so i have no error handling to log the errors.
I was attempting to add extra context properties to logged items, and have added middleware to log these.
LogContext.PushProperty("Email", email);
LogContext.PushProperty("Url", url);
These are added if i manually log myself but any logs added automatically when an error occurs does not have these items added.
Any ideas?
NOTE: i have read this...
https://blog.datalust.co/smart-logging-middleware-for-asp-net-core/
This is the closest i have found to working around the issue, but this catches the exception and manually logs it, which is a shame if this is the only way it can be done.
At first, LogContext is a stack; properties that are pushed onto the stack must be popped back off by disposing the object returned from PushProperty():
using (LogContext.PushProperty("Email", email))
using (LogContext.PushProperty("Url", url)){
// middleware code
...
}
Otherwise, the behavior may be non-deterministic.
but any logs added automatically when an error occurs does not have these items added
I assume that error logging occurs outside of the scope, where these properties don't exist. In this case, try ThrowContextEnricher to enrich the exception log with properties from the original context where the exception was thrown.
// call it once on app startup
ThrowContextEnricher.EnsureInitialized();
...
// then each throwing will capture context,
// so you can enrich log in exception handler:
catch (Exception ex)
{
using (LogContext.Push(new ThrowContextEnricher()))
{
Log.Error(ex, "Exception!");
}
}
Or simply register ThrowContextEnricher globally at LoggerConfiguration (in this case ThrowContextEnricher.EnsureInitialized() is not required). So every exception log will be enriched:
Log.Logger = new LoggerConfiguration()
.Enrich.With<ThrowContextEnricher>()
.Enrich.FromLogContext()
...
.CreateLogger();
Disclaimer: I am the author of that library, and I also left an example in this answer.
I have a global ErrorHanlder (Derive from HandleErrorAttribute) that works fine and catches all errors that occur. But I have a situation in which, home controller can throw exception. I inspected and saw that error thrown from controller is not handled in my custom ErrorHandler and asp.net gives this:
Exception of type 'Exception' was thrown.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Would you help me please ?
Code:
public HomeController()
{
_ServiceAsync = new ServiceAsyncProvider();
}
class ServiceAsyncProvider
{
public ServiceAsyncProvider()
{
throw new Exception();
}
}
While your code snippet is a little unclear on this point, it looks like your _ServiceAsync is being initialized in your controller's constructor. Exceptions thrown during controller construction are not handled by the HandleError filter.
See this related question for more information: Handling Exceptions that happen in a asp.net MVC Controller Constructor
You are throwing an exception in the constructor. These exceptions are not handled by the filter.
I'm trying to get more information for when google.script.run fails. I know that I can get a basic error handling callback function to give me the error message with something like this:
google.script.run.withFailureHandler(handleError).getMe();
Where handleError gets an argument passed in for the error message.
function handleError(error) {
console.log(error);
}
However, if I wanted to created a custom error handler that provided the location of where the exception was being thrown, I could use a custom function on withFailureHandler, like this:
google.script.run.withFailureHandler(function () {
showError(error, 'getMe');
}).getMe();
With this method I'm stumped with one issue. How do I capture the error message to pass to my showError() error handler?
Simply add the error parameter to your anonymous function.
google.script.run.withFailureHandler(function (error) {
showError(error, 'getMe');
}).getMe();
An errorHandler receives the error event from an exception that's thrown on the server. To pass a custom message, have your server side code do something like this:
...
if (errDetected) {
throw new error("Custom message")
}
...
I have created a new SplitPage inside VS2012 and I load this page with:
this.Frame.Navigate(typeof(SplitPage), "AllGroups");
An error is throw from :
this.InitializeComponent();
Visual Studio show me this exception :
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred
in IC2.exe but was not handled in user code
WinRT information: Cannot find a Resource with the Name/Key SubtitleTextStyle
[Line: 88 Position: 104]
If I catch the error I found the message :
Unspecified error
How can I avoid this error ?
I think the problem lies in the xaml where you don't have the style in the resources that is being call "SubtitleTextStyle". You may want to check on that or remove that line away in your xaml.