Wharf error handling issue
I am facing some problems while installing an error handler in jetty:
I am creating my own error handler:
public class ServerErrorPageErrorHandler extends ErrorPageErrorHandler {
@Override
protected void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks)
throws IOException {
String uri= request.getRequestURI();
writeErrorPageMessage(request,writer,code,message,uri);
if (showStacks)
writeErrorPageStacks(request,writer);
writer.write("<hr><i><small>Powered by OWN-SERVER://</small></i><hr/>\n");
}
}
And install it in the 'jett-web.xml' file which is located in the '/ webapp / WEB-INF /' folder
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="errorHandler">
<New class="com.mobile.service.handlers.ServerErrorPageErrorHandler"/>
</Set></Configure>
When Jetty started, it didn't say such a method for the setErrorHandler for the WebAppContext class, (I found the setErrorHandler method in its parent ErrorHandler class, so I think that means)
Then create an error-handler-context.xml file and fill in the file:
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/</Set>
<Set name="errorHandler">
<New class="com.mobile.service.handlers.ServerErrorPageErrorHandler"/>
</Set>
</Configure>
The jetty then starts successfully, but the error handler has no effect.
I just want to change the messages that appear on the "Power by jetty" error pages to "Power by OWN SERVER".
And I don't want to create a new error page.
So how do you implement this?
And I change the config file like this:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Call name="setErrorHandler">
<Arg>
<New class="com.hp.mobile.service.handlers.ServerErrorPageErrorHandler"/>
</Arg>
</Call>
</Configure>
After launching the pier, it still says NoSuchMethod 'setErrorHanlder' exception,
And I am debugging it and I get an exception:
"java.lang.illegalargumentexception: argument type mismatch" in method.invoke (obj, arg) in "TypeUtil.java"
SetErrorHandler argument is a class ErrorHandler
,
And in my case it comes from ErrorHandler
,
So why is this happening?
By the way: I also change the class ServerErrorPageErrorHandler
to extend from ErrorHandler
, it doesn't work either.
source to share
No one has answered this question yet
Check out similar questions: