I am facing the problem while bug fixing. I am trying to provide a handler page for 500 server errors. Sometimes it is throwing 500 server error and sometimes it is not. Can anyone please help to replicate the 500 server error in hybris project.
It is an internal server error. You have to check the backend logs for more information. Possible exceptions and stacktraces. It can be anything. If you want to change the 500 error page, you can find configuration about it in your *storefront extension web.xml file. Here is an example:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/errorPages/serverError.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/errorPages/serverError.jsp</location>
</error-page>
You can replicate so many ways
1)Place a null pointer expection in controller
2)Inproper close of JSP tags
Related
I want unhandled exceptions to be printed to console so that I can just click on exception to go to the line causing exception.
But they are printed to the browser and I couldn't find any setting for that.
I am using JSF 2.2 with myfaces implementation and tomcat as container.
You can use a special page for exceptions instead of showing exceptions. The exception trace will still be written into the log but it will not be displayed to users.
web.xml
<error-page>
<error-code>404</error-code>
<location>/errorpages/404.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.ejb.EJBException</exception-type> // Your exception type
<location>/errorpages/404.xhtml</location>
</error-page>
My application is on Apache MyFaces V2.0. Application Server is WebSphere V8.0. During security testing using URL like below, application is rendering the error in the browser exposing application server details. I have below entries in web.xml. Please suggest a solution to gracefully handle this scenario.
Web.xml
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/error.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/error500.xhtml</location>
</error-page>
URL
localhost/app/test.xhtml?emailId=test1#abcd.com&clickSubmit=Save&javax.faces.ViewState=83eNclk%2FbIe05NjdSUOQtQqlm5FVhzOBEHXMRHzqXhuC7fG%2BpJS9xRI%2BxN9tCjZIPg2dA3%2B8Xdor%2Bj40Wjiy%2FxO3J%2Bu0lbQJFHXnGNxYwUUh102oPNugRXQAmHNJsjYDnxwh9w%3D%3D
Error:
Error Page Exception
SRVE0260E: The server cannot use the error page specified for your
application to handle the Original Exception printed below.
Original Exception:
Error Message: javax.servlet.ServletException: /app/test.xhtml No saved
view state could be found for the view identifier: /app/test.xhtml
Error Code: 500 Target Servlet: Faces Servlet Error Stack:
javax.faces.application.ViewExpiredException
org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.
I am planning to use Cometd library in my application that runs on JBoss AS 6. Therefore I downloaded cometd 2.4.0 and tried to deploy example war (from cometd-demo/target) to my AS. I was aware that this was not possible without modifications, so I did the changes in web.xml:
Changed to servlet 3.0 in web-app tag (it is originally 2.5). Used complete tag from CometD faq answer. Also uncommented continuation filter that was already in web.xml, based on this description
Based on faq answer, added async-supported tag. However, this causes problems: if I just uncomment it, web.xml can't be parsed. I found out that this is due to order of tags in XML, so moved async-supported tag down the order, just after load-on-startup tag. However, Jboss still throws exceptions:
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.IllegalStateException: The servlet or filters that are being
used by this request do not support async operation
ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cometd-demo-2.4.0].[cometd]]
Servlet.service() for servlet cometd threw exception:
java.lang.ClassNotFoundException:
org.eclipse.jetty.server.AbstractHttpConnection from
BaseClassLoader#12a54b
Complete web.xml file that I use is here.
Example runs no my Jboss despite all errors reported, but by watching firebug, I can see that it does quick pooling instead of long pool. It seems that server thinks that browser has multiple connections open, which is not the case (see JSON below):
[{"id":"137","successful":true,"advice":{"interval":2000,"reconnect":"retry","multiple-clients":true,"timeout":20000},"channel":"/meta/connect"}]
Did anyone managed to make examples work with JBoss as6 and how? What I did wrong here?
remove:
<!-- Portability Filter, needed only to run on non Jetty or non Servlet-3.0 containers -->
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
from web.xml
I have the same setup and the same problem even if I remove continuation filter from web.xml.
I've found a thread on cometd-users group complaining about multiple-client issue on Tomcat 7 and the cause seems to be a Tomcat bug around Content-Type that is not set to "application/json".
However I've inspected packets and on JBossAS6 the content-type is correctly set on server responses.
UPDATE
I've give a try using Jetty 7 and the problem disappeared. The "multiple-clients" issue affects Tomcat as well as JBoss6 AS
In my PrimeFaces project, I need to provide some general error pages for general response error status codes such as 401 and 404. Does somebody know how can I figure this out?
It's not handled by JSF, it's handled by the servlet container. You can specify them by <error-page> in web.xml.
<error-page>
<error-code>401</error-code>
<location>/errors/401.xhtml</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/errors/404.xhtml</location>
</error-page>
If you'd like to navigate to them from inside JSF action methods, then you can use ExternalContext#responseSendError() for this.
externalContext.responseSendError(401, "You are not authorized.");
We have a J2EE app running beautifully on tomcat-based app servers, but all groovy scripts seem to fail on weblogic (10.3.5.0) and also IBM WebSphere. It seems the script processing, not the content of the scripts are the issue. The app itsells is a spring MVC web app and the GroovyServlet is part of the web.xml descriptor:
<!-- Servlets -->
<servlet>
<servlet-name>Groovlet</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Groovlet</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>
Calling a simple executor.groovy file results in an exception. My test script is small:
response.contentType = "application/json"
out.println "test"
But fails:
GroovyServlet Error: script: '/executor.groovy': Script processing failed.null
java.lang.NullPointerException
Anyone has a solution? Are there general issues with Groovy on weblogic or websphere?
Don't know if you're still having this issue :)
I had the same problem - the NullPointerException is caused by ServletContext.getRealPath(...) returning null.
There is a setting in Weblogic admin console which controls whether getRealPath() can be used.
It can also be configured in your weblogic.xml file by inserting the following (not sure how to deal with this in Websphere).
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
Sounds like response or out are not properly binded in weblogic. Did you try your servlet on another container. Also publishing more about the stacktrace and the web.xml could help