Page History
...
You can customize the above error message by following the instructions given below.
Create a directory named
resources
inside the<PROJECT_HOME>/src/main/
directory, and then create another directory namedweb
inside it.Tip <PROJECT_HOME>
denotes the top-level directory of your Maven project.Create a new HTML error page (e.g.
new_
error_404.html
file) as shown below. This contains the customized error page.Code Block language xml <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>404 - Error not found</title> </head> <body> <h1>Sorry, this resource is not found.</h1> </body> </html>
- Add the
new_
error_404.html
file inside the<PROJECT_HOME>/src/main/web
directory. Add the following property below the
<version>
element in the<PROJECT_HOME>/pom.
xml file:<packaging>bundle</packaging>
Add the following configurations inside the
<plugins>
element in the<PROJECT_HOME>/pom.
xml file.Code Block language xml <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Name>${project.artifactId}</Bundle-Name> <Import-Package> org.osgi.framework, org.osgi.service.http, org.wso2.carbon.ui, javax.servlet.*;version="2.4.0", *;resolution:=optional </Import-Package> <Fragment-Host>org.wso2.carbon.ui</Fragment-Host> <Carbon-Component>UIBundle</Carbon-Component> </instructions> </configuration> </plugin>
Add the following configurations inside the
<dependencies>
element in the<PROJECT_HOME>/pom.
xml file:Code Block language xml <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework</artifactId> <version>1.0.3</version> </dependency>
Build the Maven project by executing the following command: mvn
clean install
- Once the project is built, copy the JAR file (from the
<PROJECT_HOME>/target/
directory) to the<CARBON_HOME>/repository/components/dropins/
directory. Change the following configurations in the
<CARBON_HOME>/repository/conf/tomcat/carbon/WEB-INF/web.xml
file.Code Block language text <error-page> <error-code>404</error-code> <location>/carbon/new_error_404.html</location> </error-page>
Tip You need to replicate this configuration, and change the values of the
<error-code>
and<location>
elements accordingly for each new HTML error page you add.- Restart the WSO2 Carbon server.
Access the following URL again, to test the error page you customized: https://10.100.5.72:9443/abc.
You will view the new error page with the following content: "Sorry, this resource is not found.
"