After adding the context file i get this error : Statut 404 ..
my web file :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>CRUDWebAppMavenized</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
structure
I don't know where is exactly the problem ! the 'student.jsp' page there is inside the wepapp folder.
Add this to your web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
You are probably missing the ContextLoadListener, which picks up your Spring configuration files. If this doesn't solve your issue, edit your question to include the contents of your web.xml file.
Related
I got the following error while deploying war file in weblogic
Message icon - Error VALIDATION PROBLEMS WERE FOUND <5:4> problem: cvc->complex-type.2.3: Element 'web-app#http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content. <14:5> problem: cvc-complex-type.2.4a: Expected element 'url-pattern#http://java.sun.com/xml/ns/javaee' instead of 'load-on-startup#http://java.sun.com/xml/ns/javaee' here in element servlet-mapping#http://java.sun.com/xml/ns/javaee <18:5> problem: cvc-complex-type.2.4b: Element not allowed: listener-class#http://java.sun.com/xml/ns/javaee in element listener#http://java.sun.com/xml/ns/javaee
Below is my web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ">
>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
<load-on-startup>1</load-on-startup>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml
</param-value>
</context-param>
and here's my weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app ht
tp://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<context-root>/</context-root>
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
<prefer-application-packages>
<package-name>javax.faces.*</package-name>
<package-name>com.sun.faces.*</package-name>
<package-name>com.bea.faces.*</package-name>
<package-name>org.slf4j.*</package-name>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>javax.faces.*</resource-name>
<resource-name>com.sun.faces.*</resource-name>
<resource-name>com.bea.faces.*</resource-name>
<resource-name>com.google.common.*</resource-name>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
</prefer-application-resources>
</container-descriptor>
<session-descriptor>
<cookie-secure>true</cookie-secure>
<url-rewriting-enabled>false</url-rewriting-enabled>
<!-- <cookie-http-only>true</cookie-http-only> -->
</session-descriptor>
<virtual-directory-mapping>
<local-path>/usr/local/WebLogic/wlApps/miDocs</local-path>
<url-pattern>/docs/*</url-pattern>
</virtual-directory-mapping>
The folder structure matches as per the description in the oracle website
Any help is appreciated
Thinky ou have two Problems here:
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ">
>
First a blank at the end of the schemaLocation.
Second > is too much
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ">
>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml
</param-value>
</context-param>
</web-app>
This question already has answers here:
Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"
(19 answers)
Closed 5 years ago.
The xml file is located in WebContent/WEB-INF/web.xml of my project. I am using Eclipse and running Tomcat (which is not installed via Eclipse. I prefer it to be a separate installation).
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>EmployeeManagement</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>name</param-name>
<param-value>Pramod</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
</web-app>
It doesnt work when the form page submits to the servlet. I am getting a 404 error everytime. I have been encountering this problem for a while. Somebody please help me.
You are missing <servlet>...</servlet> tag which is important to mapping. So use following :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>EmployeeManagement</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>name</param-name>
<param-value>Pramod</param-value>
</context-param>
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.yourPackageName.yourServletName</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
</web-app>
and you should give action value on your form like following:
<form action="/EmployeeManagement/WebContent/Registration" method="post">
//Some code here
</form>
and also note it down all values are case sensitive on the following code:
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.yourPackageName.yourServletName</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
Your servlet name Registration should be same on both tags <servlet>...</servlet> and <servlet-mapping>...</servlet-mapping> and also package name should be same where your servlet class is located.
you have not mapped servlet name to servlet class, It should be like given below,
In <servlet-class> give the path of your servlet
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.Registration<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
Check your form action.
Is the path there
/EmployeeManagement/WebContent/Registration
or
YOURAPPCONTEXT/EmployeeManagement/WebContent/Registration
or
YOURAPPNAME/EmployeeManagement/WebContent/Registration
You have specifyed a servlet-mapping and used the name Registration in servlet-name without defining it before.
You need to define the servlet before using it in a servlet mapping
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>[fully qualifyied name of your servlet]</servlet-class>
</servlet>
You are missing another part to define the servlet in the web.xml
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>
package.path.to.RegistrationServlet
</servlet-class>
</servlet>
You forgot a vital part of the configuration. You should add this to your web.xml before servlet-mapping tag:
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.name.of.your.servlet.class</servlet-class>
</servlet>
I have a rest easy url. When i type the url in browser java class get called returns the output. when i call the index.html file it is not loading. i am using tomcat7
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com /xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns
/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>projectname</display-name>
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/projectnamedb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>${catalina.home}\conf\log4j.properties</param-value>
</context-param>
<context-param>
<param-name>inputPropertiesLocation</param-name>
<param-value>${catalina.home}\conf\projectDetails.properties</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
</web-app>
Well 2 things to know here
1) You cannot type simply http://index.html you have to give path to the index page like http://projectname/path/to/index.html
2) The other simple way is to add index.html as welcome page. So when-ever server is started it opens index.html page at first. like
<welcome-file-list>
<welcome-file>path/to/index.html</welcome-file>
</welcome-file-list>
This question already has answers here:
Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"
(19 answers)
Closed 5 years ago.
The xml file is located in WebContent/WEB-INF/web.xml of my project. I am using Eclipse and running Tomcat (which is not installed via Eclipse. I prefer it to be a separate installation).
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>EmployeeManagement</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>name</param-name>
<param-value>Pramod</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
</web-app>
It doesnt work when the form page submits to the servlet. I am getting a 404 error everytime. I have been encountering this problem for a while. Somebody please help me.
You are missing <servlet>...</servlet> tag which is important to mapping. So use following :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>EmployeeManagement</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>name</param-name>
<param-value>Pramod</param-value>
</context-param>
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.yourPackageName.yourServletName</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
</web-app>
and you should give action value on your form like following:
<form action="/EmployeeManagement/WebContent/Registration" method="post">
//Some code here
</form>
and also note it down all values are case sensitive on the following code:
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.yourPackageName.yourServletName</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
Your servlet name Registration should be same on both tags <servlet>...</servlet> and <servlet-mapping>...</servlet-mapping> and also package name should be same where your servlet class is located.
you have not mapped servlet name to servlet class, It should be like given below,
In <servlet-class> give the path of your servlet
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.Registration<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Registration</servlet-name>
<url-pattern>/EmployeeManagement/WebContent/Registration</url-pattern>
</servlet-mapping>
Check your form action.
Is the path there
/EmployeeManagement/WebContent/Registration
or
YOURAPPCONTEXT/EmployeeManagement/WebContent/Registration
or
YOURAPPNAME/EmployeeManagement/WebContent/Registration
You have specifyed a servlet-mapping and used the name Registration in servlet-name without defining it before.
You need to define the servlet before using it in a servlet mapping
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>[fully qualifyied name of your servlet]</servlet-class>
</servlet>
You are missing another part to define the servlet in the web.xml
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>
package.path.to.RegistrationServlet
</servlet-class>
</servlet>
You forgot a vital part of the configuration. You should add this to your web.xml before servlet-mapping tag:
<servlet>
<servlet-name>Registration</servlet-name>
<servlet-class>com.name.of.your.servlet.class</servlet-class>
</servlet>
When I try to deploy a WAR file by dropping it into webapps directory, I get following message in the console:
04.05.2011 19:34:07 org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying configuration descriptor xyz.war
I didn't find any hints about the detailed cause of this in the logs.
Where can I find out the details (e. g. the stack trace) about this failure?
Here's the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>myapp</display-name>
<context-param>
<description>
Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Project Control Center Application</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>
Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>at.mycompany.myapp.ProjectControlCenterApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Project Control Center Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>at.mycompany.myapp.impl.persistence.DatabaseStartStopServletContextListener</listener-class>
</listener>
<session-config>
<session-timeout>480</session-timeout>
</session-config>
</web-app>
I found the answer. The cause of the problem was a malformed context.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" ...>
<welcome-file-list>
<welcome-file>
...
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>info</servlet-name>
<servlet-class>servlets.info.Properties</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Properties</servlet-name>
<!-- Here I forget to change the servlet name to info -->
<!-- So, the reason is invalid web.xml file -->
<url-pattern>/Properties</url-pattern>
</servlet-mapping>
</web-app>
Double-check your web.xml file.